From: Mikko Rasa Date: Tue, 14 Dec 2021 14:23:34 +0000 (+0200) Subject: Clamp depth reference for shadows to 1.0 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=5e611353c5fcaf9219bd3037a32bce0f91313264;p=libs%2Fgl.git 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. --- 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