From ecf60edc33ca6881bafcdb61992572872b6a97ca Mon Sep 17 00:00:00 2001 From: RaveYard <29225776+MrRaveYard@users.noreply.github.com> Date: Fri, 4 Apr 2025 23:41:41 +0200 Subject: [PATCH] Fix vertex lighting --- wadsrc/static/shaders/scene/vert_main.glsl | 32 +++++++++++++--------- 1 file changed, 19 insertions(+), 13 deletions(-) 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);