From 43fc2899aa8acd1ef6372a5f44ad37691983a62e Mon Sep 17 00:00:00 2001 From: milek7 Date: Tue, 8 Oct 2019 00:20:45 +0200 Subject: [PATCH] add slight shadow bias (needs futhrer work) --- shaders/light_common.glsl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/shaders/light_common.glsl b/shaders/light_common.glsl index 8fc8216f..d6614867 100644 --- a/shaders/light_common.glsl +++ b/shaders/light_common.glsl @@ -7,18 +7,20 @@ float calc_shadow() if (coords.z < 0.0f) return 1.0f; + + float bias = 0.0004f; //sampler PCF - //float shadow = texture(shadowmap, coords.xyz); + //float shadow = texture(shadowmap, coords.xyz + vec3(0.0, 0.0, bias)); //sampler PCF + PCF float shadow = 0.0; vec2 texel = vec2(1.0) / vec2(textureSize(shadowmap, 0)); for (float y = -1.5; y <= 1.5; y += 1.0) for (float x = -1.5; x <= 1.5; x += 1.0) - shadow += texture(shadowmap, coords.xyz + vec3(vec2(x, y) * texel, 0.0)); + shadow += texture(shadowmap, coords.xyz + vec3(vec2(x, y) * texel, bias)); shadow /= 16.0; - + return 1.0 - shadow; #else return 1.0;