mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 22:11:43 +00:00
1D shadow maps are now working
This commit is contained in:
parent
0d1deddae5
commit
8515f9720a
3 changed files with 6 additions and 4 deletions
|
@ -83,7 +83,7 @@ void FShadowMap::UploadLights()
|
|||
ADynamicLight *light = it.Next();
|
||||
if (!light) break;
|
||||
|
||||
mLightToShadowmap[light] = mLights.Size();
|
||||
mLightToShadowmap[light] = mLights.Size() / 4;
|
||||
|
||||
mLights.Push(light->X());
|
||||
mLights.Push(light->Y());
|
||||
|
|
|
@ -158,7 +158,9 @@ float shadowmapAttenuation(vec4 lightpos, float shadowIndex)
|
|||
else
|
||||
u = dir.x / dir.y * 0.125 + (0.50 + 0.125);
|
||||
}
|
||||
return texture(ShadowMap, vec2(u, v)).x < dot(dir, dir) ? 1.0 : 0.0;
|
||||
dir -= sign(dir); // margin, to remove wall acne
|
||||
float dist2 = dot(dir, dir);
|
||||
return texture(ShadowMap, vec2(u, v)).x > dist2 ? 1.0 : 0.0;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
|
@ -129,8 +129,8 @@ void main()
|
|||
{
|
||||
case 0: pixelpos = vec2((gl_FragCoord.x - 128.0) / 128.0, 1.0); break;
|
||||
case 1: pixelpos = vec2(1.0, (gl_FragCoord.x - 384.0) / 128.0); break;
|
||||
case 2: pixelpos = vec2((gl_FragCoord.x - 640.0) / 128.0, -1.0); break;
|
||||
case 3: pixelpos = vec2(-1.0, (gl_FragCoord.x - 896.0) / 128.0); break;
|
||||
case 2: pixelpos = vec2(-(gl_FragCoord.x - 640.0) / 128.0, -1.0); break;
|
||||
case 3: pixelpos = vec2(-1.0, -(gl_FragCoord.x - 896.0) / 128.0); break;
|
||||
}
|
||||
pixelpos = lightpos + pixelpos * radius;
|
||||
|
||||
|
|
Loading…
Reference in a new issue