From cf59809852e522fe89f241ae07e75b86ee5794ea Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 1 Apr 2021 00:05:05 +0100 Subject: [PATCH] Fixed some of the worst of it, but still has inconsistencies with the lookup tables we generated for main.kart - will provide evidence on Discord. (side note, it's weird as hell that code we inherited from vanilla next - and i checked, it wasn't mangled in the merge - has bugs that straight up prevent it from functioning properly...) --- src/p_mobj.c | 2 +- src/r_data.c | 2 +- src/r_draw.c | 10 +++------- src/r_things.c | 6 +----- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 7f88136f9..c43876707 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9162,7 +9162,7 @@ void P_SceneryThinker(mobj_t *mobj) static void P_DefaultMobjShadowScale(mobj_t *thing) { thing->shadowscale = 0; - thing->whiteshadow = (thing->frame & FF_FULLBRIGHT); + thing->whiteshadow = ((thing->frame & FF_BRIGHTMASK) == FF_FULLBRIGHT); switch (thing->type) { diff --git a/src/r_data.c b/src/r_data.c index de9d28136..854ed8310 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -98,7 +98,7 @@ UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alph #define clamp(c) max(min(c, 0xFF), 0x00); else { - float falpha = ((float)alpha / 256.0f); + float falpha = ((float)alpha / 255.0f); float fr = ((float)foreground.s.red * falpha); float fg = ((float)foreground.s.green * falpha); float fb = ((float)foreground.s.blue * falpha); diff --git a/src/r_draw.c b/src/r_draw.c index ab37fb57b..403631be8 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -152,7 +152,7 @@ UINT8 skincolor_modified[MAXSKINCOLORS]; CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1]; CV_PossibleValue_t Followercolor_cons_t[MAXSKINCOLORS+3]; // +3 to account for "Match", "Opposite" & NULL -#define TRANSTAB_AMTMUL10 (256.0f / 10.0f) +#define TRANSTAB_AMTMUL10 (255.0f / 10.0f) /** \brief Initializes the translucency tables used by the Software renderer. */ @@ -191,7 +191,7 @@ void R_GenerateBlendTables(void) for (i = 0; i <= 9; i++) { const size_t offs = (0x10000 * i); - const UINT8 alpha = TRANSTAB_AMTMUL10 * i; + const UINT8 alpha = TRANSTAB_AMTMUL10 * (10-i); R_GenerateTranslucencyTable(blendtables[blendtab_add] + offs, AST_ADD, alpha); R_GenerateTranslucencyTable(blendtables[blendtab_subtract] + offs, AST_SUBTRACT, alpha); @@ -203,8 +203,6 @@ void R_GenerateBlendTables(void) R_GenerateTranslucencyTable(blendtables[blendtab_modulate], AST_MODULATE, 0); } -static colorlookup_t transtab_lut; - void R_GenerateTranslucencyTable(UINT8 *table, int style, UINT8 blendamt) { INT16 bg, fg; @@ -212,8 +210,6 @@ void R_GenerateTranslucencyTable(UINT8 *table, int style, UINT8 blendamt) if (table == NULL) I_Error("R_GenerateTranslucencyTable: input table was NULL!"); - InitColorLUT(&transtab_lut, pMasterPalette, false); - for (bg = 0; bg < 0xFF; bg++) { for (fg = 0; fg < 0xFF; fg++) @@ -223,7 +219,7 @@ void R_GenerateTranslucencyTable(UINT8 *table, int style, UINT8 blendamt) RGBA_t result; result.rgba = ASTBlendPixel(backrgba, frontrgba, style, blendamt); - table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue); + table[((fg * 0x100) + bg)] = NearestPaletteColor(result.s.red, result.s.green, result.s.blue, pMasterPalette); } } } diff --git a/src/r_things.c b/src/r_things.c index 56d8eb067..acc817c2c 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1251,7 +1251,6 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, patch_t *patch; fixed_t xscale, yscale, shadowxscale, shadowyscale, shadowskew, x1, x2; INT32 light = 0; - boolean additive = false; fixed_t groundz; pslope_t *groundslope; @@ -1259,9 +1258,6 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, if (abs(groundz-viewz)/tz > 4) return; // Prevent stretchy shadows and possible crashes - if (thing->whiteshadow == true) - additive = true; - patch = W_CachePatchName("DSHADOW", PU_SPRITE); xscale = FixedDiv(projection[viewssnum], tz); yscale = FixedDiv(projectiony[viewssnum], tz); @@ -1349,7 +1345,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, shadow->extra_colormap = thing->subsector->sector->extra_colormap; } - shadow->transmap = R_GetBlendTable(additive ? AST_ADD : AST_SUBTRACT, 0); + shadow->transmap = R_GetBlendTable(thing->whiteshadow ? AST_ADD : AST_SUBTRACT, 0); shadow->colormap = colormaps; objectsdrawn++;