Fix vertex lighting

This commit is contained in:
RaveYard 2025-04-04 23:41:41 +02:00 committed by Magnus Norddahl
commit ecf60edc33

View file

@ -11,21 +11,27 @@
vec3 lightValue(DynLightInfo light)
{
#ifdef USE_SPRITE_CENTER
float lightdistance = distance(light.pos.xyz, uActorCenter.xyz);
float lightdistance;
vec3 lightdir;
if (USE_SPRITE_CENTER)
{
lightdistance = distance(light.pos.xyz, uActorCenter.xyz);
if (light.radius < lightdistance)
return vec3(0.0); // Early out lights touching surface but not this fragment
lightdir = normalize(light.pos.xyz - uActorCenter.xyz);
}
else
{
lightdistance = distance(light.pos.xyz, pixelpos.xyz);
if (light.radius < lightdistance)
return vec3(0.0); // Early out lights touching surface but not this fragment
if (light.radius < lightdistance)
return vec3(0.0); // Early out lights touching surface but not this fragment
vec3 lightdir = normalize(light.pos.xyz - uActorCenter.xyz);
#else
float lightdistance = distance(light.pos.xyz, pixelpos.xyz);
if (light.radius < lightdistance)
return vec3(0.0); // Early out lights touching surface but not this fragment
vec3 lightdir = normalize(light.pos.xyz - pixelpos.xyz);
#endif
lightdir = normalize(light.pos.xyz - pixelpos.xyz);
}
float attenuation = distanceAttenuation(lightdistance, light.radius, light.strength, light.linearity);