From ad2993950a525fd5ef742c77d1deb563b72e9511 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 25 Dec 2016 12:58:29 +0100 Subject: [PATCH] - fixed light level calculation for low light levels. --- src/gl/renderer/gl_lightdata.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 25ad12344..ca2d32c41 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -196,14 +196,30 @@ int gl_CalcLightLevel(int lightlevel, int rellight, bool weapon) if ((glset.lightmode & 2) && lightlevel < 192 && !weapon) { - light = xs_CRoundToInt(192.f - (192-lightlevel)* 1.95f); + if (lightlevel > 100) + { + light = xs_CRoundToInt(192.f - (192 - lightlevel)* 1.87f); + if (light + rellight < 20) + { + light = 20 + (light + rellight - 20) / 5; + } + else + { + light += rellight; + } + } + else + { + light = (lightlevel + rellight) / 5; + } + } else { - light=lightlevel; + light=lightlevel+rellight; } - return clamp(light+rellight, 0, 255); + return clamp(light, 0, 255); } //==========================================================================