diff options
author | Sergey Sharybin <sergey@blender.org> | 2021-09-29 20:32:42 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey@blender.org> | 2021-09-29 20:49:59 +0300 |
commit | 6f23e4484d03f75ba1618f76114b3f81d5db0ae7 (patch) | |
tree | 679aa3ea9a3e76de2ef2f2a69dfde285b28a0c6e | |
parent | 1d478851f847047ad6253e8599407b138bc8d70e (diff) |
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
-rw-r--r-- | intern/cycles/kernel/geom/geom_curve_intersect.h | 4 |
1 files changed, 3 insertions, 1 deletions
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; |