Cycles: Fix potential NaN in normal mapping
I ran into this in a test scene - somehow the normalization here can result in NaN (so presumably a zero vector). I don't think this has a notable performance impact from some basic tests. Pull Request: https://projects.blender.org/blender/blender/pulls/125930
This commit is contained in:
committed by
Lukas Stockner
parent
c20bb31325
commit
b119e1a497
@@ -172,7 +172,7 @@ ccl_device_inline void object_inverse_normal_transform(KernelGlobals kg,
|
||||
#ifdef __OBJECT_MOTION__
|
||||
if (sd->object_flag & SD_OBJECT_MOTION) {
|
||||
if ((sd->object != OBJECT_NONE) || (sd->type == PRIMITIVE_LAMP)) {
|
||||
*N = normalize(transform_direction_transposed_auto(&sd->ob_tfm_motion, *N));
|
||||
*N = safe_normalize(transform_direction_transposed_auto(&sd->ob_tfm_motion, *N));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -180,11 +180,11 @@ ccl_device_inline void object_inverse_normal_transform(KernelGlobals kg,
|
||||
|
||||
if (sd->object != OBJECT_NONE) {
|
||||
Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_TRANSFORM);
|
||||
*N = normalize(transform_direction_transposed(&tfm, *N));
|
||||
*N = safe_normalize(transform_direction_transposed(&tfm, *N));
|
||||
}
|
||||
else if (sd->type == PRIMITIVE_LAMP) {
|
||||
Transform tfm = lamp_fetch_transform(kg, sd->lamp, false);
|
||||
*N = normalize(transform_direction_transposed(&tfm, *N));
|
||||
*N = safe_normalize(transform_direction_transposed(&tfm, *N));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user