16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 03:09:18 +02:00

changes, improved z buffer precision

This commit is contained in:
milek7
2018-07-24 16:42:18 +02:00
parent d5ce1d57e7
commit b69ffd85ea
7 changed files with 160 additions and 96 deletions

View File

@@ -2,23 +2,21 @@ float calc_shadow()
{
vec3 coords = f_light_pos.xyz / f_light_pos.w;
if (coords.z > 1.0f)
if (coords.z < 0.0f)
return 1.0f;
float bias = 0.0f;
//sampler PCF
//float shadow = texture(shadowmap, vec3(coords.xy, coords.z - bias));
//float shadow = texture(shadowmap, coords.xyz);
//sampler PCF + PCF
float shadow = 0.0;
vec2 texel = 1.0 / 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, -bias));
shadow += texture(shadowmap, coords.xyz + vec3(vec2(x, y) * texel, 0.0));
shadow /= 16.0;
return shadow;
return 1.0 - shadow;
}
vec3 apply_fog(vec3 color)

View File

@@ -4,5 +4,4 @@ in vec2 f_coord;
void main()
{
gl_FragDepth = gl_FragCoord.z;
}