From 41537a50ab9f9aeb5f07e121ed8d1396dd7d261a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 2 Jun 2016 16:52:41 +0200 Subject: [PATCH] Fix true color light calculation bug for decals --- src/r_draw.cpp | 8 ++++---- src/r_drawt_rgba.cpp | 4 ++-- src/r_things.cpp | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 5a314e640..c190c1e73 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -416,7 +416,7 @@ void R_FillAddColumn_RGBA_C() dest = (uint32_t*)dc_dest; int pitch = dc_pitch; - uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(0)); + uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 24) & 0xff; uint32_t fg_green = (fg >> 16) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -481,7 +481,7 @@ void R_FillAddClampColumn_RGBA() dest = (uint32_t*)dc_dest; int pitch = dc_pitch; - uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(0)); + uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 24) & 0xff; uint32_t fg_green = (fg >> 16) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -545,7 +545,7 @@ void R_FillSubClampColumn_RGBA() dest = (uint32_t*)dc_dest; int pitch = dc_pitch; - uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(0)); + uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 24) & 0xff; uint32_t fg_green = (fg >> 16) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -609,7 +609,7 @@ void R_FillRevSubClampColumn_RGBA() dest = (uint32_t*)dc_dest; int pitch = dc_pitch; - uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(0)); + uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 24) & 0xff; uint32_t fg_green = (fg >> 16) & 0xff; uint32_t fg_blue = fg & 0xff; diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 1725b80e4..60520783d 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -413,7 +413,7 @@ void rt_shaded1col_RGBA_c (int hx, int sx, int yl, int yh) source = &dc_temp_rgba[yl*4 + hx]; pitch = dc_pitch; - uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(0)); + uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -455,7 +455,7 @@ void rt_shaded4cols_RGBA_c (int sx, int yl, int yh) source = &dc_temp_rgba[yl*4]; pitch = dc_pitch; - uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(0)); + uint32_t fg = shade_pal_index(dc_color, calc_light_multiplier(dc_light)); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; diff --git a/src/r_things.cpp b/src/r_things.cpp index 98557817d..3fcefe038 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -416,7 +416,7 @@ void R_DrawVisSprite (vissprite_t *vis) { // For shaded sprites, R_SetPatchStyle sets a dc_colormap to an alpha table, but // it is the brightest one. We need to get back to the proper light level for // this sprite. - dc_colormap += vis->ColormapNum << COLORMAPSHIFT; + R_SetColorMapLight(dc_colormap, 0, vis->ColormapNum << FRACBITS); } if (mode != DontDraw) @@ -2704,9 +2704,9 @@ void R_DrawParticle_RGBA(vissprite_t *vis) uint32_t bg_green = (*dest >> 8) & 0xff; uint32_t bg_blue = (*dest) & 0xff; - uint32_t red = (fg_red + bg_red * alpha) / 256; - uint32_t green = (fg_green + bg_green * alpha) / 256; - uint32_t blue = (fg_blue + bg_blue * alpha) / 256; + uint32_t red = (fg_red + bg_red * inv_alpha) / 256; + uint32_t green = (fg_green + bg_green * inv_alpha) / 256; + uint32_t blue = (fg_blue + bg_blue * inv_alpha) / 256; *dest = 0xff000000 | (red << 16) | (green << 8) | blue; dest += spacing;