mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-16 01:21:17 +00:00
- fix diagonal linear shadow map artifact
This commit is contained in:
parent
ee278db86f
commit
9ad56a9f66
2 changed files with 12 additions and 9 deletions
|
@ -141,17 +141,19 @@ float shadowDirToU(vec2 dir)
|
|||
{
|
||||
if (abs(dir.x) > abs(dir.y))
|
||||
{
|
||||
float v = dir.y / dir.x * 0.125;
|
||||
if (dir.x >= 0.0)
|
||||
return dir.y / dir.x * 0.125 + (0.25 + 0.125);
|
||||
return (0.25 + 0.125) - v;
|
||||
else
|
||||
return dir.y / dir.x * 0.125 + (0.75 + 0.125);
|
||||
return (0.75 + 0.125) - v;
|
||||
}
|
||||
else
|
||||
{
|
||||
float v = dir.x / dir.y * 0.125;
|
||||
if (dir.y >= 0.0)
|
||||
return dir.x / dir.y * 0.125 + 0.125;
|
||||
return 0.125 + v;
|
||||
else
|
||||
return dir.x / dir.y * 0.125 + (0.50 + 0.125);
|
||||
return (0.50 + 0.125) + v;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -145,12 +145,13 @@ void main()
|
|||
if (radius > 0.0)
|
||||
{
|
||||
vec2 pixelpos;
|
||||
switch (int(gl_FragCoord.x) / int(ShadowmapQuality/4.0))
|
||||
float u = gl_FragCoord.x / ShadowmapQuality * 4.0;
|
||||
switch (int(u))
|
||||
{
|
||||
case 0: pixelpos = vec2((gl_FragCoord.x - float(ShadowmapQuality/8.0)) / float(ShadowmapQuality/8.0), 1.0); break;
|
||||
case 1: pixelpos = vec2(1.0, (gl_FragCoord.x - float(ShadowmapQuality/4.0 + ShadowmapQuality/8.0)) / float(ShadowmapQuality/8.0)); break;
|
||||
case 2: pixelpos = vec2(-(gl_FragCoord.x - float(ShadowmapQuality/2.0 + ShadowmapQuality/8.0)) / float(ShadowmapQuality/8.0), -1.0); break;
|
||||
case 3: pixelpos = vec2(-1.0, -(gl_FragCoord.x - float(ShadowmapQuality*3.0/4.0 + ShadowmapQuality/8.0)) / float(ShadowmapQuality/8.0)); break;
|
||||
case 0: pixelpos = vec2(u * 2.0 - 1.0, 1.0); break;
|
||||
case 1: pixelpos = vec2(1.0, 1.0 - (u - 1.0) * 2.0); break;
|
||||
case 2: pixelpos = vec2(1.0 - (u - 2.0) * 2.0, -1.0); break;
|
||||
case 3: pixelpos = vec2(-1.0, (u - 3.0) * 2.0 - 1.0); break;
|
||||
}
|
||||
pixelpos = lightpos + pixelpos * radius;
|
||||
|
||||
|
|
Loading…
Reference in a new issue