From c9e5f90813a479519f1e51b8aa4b4106371a1a4e Mon Sep 17 00:00:00 2001 From: viksl Date: Fri, 29 Sep 2023 21:19:01 +0200 Subject: [PATCH] Fixes spotlight's cluster artifacts and negative light. (cherry picked from commit 8a2d345a859d6643a14872474daacca85d586ff7) --- .../shaders/environment/volumetric_fog_process.glsl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/servers/rendering/renderer_rd/shaders/environment/volumetric_fog_process.glsl b/servers/rendering/renderer_rd/shaders/environment/volumetric_fog_process.glsl index f961249dce0..57b9a4c320e 100644 --- a/servers/rendering/renderer_rd/shaders/environment/volumetric_fog_process.glsl +++ b/servers/rendering/renderer_rd/shaders/environment/volumetric_fog_process.glsl @@ -576,8 +576,9 @@ void main() { float attenuation = get_omni_attenuation(d, spot_lights.data[light_index].inv_radius, spot_lights.data[light_index].attenuation); vec3 spot_dir = spot_lights.data[light_index].direction; - float scos = max(dot(-normalize(light_rel_vec), spot_dir), spot_lights.data[light_index].cone_angle); - float spot_rim = max(0.0001, (1.0 - scos) / (1.0 - spot_lights.data[light_index].cone_angle)); + highp float cone_angle = spot_lights.data[light_index].cone_angle; + float scos = max(dot(-normalize(light_rel_vec), spot_dir), cone_angle); + float spot_rim = max(0.0001, (1.0 - scos) / (1.0 - cone_angle)); attenuation *= 1.0 - pow(spot_rim, spot_lights.data[light_index].cone_attenuation); vec3 light = spot_lights.data[light_index].color;