diff --git a/wadsrc/static/shaders/scene/vert_main.glsl b/wadsrc/static/shaders/scene/vert_main.glsl index 12748d7e8..de0de71c6 100644 --- a/wadsrc/static/shaders/scene/vert_main.glsl +++ b/wadsrc/static/shaders/scene/vert_main.glsl @@ -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);