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.
This commit is contained in:
parent
72a199e148
commit
fdd3032f8f
Notes:
blender-bot
2023-02-14 10:37:49 +01:00
Referenced by issue #82859, Blender crashes anytime the renderer is set to OpenCL. Referenced by issue #82865, CUDA ERROR due to Global coordinates for texture in displace modifier
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue