diff --git a/src/gl/dynlights/gl_shadowmap.cpp b/src/gl/dynlights/gl_shadowmap.cpp index b70304db0a..005f38ad8c 100644 --- a/src/gl/dynlights/gl_shadowmap.cpp +++ b/src/gl/dynlights/gl_shadowmap.cpp @@ -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()); diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 0d4cf0607e..e986f65f0a 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -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; } //=========================================================================== diff --git a/wadsrc/static/shaders/glsl/shadowmap.fp b/wadsrc/static/shaders/glsl/shadowmap.fp index 1c9b3a754b..957e08b77f 100644 --- a/wadsrc/static/shaders/glsl/shadowmap.fp +++ b/wadsrc/static/shaders/glsl/shadowmap.fp @@ -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;