]> git.tdb.fi Git - libs/gl.git/commitdiff
Don't apply shadows outside the shadowmap's range
authorMikko Rasa <tdb@tdb.fi>
Sat, 24 Apr 2021 12:12:50 +0000 (15:12 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 24 Apr 2021 12:12:50 +0000 (15:12 +0300)
shaderlib/shadow.glsl

index f168fe7955431869b25f90b8909192453929bcd0..f0338b95f8a10c1f0a9ced28210d59fb345e5d4d 100644 (file)
@@ -21,6 +21,8 @@ virtual float get_shadow_factor(int index)
 {
        if(use_shadow_map)
        {
+               if(shadow_coord.x<0 || shadow_coord.x>1 || shadow_coord.y<0 || shadow_coord.y>1)
+                       return 1.0;
                float shadow_sample = texture(shadow_map, shadow_coord);
                return mix(1.0, shadow_sample, shadow_darkness);
        }