[Bf-blender-cvs] [726bc3a46b2] blender-v3.0-release: Fix T93155: Approximate shadow catcher displayed wrong on CPU and GPU

Sergey Sharybin noreply at git.blender.org
Thu Nov 25 10:17:56 CET 2021


Commit: 726bc3a46b2fcf6ba36c3e3484b344340f83e53e
Author: Sergey Sharybin
Date:   Wed Nov 24 17:06:32 2021 +0100
Branches: blender-v3.0-release
https://developer.blender.org/rB726bc3a46b2fcf6ba36c3e3484b344340f83e53e

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

===================================================================

M	intern/cycles/kernel/film/read.h

===================================================================

diff --git a/intern/cycles/kernel/film/read.h b/intern/cycles/kernel/film/read.h
index d308a9818e2..18a593a75b1 100644
--- a/intern/cycles/kernel/film/read.h
+++ b/intern/cycles/kernel/film/read.h
@@ -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);



More information about the Bf-blender-cvs mailing list