[Bf-blender-cvs] [3172aa9ac5f] temp-studio-sprite-fright-cycles: Fix non-finite curve normal causing Cycles to crash

Sergey Sharybin noreply at git.blender.org
Wed Sep 29 19:57:53 CEST 2021


Commit: 3172aa9ac5f4290a73c3031de914a837689a5942
Author: Sergey Sharybin
Date:   Wed Sep 29 19:32:42 2021 +0200
Branches: temp-studio-sprite-fright-cycles
https://developer.blender.org/rB3172aa9ac5f4290a73c3031de914a837689a5942

Fix non-finite curve normal causing Cycles to crash

Similar to the previous change in the area: need to avoid ray
point and direction becoming a non-finite value.

Use the view direction when the geometrical normal can not be
calculated.

Collaboration and sanity inspiration with Brecht!

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

M	intern/cycles/kernel/geom/geom_curve_intersect.h

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

diff --git a/intern/cycles/kernel/geom/geom_curve_intersect.h b/intern/cycles/kernel/geom/geom_curve_intersect.h
index 063c72d5d9f..24c8f6b6282 100644
--- a/intern/cycles/kernel/geom/geom_curve_intersect.h
+++ b/intern/cycles/kernel/geom/geom_curve_intersect.h
@@ -765,8 +765,10 @@ ccl_device_inline void curve_shader_setup(KernelGlobals *kg,
     /* Thick curves, compute normal using direction from inside the curve.
      * This could be optimized by recording the normal in the intersection,
      * however for Optix this would go beyond the size of the payload. */
+    /* NOTE: It is possible that P will be the same as P_inside (precision issues, or very small
+     * radius). In this case use the view direction to approximate the normal. */
     const float3 P_inside = float4_to_float3(catmull_rom_basis_eval(P_curve, isect->u));
-    const float3 Ng = normalize(P - P_inside);
+    const float3 Ng = (!isequal_float3(P, P_inside)) ? normalize(P - P_inside) : -sd->I;
 
     sd->N = Ng;
     sd->Ng = Ng;



More information about the Bf-blender-cvs mailing list