From 5e611353c5fcaf9219bd3037a32bce0f91313264 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 14 Dec 2021 16:23:34 +0200 Subject: [PATCH] Clamp depth reference for shadows to 1.0 This makes objects which are "behind" the shadow map volume sample the shadow map correctly and not treat the clear value as a shadow caster. --- shaderlib/shadow.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shaderlib/shadow.glsl b/shaderlib/shadow.glsl index d6e2b385..2e8a05b0 100644 --- a/shaderlib/shadow.glsl +++ b/shaderlib/shadow.glsl @@ -52,7 +52,7 @@ virtual float get_shadow_factor(int index, vec4 world_pos) return 1.0; vec4 region = shadows[index].region; - float shadow_sample = texture(shadow_map, vec3(shadow_coord.xy*region.zw+region.xy, shadow_coord.z)); + float shadow_sample = texture(shadow_map, vec3(shadow_coord.xy*region.zw+region.xy, min(shadow_coord.z, 1.0))); return mix(1.0, shadow_sample, shadows[index].darkness); } else -- 2.43.0