summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorWilliam Deurwaarder <william.git@xs4all.nl>2021-10-12 23:43:34 +0200
committerWilliam Deurwaarder <william.git@xs4all.nl>2021-10-12 23:43:34 +0200
commitf3f64389ca4b1f55ddc161cedbae02ed746c1632 (patch)
treee90caebe01cd6eae11359cbbc89f4806e499975f /modules
parent6f1d2133bb2b77048bf13a8180f57bff1a747226 (diff)
GPULightmapper: prevent loop with max iterations
In case the calculation of the delta contained infinity values (division by zero), than later the calculation of the next cell failed as the infinity value was multiplied by zero which resulted in a nan. The nan-value caused that the next cell was equal to the current cell which resulted in an end-less loop, which only terminates by the maximum iterations protection. This is solved by replacing infinity with grid_size which acts as infinity.
Diffstat (limited to 'modules')
-rw-r--r--modules/lightmapper_rd/lm_compute.glsl2
1 files changed, 1 insertions, 1 deletions
diff --git a/modules/lightmapper_rd/lm_compute.glsl b/modules/lightmapper_rd/lm_compute.glsl
index 25b334c5eb..3306b8a8c7 100644
--- a/modules/lightmapper_rd/lm_compute.glsl
+++ b/modules/lightmapper_rd/lm_compute.glsl
@@ -148,7 +148,7 @@ uint trace_ray(vec3 p_from, vec3 p_to
ivec3 icell = ivec3(from_cell);
ivec3 iendcell = ivec3(to_cell);
vec3 dir_cell = normalize(rel_cell);
- vec3 delta = abs(1.0 / dir_cell); //vec3(length(rel_cell)) / rel_cell);
+ vec3 delta = min(abs(1.0 / dir_cell), params.grid_size); // use params.grid_size as max to prevent infinity values
ivec3 step = ivec3(sign(rel_cell));
vec3 side = (sign(rel_cell) * (vec3(icell) - from_cell) + (sign(rel_cell) * 0.5) + 0.5) * delta;