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:
@@ -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)
|
||||
|
||||
@@ -4,5 +4,4 @@ in vec2 f_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragDepth = gl_FragCoord.z;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user