diff options
author | Stefan Werner <stefan.werner@tangent-animation.com> | 2020-11-20 01:15:09 +0300 |
---|---|---|
committer | Stefan Werner <stefan.werner@tangent-animation.com> | 2020-11-20 01:15:09 +0300 |
commit | fdd3032f8fadf3a2de2cff9452801549fa79a779 (patch) | |
tree | a807381fdc5319d1e540604a6593106b6eaf1593 | |
parent | 72a199e148b20c36a63cdf6c6af067c9bcdb3f92 (diff) |
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.
-rw-r--r-- | intern/cycles/kernel/svm/svm_tex_coord.h | 6 |
1 files changed, 4 insertions, 2 deletions
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; } |