                 texture2DProj(sShadowMap, vec4(shadowPos.xy + offsets.xy, shadowPos.zw)).r * shadowPos.w > shadowPos.z
             );
             return cShadowIntensity.y + dot(inLight, vec4(cShadowIntensity.x));
-        #else
-            // Take one sample
-            return cShadowIntensity.y + (texture2DProj(sShadowMap, shadowPos).r * shadowPos.w > shadowPos.z ? cShadowIntensity.x : 0.0);
+        #elif defined(VSM_SHADOW)
+            vec2 samples = texture2D(sShadowMap, shadowPos.xy).rg;
+            return cShadowIntensity.y + cShadowIntensity.x * Chebyshev(samples, shadowPos.z/shadowPos.w);
         #endif
     #endif
 }


    return max(p, p_max);
}


float GetShadow(vec4 shadowPos)
{

float ReduceLightBleeding(float p_max, float Amount)  
{  
    // Remove the [0, Amount] tail and linearly rescale (Amount, 1].  
    return linstep(Amount, 1.0, p_max); 
}  

float Chebyshev(vec2 Moments, float depth)  
{  
