summaryrefslogtreecommitdiff
path: root/modules/lightmapper_rd
diff options
context:
space:
mode:
authorWilliam Deurwaarder <william.git@xs4all.nl>2021-10-15 15:19:43 +0200
committerWilliam Deurwaarder <william.git@xs4all.nl>2021-10-15 15:19:43 +0200
commita3f315c81bc782ef75ee2cecfc47d136db6d4a54 (patch)
tree185c0f54f0ab35221c7402e893083fd24707dd50 /modules/lightmapper_rd
parent5bc0e4081bbfa077567e1d94b760f81c63eb3392 (diff)
GPULightmapper: increase ray triangle hit rate
Currently the method ray_hits_triangle determines triangles not to be hit by a ray due to an epsilon that is too big. In practice those triangles are hit by those rays. This is fixed by introducing a smaller epsilon.
Diffstat (limited to 'modules/lightmapper_rd')
-rw-r--r--modules/lightmapper_rd/lm_compute.glsl3
1 files changed, 2 insertions, 1 deletions
diff --git a/modules/lightmapper_rd/lm_compute.glsl b/modules/lightmapper_rd/lm_compute.glsl
index 6e5c9f25ba..158cd960c4 100644
--- a/modules/lightmapper_rd/lm_compute.glsl
+++ b/modules/lightmapper_rd/lm_compute.glsl
@@ -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;
}