]> git.tdb.fi Git - libs/gl.git/blobdiff - shaderlib/shadow.glsl
Don't apply shadows outside the shadowmap's range
[libs/gl.git] / shaderlib / shadow.glsl
index 6f4acd2786a6319c242d9ff8300a00ecc535d0a7..f0338b95f8a10c1f0a9ced28210d59fb345e5d4d 100644 (file)
@@ -1,5 +1,13 @@
 import msp_interface;
 
+uniform ShadowMap
+{
+       float shadow_darkness;
+       mat4 shd_eye_matrix;
+};
+
+uniform sampler2DShadow shadow_map;
+
 layout(constant_id=auto) const bool use_shadow_map = false;
 
 #pragma MSP stage(vertex)
@@ -13,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);
        }