diff options
Diffstat (limited to 'intern/cycles/kernel')
-rw-r--r-- | intern/cycles/kernel/geom/geom_shader_data.h | 2 | ||||
-rw-r--r-- | intern/cycles/kernel/integrator/integrator_init_from_bake.h | 25 |
2 files changed, 23 insertions, 4 deletions
diff --git a/intern/cycles/kernel/geom/geom_shader_data.h b/intern/cycles/kernel/geom/geom_shader_data.h index fb2cb5cb1ea..0e373c10086 100644 --- a/intern/cycles/kernel/geom/geom_shader_data.h +++ b/intern/cycles/kernel/geom/geom_shader_data.h @@ -103,7 +103,7 @@ ccl_device_inline void shader_setup_from_ray(const KernelGlobals *ccl_restrict k sd->flag |= kernel_tex_fetch(__shaders, (sd->shader & SHADER_MASK)).flags; - if (isect->object != OBJECT_NONE) { + if (!(sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED)) { /* instance transform */ object_normal_transform_auto(kg, sd, &sd->N); object_normal_transform_auto(kg, sd, &sd->Ng); diff --git a/intern/cycles/kernel/integrator/integrator_init_from_bake.h b/intern/cycles/kernel/integrator/integrator_init_from_bake.h index 96db606cee1..6e4e1be55fa 100644 --- a/intern/cycles/kernel/integrator/integrator_init_from_bake.h +++ b/intern/cycles/kernel/integrator/integrator_init_from_bake.h @@ -109,9 +109,17 @@ ccl_device bool integrator_init_from_bake(INTEGRATOR_STATE_ARGS, } /* Position and normal on triangle. */ + const int object = kernel_data.bake.object_index; float3 P, Ng; int shader; - triangle_point_normal(kg, kernel_data.bake.object_index, prim, u, v, &P, &Ng, &shader); + triangle_point_normal(kg, object, prim, u, v, &P, &Ng, &shader); + + const int object_flag = kernel_tex_fetch(__object_flag, object); + if (!(object_flag & SD_OBJECT_TRANSFORM_APPLIED)) { + Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM); + P = transform_point_auto(&tfm, P); + } + if (kernel_data.film.pass_background != PASS_UNUSED) { /* Environment baking. */ @@ -130,8 +138,13 @@ ccl_device bool integrator_init_from_bake(INTEGRATOR_STATE_ARGS, } else { /* Surface baking. */ - const float3 N = (shader & SHADER_SMOOTH_NORMAL) ? triangle_smooth_normal(kg, Ng, prim, u, v) : - Ng; + float3 N = (shader & SHADER_SMOOTH_NORMAL) ? triangle_smooth_normal(kg, Ng, prim, u, v) : Ng; + + if (!(object_flag & SD_OBJECT_TRANSFORM_APPLIED)) { + Transform itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM); + N = normalize(transform_direction_transposed(&itfm, N)); + Ng = normalize(transform_direction_transposed(&itfm, Ng)); + } /* Setup ray. */ Ray ray ccl_optional_struct_init; @@ -143,6 +156,12 @@ ccl_device bool integrator_init_from_bake(INTEGRATOR_STATE_ARGS, /* Setup differentials. */ float3 dPdu, dPdv; triangle_dPdudv(kg, prim, &dPdu, &dPdv); + if (!(object_flag & SD_OBJECT_TRANSFORM_APPLIED)) { + Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM); + dPdu = transform_direction(&tfm, dPdu); + dPdv = transform_direction(&tfm, dPdv); + } + differential3 dP; dP.dx = dPdu * dudx + dPdv * dvdx; dP.dy = dPdu * dudy + dPdv * dvdy; |