diff options
author | Brecht Van Lommel <brecht@blender.org> | 2022-07-26 17:07:50 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-07-27 22:03:33 +0300 |
commit | 38af5b0501005d8ee84a59f027417bf6a31fcc5e (patch) | |
tree | 0856dd31787e59abe9300a8d4b3c6b37be3cfbc8 /intern/cycles/kernel/geom/triangle_intersect.h | |
parent | 69f2732a1391680d252c86365b2df62b084ceeb8 (diff) |
Cycles: switch Cycles triangle barycentric convention to match Embree/OptiX
Simplifies intersection code a little and slightly improves precision regarding
self intersection.
The parametric texture coordinate in shader nodes is still the same as before
for compatibility.
Diffstat (limited to 'intern/cycles/kernel/geom/triangle_intersect.h')
-rw-r--r-- | intern/cycles/kernel/geom/triangle_intersect.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/intern/cycles/kernel/geom/triangle_intersect.h b/intern/cycles/kernel/geom/triangle_intersect.h index f968e537cfa..847ed22fddd 100644 --- a/intern/cycles/kernel/geom/triangle_intersect.h +++ b/intern/cycles/kernel/geom/triangle_intersect.h @@ -145,9 +145,9 @@ ccl_device_inline float3 triangle_point_from_uv(KernelGlobals kg, const packed_float3 tri_a = kernel_data_fetch(tri_verts, tri_vindex + 0), tri_b = kernel_data_fetch(tri_verts, tri_vindex + 1), tri_c = kernel_data_fetch(tri_verts, tri_vindex + 2); - float w = 1.0f - u - v; - float3 P = u * tri_a + v * tri_b + w * tri_c; + /* This appears to give slightly better precision than interpolating with w = (1 - u - v). */ + float3 P = tri_a + u * (tri_b - tri_a) + v * (tri_c - tri_a); if (!(sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED)) { const Transform tfm = object_get_transform(kg, sd); |