[Bf-blender-cvs] [dfd12901242] cycles-x: Fix shadow catcher casting unnecessary shadows in some cases

Brecht Van Lommel noreply at git.blender.org
Mon Jul 26 16:36:21 CEST 2021


Commit: dfd12901242d0448d8b61700c920e4b7def57510
Author: Brecht Van Lommel
Date:   Mon Jul 26 14:58:00 2021 +0200
Branches: cycles-x
https://developer.blender.org/rBdfd12901242d0448d8b61700c920e4b7def57510

Fix shadow catcher casting unnecessary shadows in some cases

When both the render with and without synthetic objects results in a black
pixel and we get 0/0, we previously would assume that area is fully shadowed.
Now assume there is no shadow.

The correct result is unknown in this case. But for the case where an adjacent
pixel has 0.001/0.001, this avoids a discontinuity.

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

M	intern/cycles/kernel/kernel_film.h

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

diff --git a/intern/cycles/kernel/kernel_film.h b/intern/cycles/kernel/kernel_film.h
index 65966e0fef6..233b38b99a0 100644
--- a/intern/cycles/kernel/kernel_film.h
+++ b/intern/cycles/kernel/kernel_film.h
@@ -298,6 +298,17 @@ film_calculate_shadow_catcher_denoised(const KernelFilmConvert *ccl_restrict kfi
   return pixel;
 }
 
+ccl_device_inline float3 safe_divide_shadow_catcher(float3 a, float3 b)
+{
+  float x, y, z;
+
+  x = (b.x != 0.0f) ? a.x / b.x : 1.0f;
+  y = (b.y != 0.0f) ? a.y / b.y : 1.0f;
+  z = (b.z != 0.0f) ? a.z / b.z : 1.0f;
+
+  return make_float3(x, y, z);
+}
+
 ccl_device_inline float3
 film_calculate_shadow_catcher(const KernelFilmConvert *ccl_restrict kfilm_convert,
                               ccl_global const float *ccl_restrict buffer)
@@ -344,7 +355,7 @@ film_calculate_shadow_catcher(const KernelFilmConvert *ccl_restrict kfilm_conver
    * the matte objects were not accumulated to the combined pass. */
   const float3 combined_no_matte = color_combined - color_matte;
 
-  const float3 shadow_catcher = safe_divide_color(combined_no_matte, color_catcher);
+  const float3 shadow_catcher = safe_divide_shadow_catcher(combined_no_matte, color_catcher);
 
   const float scale = film_get_scale(kfilm_convert, buffer);
   const float transparency = in_combined[3] * scale;



More information about the Bf-blender-cvs mailing list