From 156b1e334ca8bffafca5558593cc801e8bb9d810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Dubouchet?= Date: Tue, 19 Aug 2025 08:18:15 +0200 Subject: [PATCH] Clamp barycentric tests in Moller-Trumbore --- asset/shader/opengl/apple_shadow.frag | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/asset/shader/opengl/apple_shadow.frag b/asset/shader/opengl/apple_shadow.frag index b6289fb6..1d6ba1a3 100644 --- a/asset/shader/opengl/apple_shadow.frag +++ b/asset/shader/opengl/apple_shadow.frag @@ -39,11 +39,11 @@ bool rayTriangleIntersect( float f = 1.0/a; vec3 s = ray_origin - triangle.v0; float u = f * dot(s, h); - if (u < 0.0 || u > 1.0) + if (u < -EPSILON || u > 1.0 + EPSILON) return false; vec3 q = cross(s, edge1); float v = f * dot(ray_direction, q); - if (v < 0.0 || u + v > 1.0) + if (v < -EPSILON || u + v > 1.0 + EPSILON) return false; // At this stage we can compute t to find out where the intersection point is on the line. float t = f * dot(edge2, q);