Fix #115424: Cycles object space normal map wrong with backfaces
This commit is contained in:
@@ -324,6 +324,11 @@ ccl_device_noinline void svm_node_normal_map(KernelGlobals kg,
|
||||
|
||||
/* transform to world space */
|
||||
object_normal_transform(kg, sd, &N);
|
||||
|
||||
/* invert normal for backfacing polygons */
|
||||
if (is_backfacing) {
|
||||
N = -N;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* strange blender convention */
|
||||
@@ -335,10 +340,18 @@ ccl_device_noinline void svm_node_normal_map(KernelGlobals kg,
|
||||
/* object, world space */
|
||||
N = color;
|
||||
|
||||
if (space == NODE_NORMAL_MAP_OBJECT || space == NODE_NORMAL_MAP_BLENDER_OBJECT)
|
||||
if (space == NODE_NORMAL_MAP_OBJECT || space == NODE_NORMAL_MAP_BLENDER_OBJECT) {
|
||||
object_normal_transform(kg, sd, &N);
|
||||
else
|
||||
}
|
||||
else {
|
||||
N = safe_normalize(N);
|
||||
}
|
||||
|
||||
/* invert normal for backfacing polygons */
|
||||
if (is_backfacing) {
|
||||
N = -N;
|
||||
}
|
||||
|
||||
/* Apply strength in all but tangent space. */
|
||||
if (strength != 1.0f) {
|
||||
strength = max(strength, 0.0f);
|
||||
@@ -346,11 +359,6 @@ ccl_device_noinline void svm_node_normal_map(KernelGlobals kg,
|
||||
}
|
||||
}
|
||||
|
||||
/* invert normal for backfacing polygons */
|
||||
if (is_backfacing) {
|
||||
N = -N;
|
||||
}
|
||||
|
||||
if (is_zero(N)) {
|
||||
N = sd->N;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user