Fix #111277: NaN in Vector Displacement leading to render errors
Fixes NaN in Vector Displacement node caused by the normalization of 0, 0, 0 vectors. This fixes both visual rendering issues and an "illegal address" error on the GPU. The "illegal address" error came from the Light Tree Sampling code not handling the NaN normals well, leading to weird code paths being taken, eventually leading to a kernel_assert and a user facing illegal address error. Pull Request: https://projects.blender.org/blender/blender/pulls/111294
This commit is contained in:
parent
8b311daf0a
commit
7f65080ab4
|
@ -165,7 +165,7 @@ ccl_device_noinline int svm_node_vector_displacement(
|
|||
tangent = normalize(sd->dPdu);
|
||||
}
|
||||
|
||||
float3 bitangent = normalize(cross(normal, tangent));
|
||||
float3 bitangent = safe_normalize(cross(normal, tangent));
|
||||
const AttributeDescriptor attr_sign = find_attribute(kg, sd, node.w);
|
||||
if (attr_sign.offset != ATTR_STD_NOT_FOUND) {
|
||||
float sign = primitive_surface_attribute_float(kg, sd, attr_sign, NULL, NULL);
|
||||
|
|
|
@ -3,7 +3,7 @@ void node_vector_displacement_tangent(
|
|||
{
|
||||
vec3 oN = normalize(normal_world_to_object(g_data.N));
|
||||
vec3 oT = normalize(normal_world_to_object(T.xyz));
|
||||
vec3 oB = T.w * normalize(cross(oN, oT));
|
||||
vec3 oB = T.w * safe_normalize(cross(oN, oT));
|
||||
|
||||
result = (vector.xyz - midlevel) * scale;
|
||||
result = result.x * oT + result.y * oN + result.z * oB;
|
||||
|
|
Loading…
Reference in New Issue