From 2b45cd693f5b522d0e62cf12762fa53e583d8bdf Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 9 Jan 2012 17:47:25 +0900 Subject: [PATCH] Fix the black overbright dlights. t was unsigned and underflowing. This fixes the problem but keeps the bitshift unsigned clean. --- libs/video/renderer/glsl/glsl_lightmap.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libs/video/renderer/glsl/glsl_lightmap.c b/libs/video/renderer/glsl/glsl_lightmap.c index 9d854f059..845e2be31 100644 --- a/libs/video/renderer/glsl/glsl_lightmap.c +++ b/libs/video/renderer/glsl/glsl_lightmap.c @@ -124,8 +124,8 @@ static void R_BuildLightMap_1 (msurface_t *surf) { int smax, tmax, size; - unsigned scale, t; - int i; + unsigned scale; + int i, t; byte *out; smax = (surf->extents[0] >> 4) + 1; @@ -163,10 +163,10 @@ R_BuildLightMap_1 (msurface_t *surf) // bound, invert, and shift out = (byte *) blocklights; for (i = 0; i < size; i++) { - t = (255 * 256 - (int) blocklights[i]) >> (8 - VID_CBITS); - - t = max (t, 1 << 6); - *out++ = t >> 8; + t = (255 * 256 - (int) blocklights[i]); + t = max (t, 1 << (14 - VID_CBITS)); + t = ((unsigned) t) >> (16 - VID_CBITS); + *out++ = t; } GL_SubpicUpdate (surf->lightpic, (byte *) blocklights);