From fc50bdee989de3f5358a8827761ed5b60245d395 Mon Sep 17 00:00:00 2001 From: Ian Curtis Date: Fri, 14 Apr 2017 00:08:17 +0000 Subject: [PATCH] light parameters must be clamped (HarryTuttle) --- Src/Graphics/New3D/New3D.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Src/Graphics/New3D/New3D.cpp b/Src/Graphics/New3D/New3D.cpp index 5b1ea52..9013fa8 100644 --- a/Src/Graphics/New3D/New3D.cpp +++ b/Src/Graphics/New3D/New3D.cpp @@ -756,6 +756,9 @@ void CNew3D::RenderViewport(UINT32 addr) vp->lightingParams[4] = (float)((vpnode[0x24] >> 8) & 0xFF) * (1.0f / 255.0f); // ambient intensity vp->lightingParams[5] = 0.0; // reserved + vp->lightingParams[3] = std::max(0.f, std::min(vp->lightingParams[3], 1.0f)); // clamp sun values + vp->lightingParams[4] = std::max(0.f, std::min(vp->lightingParams[4], 1.0f)); // std::clamp would be easier but c++17 .. sigh. + // Spotlight int spotColorIdx = (vpnode[0x20] >> 11) & 7; // spotlight color index int spotFogColorIdx = (vpnode[0x20] >> 8) & 7; // spotlight on fog color index