[Bf-blender-cvs] [fdd3032f8fa] master: Cycles: Fixed zero sized normals when certain attributes were missing.

Stefan Werner noreply at git.blender.org
Thu Nov 19 23:17:32 CET 2020


Commit: fdd3032f8fadf3a2de2cff9452801549fa79a779
Author: Stefan Werner
Date:   Thu Nov 19 23:15:09 2020 +0100
Branches: master
https://developer.blender.org/rBfdd3032f8fadf3a2de2cff9452801549fa79a779

Cycles: Fixed zero sized normals when certain attributes were missing.

The Normal Map node was falling back to (0, 0, 0) when it was missing
the required attributes to calculate a new normal.
(0, 0, 0) is not a valid normal and can lead to NaNs when it is
normalized later in the shader. Instead, we now return sd->N,
the unperturbed surface normal.

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

M	intern/cycles/kernel/svm/svm_tex_coord.h

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

diff --git a/intern/cycles/kernel/svm/svm_tex_coord.h b/intern/cycles/kernel/svm/svm_tex_coord.h
index a876d6bc916..4fe940f1a67 100644
--- a/intern/cycles/kernel/svm/svm_tex_coord.h
+++ b/intern/cycles/kernel/svm/svm_tex_coord.h
@@ -268,7 +268,8 @@ ccl_device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *st
   if (space == NODE_NORMAL_MAP_TANGENT) {
     /* tangent space */
     if (sd->object == OBJECT_NONE) {
-      stack_store_float3(stack, normal_offset, make_float3(0.0f, 0.0f, 0.0f));
+      /* Fallback to unperturbed normal. */
+      stack_store_float3(stack, normal_offset, sd->N);
       return;
     }
 
@@ -279,7 +280,8 @@ ccl_device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *st
 
     if (attr.offset == ATTR_STD_NOT_FOUND || attr_sign.offset == ATTR_STD_NOT_FOUND ||
         attr_normal.offset == ATTR_STD_NOT_FOUND) {
-      stack_store_float3(stack, normal_offset, make_float3(0.0f, 0.0f, 0.0f));
+      /* Fallback to unperturbed normal. */
+      stack_store_float3(stack, normal_offset, sd->N);
       return;
     }



More information about the Bf-blender-cvs mailing list