From 82a0decf06fe80df3a6f23fda2ad516c459b631f Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Wed, 19 Jul 2023 05:05:05 +0200 Subject: [PATCH] Clamp light level for shaders See https://git.do.srb2.org/STJr/SRB2/-/merge_requests/1085 cause why not --- 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 c765150fc..bdb6ebcb2 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -436,6 +436,9 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col poly_color.s.green = (UINT8)green; 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;