From e4d6e92f37e9d9dcb6d21ea0ca5e57818dc1f2a8 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Thu, 23 Jul 2020 19:05:17 +0300 Subject: [PATCH] Clamp light level for shaders. Fixes #194. --- src/hardware/hw_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 0d7404c77..127756a00 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -214,6 +214,9 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col poly_color.s.blue = (UINT8)blue; } + // Clamp the light level, since it can sometimes go out of the 0-255 range from animations + light_level = min(max(light_level, 0), 255); + Surface->PolyColor.rgba = poly_color.rgba; Surface->TintColor.rgba = tint_color.rgba; Surface->FadeColor.rgba = fade_color.rgba;