Fix T99179: holdout does not affect transparency without transparent background

This was by design, but maybe not so useful in practice. It's always possible to
set alpha to 1 in compositing if needed.
This commit is contained in:
Brecht Van Lommel 2022-08-05 15:12:43 +02:00
parent fa514564b0
commit 43a124bc1c
Notes: blender-bot 2023-02-14 09:44:56 +01:00
Referenced by issue #99179, Cycles holdout depends on world transparency
2 changed files with 6 additions and 14 deletions

View File

@ -913,8 +913,6 @@ void BlenderDisplayDriver::flush()
void BlenderDisplayDriver::draw(const Params &params)
{
/* See do_update_begin() for why no locking is required here. */
const bool transparent = true; // TODO(sergey): Derive this from Film.
if (use_gl_context_) {
gl_context_mutex_.lock();
}
@ -935,10 +933,8 @@ void BlenderDisplayDriver::draw(const Params &params)
glWaitSync((GLsync)gl_upload_sync_, 0, GL_TIMEOUT_IGNORED);
}
if (transparent) {
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
}
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glActiveTexture(GL_TEXTURE0);
@ -975,9 +971,7 @@ void BlenderDisplayDriver::draw(const Params &params)
glDeleteVertexArrays(1, &vertex_array_object);
if (transparent) {
glDisable(GL_BLEND);
}
glDisable(GL_BLEND);
gl_render_sync_ = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
glFlush();

View File

@ -43,11 +43,9 @@ ccl_device_forceinline bool integrate_surface_holdout(KernelGlobals kg,
if (((sd->flag & SD_HOLDOUT) || (sd->object_flag & SD_OBJECT_HOLDOUT_MASK)) &&
(path_flag & PATH_RAY_TRANSPARENT_BACKGROUND)) {
const float3 holdout_weight = shader_holdout_apply(kg, sd);
if (kernel_data.background.transparent) {
const float3 throughput = INTEGRATOR_STATE(state, path, throughput);
const float transparent = average(holdout_weight * throughput);
kernel_accum_holdout(kg, state, path_flag, transparent, render_buffer);
}
const float3 throughput = INTEGRATOR_STATE(state, path, throughput);
const float transparent = average(holdout_weight * throughput);
kernel_accum_holdout(kg, state, path_flag, transparent, render_buffer);
if (isequal(holdout_weight, one_float3())) {
return false;
}