Merge pull request #53844 from williamd67/GPULightmapper-increase-ray-triangle-hit-rate

This commit is contained in:
Rémi Verschelde 2021-10-15 16:31:55 +02:00 committed by GitHub
commit d15512c17f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -94,13 +94,14 @@ params;
//check it, but also return distance and barycentric coords (for uv lookup)
bool ray_hits_triangle(vec3 from, vec3 dir, float max_dist, vec3 p0, vec3 p1, vec3 p2, out float r_distance, out vec3 r_barycentric) {
const float EPSILON = 0.00001;
const vec3 e0 = p1 - p0;
const vec3 e1 = p0 - p2;
vec3 triangle_normal = cross(e1, e0);
float n_dot_dir = dot(triangle_normal, dir);
if (abs(n_dot_dir) < 0.01) {
if (abs(n_dot_dir) < EPSILON) {
return false;
}