diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-07-23 10:54:49 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-07-23 11:00:52 +0400 |
commit | 9fcaac5009b567edc59c4831b6a0580211d1d290 (patch) | |
tree | 001d9951652c731a71b21ad58a9ed473ab33294e /intern/cycles/kernel/geom/geom_triangle.h | |
parent | 54109add6578da9f306973e2e224664e2d63e534 (diff) |
Fix T41147: Static BVH shading problem
Fix T41079: Solid black render of object with negative scale and smooth shading
In both cases the issue was caused by negative scaled objects with single mesh
users for which scale gets applied when using static BVH.
Since the on-fly normals calculation land normals for such cases weren't flipped
leading them to point to a wrong direction.
Added a special object flag for this, which is a bit of a bummer because now
we've got less bits for real useful things, but this is the only way to get
proper normals without adding more complexity in the on-fly calculations.
Diffstat (limited to 'intern/cycles/kernel/geom/geom_triangle.h')
-rw-r--r-- | intern/cycles/kernel/geom/geom_triangle.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/intern/cycles/kernel/geom/geom_triangle.h b/intern/cycles/kernel/geom/geom_triangle.h index f2f35c2efd0..f4e53be5429 100644 --- a/intern/cycles/kernel/geom/geom_triangle.h +++ b/intern/cycles/kernel/geom/geom_triangle.h @@ -117,17 +117,20 @@ ccl_device_inline float3 triangle_refine_subsurface(KernelGlobals *kg, ShaderDat } /* normal on triangle */ -ccl_device_inline float3 triangle_normal(KernelGlobals *kg, int prim) +ccl_device_inline float3 triangle_normal(KernelGlobals *kg, ShaderData *sd) { /* load triangle vertices */ - float3 tri_vindex = float4_to_float3(kernel_tex_fetch(__tri_vindex, prim)); + float3 tri_vindex = float4_to_float3(kernel_tex_fetch(__tri_vindex, sd->prim)); float3 v0 = float4_to_float3(kernel_tex_fetch(__tri_verts, __float_as_int(tri_vindex.x))); float3 v1 = float4_to_float3(kernel_tex_fetch(__tri_verts, __float_as_int(tri_vindex.y))); float3 v2 = float4_to_float3(kernel_tex_fetch(__tri_verts, __float_as_int(tri_vindex.z))); /* return normal */ - return normalize(cross(v1 - v0, v2 - v0)); + if(sd->flag & SD_NEGATIVE_SCALE_APPLIED) + return normalize(cross(v2 - v0, v1 - v0)); + else + return normalize(cross(v1 - v0, v2 - v0)); } /* point and normal on triangle */ |