Fix T61103: Cycles bevel wrong on objects with negative scale.

This commit is contained in:
Brecht Van Lommel 2019-03-11 10:20:31 +01:00
parent 6503b4f90f
commit 56a633fd2c
Notes: blender-bot 2023-02-14 03:52:45 +01:00
Referenced by issue #61103, Mirrored objects render black when using the Bevel Node
2 changed files with 10 additions and 4 deletions

View File

@ -56,7 +56,7 @@ ccl_device_noinline void shader_setup_from_ray(KernelGlobals *kg,
PROFILING_INIT(kg, PROFILING_SHADER_SETUP);
#ifdef __INSTANCING__
sd->object = (isect->object == PRIM_NONE)? kernel_tex_fetch(__prim_object, isect->prim): isect->object;
sd->object = (isect->object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, isect->prim): isect->object;
#endif
sd->lamp = LAMP_NONE;
@ -411,7 +411,7 @@ ccl_device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderDat
sd->ray_length = 0.0f;
#ifdef __INSTANCING__
sd->object = PRIM_NONE;
sd->object = OBJECT_NONE;
#endif
sd->lamp = LAMP_NONE;
sd->prim = PRIM_NONE;
@ -457,7 +457,7 @@ ccl_device_inline void shader_setup_from_volume(KernelGlobals *kg, ShaderData *s
sd->ray_length = 0.0f; /* todo: can we set this to some useful value? */
# ifdef __INSTANCING__
sd->object = PRIM_NONE; /* todo: fill this for texture coordinates */
sd->object = OBJECT_NONE; /* todo: fill this for texture coordinates */
# endif
sd->lamp = LAMP_NONE;
sd->prim = PRIM_NONE;

View File

@ -146,7 +146,13 @@ ccl_device_noinline float3 svm_bevel(
}
#endif /* __OBJECT_MOTION__ */
/* Get geometric normal. */
float3 hit_Ng = isect.Ng[hit];
int object = (isect.hits[hit].object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, isect.hits[hit].prim): isect.hits[hit].object;
int object_flag = kernel_tex_fetch(__object_flag, object);
if(object_flag & SD_OBJECT_NEGATIVE_SCALE_APPLIED) {
hit_Ng = -hit_Ng;
}
/* Compute smooth normal. */
float3 N = hit_Ng;
@ -168,7 +174,7 @@ ccl_device_noinline float3 svm_bevel(
}
/* Transform normals to world space. */
if(isect.hits[hit].object != OBJECT_NONE) {
if(!(object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
object_normal_transform(kg, sd, &N);
object_normal_transform(kg, sd, &hit_Ng);
}