- re-enable light attenuation.

This commit is contained in:
Christoph Oelckers 2021-09-22 11:39:12 +02:00
parent 55186d3f6c
commit 7ce5bb4861
1 changed files with 3 additions and 21 deletions

View File

@ -14,7 +14,7 @@ vec3 lightContribution(int i, vec3 normal)
vec3 lightdir = normalize(lightpos.xyz - pixelpos.xyz); vec3 lightdir = normalize(lightpos.xyz - pixelpos.xyz);
float dotprod = dot(normal, lightdir); float dotprod = dot(normal, lightdir);
//if (dotprod < -0.0001) return vec3(0.0); // light hits from the backside. This can happen with full sector light lists and must be rejected for all cases. Note that this can cause precision issues. if (dotprod < -0.0001) return vec3(0.0); // light hits from the backside. This can happen with full sector light lists and must be rejected for all cases. Note that this can cause precision issues.
float attenuation = clamp((lightpos.w - lightdistance) / lightpos.w, 0.0, 1.0); float attenuation = clamp((lightpos.w - lightdistance) / lightpos.w, 0.0, 1.0);
@ -26,30 +26,12 @@ vec3 lightContribution(int i, vec3 normal)
#endif #endif
return lightcolor.rgb * attenuation;
/*
if (lightspot1.w == 1.0)
attenuation *= spotLightAttenuation(lightpos, lightspot1.xyz, lightspot2.x, lightspot2.y);
if (lightcolor.a < 0.0) // Sign bit is the attenuated light flag if (lightcolor.a < 0.0) // Sign bit is the attenuated light flag
{ {
attenuation *= clamp(dotprod, 0.0, 1.0); attenuation *= clamp(dotprod, 0.0, 1.0);
} }
if (attenuation > 0.0) // Skip shadow map test if possible
{
attenuation *= shadowAttenuation(lightpos, lightcolor.a);
return lightcolor.rgb * attenuation; return lightcolor.rgb * attenuation;
} }
else
{
return vec3(0.0);
}
*/
}
vec3 ProcessMaterialLight(Material material, vec3 color) vec3 ProcessMaterialLight(Material material, vec3 color)
@ -60,7 +42,7 @@ vec3 ProcessMaterialLight(Material material, vec3 color)
#if (DEF_DYNAMIC_LIGHTS_MOD == 1) #if (DEF_DYNAMIC_LIGHTS_MOD == 1)
// modulated lights // modulated lights
// Some very old GLES2 hardward does not allow non-constants in a for-loop expression because it can not unroll it. // Some very old GLES2 hardware does not allow non-constants in a for-loop expression because it can not unroll it.
// However they do allow 'break', so use stupid hack // However they do allow 'break', so use stupid hack
#if (USE_GLSL_V100 == 1) #if (USE_GLSL_V100 == 1)