summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-01-24 09:15:26 +0100
committerRémi Verschelde <rverschelde@gmail.com>2023-01-24 09:15:26 +0100
commita6042b649a3626488550a822b7d9469aa2bd3f92 (patch)
treeaa085871bd57af6b432cc957183e2cb66f1e1d8a /drivers
parent514b3486196ac4779d7a9dbe84e7223d8d365a6a (diff)
parent4bd01a93dc82b4ac5734ac2a4af70d49b4559496 (diff)
Merge pull request #71832 from Geometror/fix-spotlight-artifacts
Fix some `SpotLight3D` issues (clustering artifacts, leaking light, AABB)
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gles3/shaders/scene.glsl3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl
index 951155e287..52ff70f746 100644
--- a/drivers/gles3/shaders/scene.glsl
+++ b/drivers/gles3/shaders/scene.glsl
@@ -690,7 +690,8 @@ void light_compute(vec3 N, vec3 L, vec3 V, float A, vec3 light_color, float atte
#endif
#if defined(LIGHT_RIM_USED)
- float rim_light = pow(max(0.0, 1.0 - cNdotV), max(0.0, (1.0 - roughness) * 16.0));
+ // Epsilon min to prevent pow(0, 0) singularity which results in undefined behavior.
+ float rim_light = pow(max(1e-4, 1.0 - cNdotV), max(0.0, (1.0 - roughness) * 16.0));
diffuse_light += rim_light * rim * mix(vec3(1.0), albedo, rim_tint) * light_color;
#endif
}