From 79440d70141eb504990acf5e8023108e070ed66e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 4 Jan 2018 19:42:52 +0100 Subject: [PATCH] - Fix sprite spot light calculation --- src/gl/scene/gl_spritelight.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp index bde9f1450..ac7e6971e 100644 --- a/src/gl/scene/gl_spritelight.cpp +++ b/src/gl/scene/gl_spritelight.cpp @@ -107,11 +107,12 @@ void gl_SetDynSpriteLight(AActor *self, float x, float y, float z, subsector_t * if (light->IsSpot()) { + L *= -1.0f / dist; DAngle negPitch = -light->Angles.Pitch; - double xzLen = negPitch.Cos(); - double spotDirX = -light->Angles.Yaw.Cos() * xzLen; - double spotDirY = -negPitch.Sin(); - double spotDirZ = -light->Angles.Yaw.Sin() * xzLen; + double xyLen = negPitch.Cos(); + double spotDirX = -light->Angles.Yaw.Cos() * xyLen; + double spotDirY = -light->Angles.Yaw.Sin() * xyLen; + double spotDirZ = -negPitch.Sin(); double cosDir = L.X * spotDirX + L.Y * spotDirY + L.Z * spotDirZ; frac *= (float)smoothstep(light->SpotOuterAngle.Cos(), light->SpotInnerAngle.Cos(), cosDir); }