Fix T93155: Approximate shadow catcher displayed wrong on CPU and GPU

Was happening during rendering, causing visual artifacts when doing
CPU+GPU rendering, and giving different in-progress results on different
devices.

The root of the issue comes to the fact that math used in the approximate
shadow catcher calculation might have resulted in negative alpha channel,
and negative values for display are handled differently on CPU and GPU.
Such difference in handling is caused by an approximate conversion used on
the CPU for the performance reasons.

This change makes it so no negative alpha is generated by the approximate
shadow catcher. Not sure if we need some explicit clamping somewhere to
deal with possible negative values coming from somewhere else.

The shadow catcher cornell box tests are to be updated for the new code,
but the new result seems to be more accurate.

Differential Revision: https://developer.blender.org/D13354
This commit is contained in:
Sergey Sharybin 2021-11-24 17:06:32 +01:00
parent ce5561b815
commit 726bc3a46b
Notes: blender-bot 2023-02-14 08:08:54 +01:00
Referenced by issue #93155, Rendering window is displaying wrongly result during rendering.
1 changed files with 1 additions and 1 deletions

View File

@ -460,7 +460,7 @@ ccl_device_inline float4 film_calculate_shadow_catcher_matte_with_shadow(
const float transparency = in_matte[3] * scale;
const float alpha = saturatef(1.0f - transparency);
const float alpha_matte = (1.0f - alpha) * (1.0f - average(shadow_catcher)) + alpha;
const float alpha_matte = (1.0f - alpha) * (1.0f - saturatef(average(shadow_catcher))) + alpha;
if (kfilm_convert->use_approximate_shadow_catcher_background) {
kernel_assert(kfilm_convert->pass_background != PASS_UNUSED);