diff --git a/intern/cycles/kernel/film/read.h b/intern/cycles/kernel/film/read.h index 108f992e29d..6c29b79b29b 100644 --- a/intern/cycles/kernel/film/read.h +++ b/intern/cycles/kernel/film/read.h @@ -485,11 +485,19 @@ ccl_device_inline float4 film_calculate_shadow_catcher_matte_with_shadow( if (kfilm_convert->use_approximate_shadow_catcher_background) { kernel_assert(kfilm_convert->pass_background != PASS_UNUSED); + kernel_assert(kfilm_convert->pass_shadow_catcher_sample_count != PASS_UNUSED); + + ccl_global const float *in_catcher_sample_count = + buffer + kfilm_convert->pass_shadow_catcher_sample_count; + const float num_samples = in_catcher_sample_count[0]; + const float background_scale_exposure = (num_samples != 0.0f) ? + (1.0f / num_samples * kfilm_convert->exposure) : + scale_exposure; ccl_global const float *in_background = buffer + kfilm_convert->pass_background; const float3 color_background = make_float3( in_background[0], in_background[1], in_background[2]) * - scale_exposure; + background_scale_exposure; const float3 alpha_over = color_matte + color_background * (1.0f - alpha_matte); return make_float4(alpha_over.x, alpha_over.y, alpha_over.z, 1.0f); }