- check light direction in the shader.

There are situations where lights on the wrong side of a linedef may be passed and those need to be skipped in the shader code.
This commit is contained in:
Christoph Oelckers 2018-05-19 19:20:45 +02:00
parent 5cffa8873a
commit 3dc6ddbcc3
1 changed files with 4 additions and 1 deletions

View File

@ -9,6 +9,9 @@ vec3 lightContribution(int i, vec3 normal)
float lightdistance = distance(lightpos.xyz, pixelpos.xyz);
if (lightpos.w < lightdistance)
return vec3(0.0); // Early out lights touching surface but not this fragment
float dotprod = dot(normal, lightdir);
if (dotprod < 0.0) return vec3(0.0); // light hits from the backside. This can happen with full sector light lists and must be rejected for all cases.
float attenuation = clamp((lightpos.w - lightdistance) / lightpos.w, 0.0, 1.0);
@ -18,7 +21,7 @@ vec3 lightContribution(int i, vec3 normal)
if (lightcolor.a < 0.0) // Sign bit is the attenuated light flag
{
vec3 lightdir = normalize(lightpos.xyz - pixelpos.xyz);
attenuation *= clamp(dot(normal, lightdir), 0.0, 1.0);
attenuation *= clamp(dotprod, 0.0, 1.0);
}
if (attenuation > 0.0) // Skip shadow map test if possible