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