Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2014-08-13 14:19:12 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2014-08-13 14:35:54 +0400
commitbfaf4f2d0d4e600f6f8e253033de2b05a93e3ec1 (patch)
tree3299b51ca6994b30900da058176df1f5c4ef5848 /intern/cycles/kernel/geom/geom_triangle.h
parent8d801c3afd39d66d249c8b7e45249339ad297fcf (diff)
Fix T41219: Cycles backface detection doesn't work properly
Root of the issue goes back to the on-fly normals commit and the latest fix for it wasn't actually correct. I've mixed two fixes in there. So the idea here goes back to storing negative scaled object flag and flip runtime-calculated normal if this flag is set, which is pretty much the same as the original fix for the issue from me. The issue with motion blur wasn't caused by the rumtime normals patch and it had issues before, because it already did runtime normals calculation. Now made it so motion triangles takes the negative scale flag into account. This actually makes code more clean imo and avoids rather confusing flipping code in mesh.cpp.
Diffstat (limited to 'intern/cycles/kernel/geom/geom_triangle.h')
-rw-r--r--intern/cycles/kernel/geom/geom_triangle.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/intern/cycles/kernel/geom/geom_triangle.h b/intern/cycles/kernel/geom/geom_triangle.h
index 27d1351568a..35dd5b2324e 100644
--- a/intern/cycles/kernel/geom/geom_triangle.h
+++ b/intern/cycles/kernel/geom/geom_triangle.h
@@ -127,11 +127,14 @@ ccl_device_inline float3 triangle_normal(KernelGlobals *kg, ShaderData *sd)
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 */
-ccl_device_inline void triangle_point_normal(KernelGlobals *kg, int prim, float u, float v, float3 *P, float3 *Ng, int *shader)
+ccl_device_inline void triangle_point_normal(KernelGlobals *kg, int object, int prim, float u, float v, float3 *P, float3 *Ng, int *shader)
{
/* load triangle vertices */
float3 tri_vindex = float4_to_float3(kernel_tex_fetch(__tri_vindex, prim));
@@ -145,7 +148,11 @@ ccl_device_inline void triangle_point_normal(KernelGlobals *kg, int prim, float
*P = (u*v0 + v*v1 + t*v2);
/* compute normal */
- *Ng = normalize(cross(v1 - v0, v2 - v0));
+ int object_flag = kernel_tex_fetch(__object_flag, object);
+ if(object_flag & SD_NEGATIVE_SCALE_APPLIED)
+ *Ng = normalize(cross(v2 - v0, v1 - v0));
+ else
+ *Ng = normalize(cross(v1 - v0, v2 - v0));
/* shader`*/
*shader = __float_as_int(kernel_tex_fetch(__tri_shader, prim));