[Bf-blender-cvs] [6f23e4484d0] master: Fix non-finite curve normal causing Cycles to crash

Sergey Sharybin noreply at git.blender.org
Wed Sep 29 19:55:04 CEST 2021


Commit: 6f23e4484d03f75ba1618f76114b3f81d5db0ae7
Author: Sergey Sharybin
Date:   Wed Sep 29 19:32:42 2021 +0200
Branches: master
https://developer.blender.org/rB6f23e4484d03f75ba1618f76114b3f81d5db0ae7

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!

Differential Revision: https://developer.blender.org/D12703

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

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 b2101034bb6..a068e93790a 100644
--- a/intern/cycles/kernel/geom/geom_curve_intersect.h
+++ b/intern/cycles/kernel/geom/geom_curve_intersect.h
@@ -764,8 +764,10 @@ ccl_device_inline void curve_shader_setup(const 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, sd->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