Merge branch 'blendmode-revision' into 'next'

Blending changes

See merge request STJr/SRB2!1446
This commit is contained in:
sphere 2021-04-11 08:18:12 -04:00
commit bcd3245b76
7 changed files with 171 additions and 68 deletions

View file

@ -1,7 +1,7 @@
// SONIC ROBO BLAST 2 // SONIC ROBO BLAST 2
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2020 by Sonic Team Junior. // Copyright (C) 1999-2021 by Sonic Team Junior.
// //
// This program is free software distributed under the // This program is free software distributed under the
// terms of the GNU General Public License, version 2. // terms of the GNU General Public License, version 2.
@ -216,14 +216,13 @@ enum EPolyFlags
PF_Masked = 0x00000001, // Poly is alpha scaled and 0 alpha pixels are discarded (holes in texture) PF_Masked = 0x00000001, // Poly is alpha scaled and 0 alpha pixels are discarded (holes in texture)
PF_Translucent = 0x00000002, // Poly is transparent, alpha = level of transparency PF_Translucent = 0x00000002, // Poly is transparent, alpha = level of transparency
PF_Environment = 0x00000004, // Poly should be drawn environment mapped. (Hurdler: used for text drawing) PF_Environment = 0x00000004, // Poly should be drawn environment mapped. (Hurdler: used for text drawing)
PF_Additive = 0x00000008, // Additive color blending PF_Additive = 0x00000008, // Source blending factor is additive.
PF_AdditiveSource = 0x00000010, // Source blending factor is additive. This is the opposite of regular additive blending. PF_Subtractive = 0x00000010, // Subtractive color blending
PF_Subtractive = 0x00000020, // Subtractive color blending PF_ReverseSubtract = 0x00000020, // Reverse subtract, used in wall splats (decals)
PF_ReverseSubtract = 0x00000040, // Reverse subtract, used in wall splats (decals) PF_Multiplicative = 0x00000040, // Multiplicative color blending
PF_Multiplicative = 0x00000080, // Multiplicative color blending
PF_Fog = 0x20000000, // Fog blocks PF_Fog = 0x20000000, // Fog blocks
PF_NoAlphaTest = 0x40000000, // Disables alpha testing PF_NoAlphaTest = 0x40000000, // Disables alpha testing
PF_Blending = (PF_Masked|PF_Translucent|PF_Environment|PF_Additive|PF_AdditiveSource|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Fog) & ~PF_NoAlphaTest, PF_Blending = (PF_Masked|PF_Translucent|PF_Environment|PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Fog) & ~PF_NoAlphaTest,
// other flag bits // other flag bits
PF_Occlude = 0x00000100, // Updates the depth buffer PF_Occlude = 0x00000100, // Updates the depth buffer

View file

@ -1,7 +1,7 @@
// SONIC ROBO BLAST 2 // SONIC ROBO BLAST 2
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2020 by Sonic Team Junior. // Copyright (C) 1999-2021 by Sonic Team Junior.
// //
// This program is free software distributed under the // This program is free software distributed under the
// terms of the GNU General Public License, version 2. // terms of the GNU General Public License, version 2.
@ -35,7 +35,7 @@
#define DL_HIGH_QUALITY #define DL_HIGH_QUALITY
//#define STATICLIGHT //Hurdler: TODO! //#define STATICLIGHT //Hurdler: TODO!
#define LIGHTMAPFLAGS (PF_Modulated|PF_AdditiveSource) #define LIGHTMAPFLAGS (PF_Modulated|PF_Additive)
#ifdef ALAM_LIGHTING #ifdef ALAM_LIGHTING
static dynlights_t view_dynlights[2]; // 2 players in splitscreen mode static dynlights_t view_dynlights[2]; // 2 players in splitscreen mode
@ -1056,7 +1056,7 @@ void HWR_DoCoronasLighting(FOutVector *outVerts, gl_vissprite_t *spr)
HWR_GetPic(coronalumpnum); /// \todo use different coronas HWR_GetPic(coronalumpnum); /// \todo use different coronas
HWD.pfnDrawPolygon (&Surf, light, 4, PF_Modulated | PF_AdditiveSource | PF_Corona | PF_NoDepthTest); HWD.pfnDrawPolygon (&Surf, light, 4, PF_Modulated | PF_Additive | PF_Corona | PF_NoDepthTest);
} }
} }
#endif #endif
@ -1144,7 +1144,7 @@ void HWR_DrawCoronas(void)
light[3].y = cy+size*1.33f; light[3].y = cy+size*1.33f;
light[3].s = 0.0f; light[3].t = 1.0f; light[3].s = 0.0f; light[3].t = 1.0f;
HWD.pfnDrawPolygon (&Surf, light, 4, PF_Modulated | PF_AdditiveSource | PF_NoDepthTest | PF_Corona); HWD.pfnDrawPolygon (&Surf, light, 4, PF_Modulated | PF_Additive | PF_NoDepthTest | PF_Corona);
} }
} }
#endif #endif

View file

@ -1,7 +1,7 @@
// SONIC ROBO BLAST 2 // SONIC ROBO BLAST 2
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2020 by Sonic Team Junior. // Copyright (C) 1999-2021 by Sonic Team Junior.
// //
// This program is free software distributed under the // This program is free software distributed under the
// terms of the GNU General Public License, version 2. // terms of the GNU General Public License, version 2.
@ -706,6 +706,9 @@ FBITFIELD HWR_GetBlendModeFlag(INT32 ast)
{ {
switch (ast) switch (ast)
{ {
case AST_COPY:
case AST_OVERLAY:
return PF_Masked;
case AST_ADD: case AST_ADD:
return PF_Additive; return PF_Additive;
case AST_SUBTRACT: case AST_SUBTRACT:
@ -744,7 +747,7 @@ UINT8 HWR_GetTranstableAlpha(INT32 transtablenum)
FBITFIELD HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf) FBITFIELD HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf)
{ {
if (!transtablenum) if (!transtablenum || style == AST_COPY || style == AST_OVERLAY)
{ {
pSurf->PolyColor.s.alpha = 0xff; pSurf->PolyColor.s.alpha = 0xff;
return PF_Masked; return PF_Masked;
@ -3813,8 +3816,6 @@ static void HWR_SplitSprite(gl_vissprite_t *spr)
else if (spr->mobj->frame & FF_TRANSMASK) else if (spr->mobj->frame & FF_TRANSMASK)
{ {
INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT;
if (spr->mobj->blendmode == AST_TRANSLUCENT && trans >= NUMTRANSMAPS)
return;
blend = HWR_SurfaceBlend(spr->mobj->blendmode, trans, &Surf); blend = HWR_SurfaceBlend(spr->mobj->blendmode, trans, &Surf);
} }
else else
@ -4240,8 +4241,6 @@ static void HWR_DrawSprite(gl_vissprite_t *spr)
else if (spr->mobj->frame & FF_TRANSMASK) else if (spr->mobj->frame & FF_TRANSMASK)
{ {
INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT;
if (spr->mobj->blendmode == AST_TRANSLUCENT && trans >= NUMTRANSMAPS)
return;
blend = HWR_SurfaceBlend(spr->mobj->blendmode, trans, &Surf); blend = HWR_SurfaceBlend(spr->mobj->blendmode, trans, &Surf);
} }
else else
@ -4354,9 +4353,7 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr)
if (spr->mobj->frame & FF_TRANSMASK) if (spr->mobj->frame & FF_TRANSMASK)
{ {
INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT;
if (spr->mobj->blendmode == AST_TRANSLUCENT && trans >= NUMTRANSMAPS) blend = HWR_SurfaceBlend(AST_TRANSLUCENT, trans, &Surf);
return;
blend = HWR_SurfaceBlend(spr->mobj->blendmode, trans, &Surf);
} }
else else
{ {
@ -4935,6 +4932,13 @@ static void HWR_ProjectSprite(mobj_t *thing)
if (thing->spritexscale < 1 || thing->spriteyscale < 1) if (thing->spritexscale < 1 || thing->spriteyscale < 1)
return; return;
// Visibility check by the blend mode.
if (thing->frame & FF_TRANSMASK)
{
if (!R_BlendLevelVisible(thing->blendmode, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT))
return;
}
dispoffset = thing->info->dispoffset; dispoffset = thing->info->dispoffset;
this_scale = FIXED_TO_FLOAT(thing->scale); this_scale = FIXED_TO_FLOAT(thing->scale);
@ -5321,6 +5325,13 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
unsigned rot = 0; unsigned rot = 0;
UINT8 flip; UINT8 flip;
// Visibility check by the blend mode.
if (thing->frame & FF_TRANSMASK)
{
if (!R_BlendLevelVisible(thing->blendmode, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT))
return;
}
// transform the origin point // transform the origin point
tr_x = FIXED_TO_FLOAT(thing->x) - gl_viewx; tr_x = FIXED_TO_FLOAT(thing->x) - gl_viewx;
tr_y = FIXED_TO_FLOAT(thing->y) - gl_viewy; tr_y = FIXED_TO_FLOAT(thing->y) - gl_viewy;
@ -5354,7 +5365,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
return; return;
#endif #endif
sprframe = &sprdef->spriteframes[ thing->frame & FF_FRAMEMASK]; sprframe = &sprdef->spriteframes[thing->frame & FF_FRAMEMASK];
// use single rotation for all views // use single rotation for all views
lumpoff = sprframe->lumpid[0]; lumpoff = sprframe->lumpid[0];
@ -6510,7 +6521,7 @@ void HWR_DoPostProcessor(player_t *player)
Surf.PolyColor.s.alpha = 0xc0; // match software mode Surf.PolyColor.s.alpha = 0xc0; // match software mode
HWD.pfnDrawPolygon(&Surf, v, 4, PF_Modulated|PF_AdditiveSource|PF_NoTexture|PF_NoDepthTest); HWD.pfnDrawPolygon(&Surf, v, 4, PF_Modulated|PF_Additive|PF_NoTexture|PF_NoDepthTest);
} }
// Capture the screen for intermission and screen waving // Capture the screen for intermission and screen waving

View file

@ -1580,12 +1580,11 @@ static void SetBlendMode(FBITFIELD flags)
case PF_Additive & PF_Blending: case PF_Additive & PF_Blending:
case PF_Subtractive & PF_Blending: case PF_Subtractive & PF_Blending:
case PF_ReverseSubtract & PF_Blending: case PF_ReverseSubtract & PF_Blending:
pglBlendFunc(GL_SRC_ALPHA, GL_ONE); // src * alpha + dest
break;
case PF_Environment & PF_Blending: case PF_Environment & PF_Blending:
pglBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); pglBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
break; break;
case PF_AdditiveSource & PF_Blending:
pglBlendFunc(GL_SRC_ALPHA, GL_ONE); // src * alpha + dest
break;
case PF_Multiplicative & PF_Blending: case PF_Multiplicative & PF_Blending:
pglBlendFunc(GL_DST_COLOR, GL_ZERO); pglBlendFunc(GL_DST_COLOR, GL_ZERO);
break; break;
@ -1624,7 +1623,6 @@ static void SetBlendMode(FBITFIELD flags)
break; break;
case PF_Translucent & PF_Blending: case PF_Translucent & PF_Blending:
case PF_Additive & PF_Blending: case PF_Additive & PF_Blending:
case PF_AdditiveSource & PF_Blending:
case PF_Subtractive & PF_Blending: case PF_Subtractive & PF_Blending:
case PF_ReverseSubtract & PF_Blending: case PF_ReverseSubtract & PF_Blending:
case PF_Environment & PF_Blending: case PF_Environment & PF_Blending:
@ -2756,7 +2754,7 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32
fade.alpha = byte2float[Surface->FadeColor.s.alpha]; fade.alpha = byte2float[Surface->FadeColor.s.alpha];
flags = (Surface->PolyFlags | PF_Modulated); flags = (Surface->PolyFlags | PF_Modulated);
if (Surface->PolyFlags & (PF_Additive|PF_AdditiveSource|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative)) if (Surface->PolyFlags & (PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative))
flags |= PF_Occlude; flags |= PF_Occlude;
else if (Surface->PolyColor.s.alpha == 0xFF) else if (Surface->PolyColor.s.alpha == 0xFF)
flags |= (PF_Occlude | PF_Masked); flags |= (PF_Occlude | PF_Masked);

View file

@ -2,7 +2,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2020 by Sonic Team Junior. // Copyright (C) 1999-2021 by Sonic Team Junior.
// //
// This program is free software distributed under the // This program is free software distributed under the
// terms of the GNU General Public License, version 2. // terms of the GNU General Public License, version 2.
@ -173,14 +173,12 @@ static INT32 CacheIndexToSkin(INT32 ttc)
CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1]; CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1];
#define TRANSTAB_AMTMUL10 (256.0f / 10.0f)
/** \brief Initializes the translucency tables used by the Software renderer. /** \brief Initializes the translucency tables used by the Software renderer.
*/ */
void R_InitTranslucencyTables(void) void R_InitTranslucencyTables(void)
{ {
// Load here the transparency lookup tables 'TINTTAB' // Load here the transparency lookup tables 'TRANSx0'
// NOTE: the TINTTAB resource MUST BE aligned on 64k for the asm // NOTE: the TRANSx0 resources MUST BE aligned on 64k for the asm
// optimised code (in other words, transtables pointer low word is 0) // optimised code (in other words, transtables pointer low word is 0)
transtables = Z_MallocAlign(NUMTRANSTABLES*0x10000, PU_STATIC, transtables = Z_MallocAlign(NUMTRANSTABLES*0x10000, PU_STATIC,
NULL, 16); NULL, 16);
@ -198,42 +196,14 @@ void R_InitTranslucencyTables(void)
R_GenerateBlendTables(); R_GenerateBlendTables();
} }
void R_GenerateBlendTables(void)
{
INT32 i;
for (i = 0; i < NUMBLENDMAPS; i++)
{
if (i == blendtab_modulate)
continue;
blendtables[i] = Z_MallocAlign((NUMTRANSTABLES + 1) * 0x10000, PU_STATIC, NULL, 16);
}
for (i = 0; i <= 9; i++)
{
const size_t offs = (0x10000 * i);
const UINT8 alpha = TRANSTAB_AMTMUL10 * i;
R_GenerateTranslucencyTable(blendtables[blendtab_add] + offs, AST_ADD, alpha);
R_GenerateTranslucencyTable(blendtables[blendtab_subtract] + offs, AST_SUBTRACT, alpha);
R_GenerateTranslucencyTable(blendtables[blendtab_reversesubtract] + offs, AST_REVERSESUBTRACT, alpha);
}
// Modulation blending only requires a single table
blendtables[blendtab_modulate] = Z_MallocAlign(0x10000, PU_STATIC, NULL, 16);
R_GenerateTranslucencyTable(blendtables[blendtab_modulate], AST_MODULATE, 0);
}
static colorlookup_t transtab_lut; static colorlookup_t transtab_lut;
void R_GenerateTranslucencyTable(UINT8 *table, int style, UINT8 blendamt) static void BlendTab_Translucent(UINT8 *table, int style, UINT8 blendamt)
{ {
INT16 bg, fg; INT16 bg, fg;
if (table == NULL) if (table == NULL)
I_Error("R_GenerateTranslucencyTable: input table was NULL!"); I_Error("BlendTab_Translucent: input table was NULL!");
InitColorLUT(&transtab_lut, pMasterPalette, false);
for (bg = 0; bg < 0xFF; bg++) for (bg = 0; bg < 0xFF; bg++)
{ {
@ -243,12 +213,123 @@ void R_GenerateTranslucencyTable(UINT8 *table, int style, UINT8 blendamt)
RGBA_t frontrgba = V_GetMasterColor(fg); RGBA_t frontrgba = V_GetMasterColor(fg);
RGBA_t result; RGBA_t result;
result.rgba = ASTBlendPixel(backrgba, frontrgba, style, blendamt); result.rgba = ASTBlendPixel(backrgba, frontrgba, style, 0xFF);
result.rgba = ASTBlendPixel(result, frontrgba, AST_TRANSLUCENT, blendamt);
table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue); table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue);
} }
} }
} }
static void BlendTab_Subtractive(UINT8 *table, int style, UINT8 blendamt)
{
INT16 bg, fg;
if (table == NULL)
I_Error("BlendTab_Subtractive: input table was NULL!");
if (blendamt == 0xFF)
{
memset(table, GetColorLUT(&transtab_lut, 0, 0, 0), 0x10000);
return;
}
for (bg = 0; bg < 0xFF; bg++)
{
for (fg = 0; fg < 0xFF; fg++)
{
RGBA_t backrgba = V_GetMasterColor(bg);
RGBA_t frontrgba = V_GetMasterColor(fg);
RGBA_t result;
result.rgba = ASTBlendPixel(backrgba, frontrgba, style, 0xFF);
result.s.red = max(0, result.s.red - blendamt);
result.s.green = max(0, result.s.green - blendamt);
result.s.blue = max(0, result.s.blue - blendamt);
table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue);
}
}
}
static void BlendTab_Modulative(UINT8 *table)
{
INT16 bg, fg;
if (table == NULL)
I_Error("BlendTab_Modulative: input table was NULL!");
for (bg = 0; bg < 0xFF; bg++)
{
for (fg = 0; fg < 0xFF; fg++)
{
RGBA_t backrgba = V_GetMasterColor(bg);
RGBA_t frontrgba = V_GetMasterColor(fg);
RGBA_t result;
result.rgba = ASTBlendPixel(backrgba, frontrgba, AST_MODULATE, 0);
table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue);
}
}
}
static INT32 BlendTab_Count[NUMBLENDMAPS] =
{
NUMTRANSTABLES, // blendtab_add
NUMTRANSTABLES+1, // blendtab_subtract
NUMTRANSTABLES+1, // blendtab_reversesubtract
1 // blendtab_modulate
};
static INT32 BlendTab_FromStyle[] =
{
0, // AST_COPY
0, // AST_TRANSLUCENT
blendtab_add, // AST_ADD
blendtab_subtract, // AST_SUBTRACT
blendtab_reversesubtract, // AST_REVERSESUBTRACT
blendtab_modulate, // AST_MODULATE
0 // AST_OVERLAY
};
static void BlendTab_GenerateMaps(INT32 tab, INT32 style, void (*genfunc)(UINT8 *, int, UINT8))
{
INT32 i = 0, num = BlendTab_Count[tab];
const float amtmul = (256.0f / (float)(NUMTRANSTABLES));
for (; i < num; i++)
{
const size_t offs = (0x10000 * i);
const UINT16 alpha = min(amtmul * i, 0xFF);
genfunc(blendtables[tab] + offs, style, alpha);
}
}
void R_GenerateBlendTables(void)
{
INT32 i;
for (i = 0; i < NUMBLENDMAPS; i++)
blendtables[i] = Z_MallocAlign(BlendTab_Count[i] * 0x10000, PU_STATIC, NULL, 16);
InitColorLUT(&transtab_lut, pMasterPalette, false);
// Additive
BlendTab_GenerateMaps(blendtab_add, AST_ADD, BlendTab_Translucent);
// Subtractive
#if 1
BlendTab_GenerateMaps(blendtab_subtract, AST_SUBTRACT, BlendTab_Subtractive);
#else
BlendTab_GenerateMaps(blendtab_subtract, AST_SUBTRACT, BlendTab_Translucent);
#endif
// Reverse subtractive
BlendTab_GenerateMaps(blendtab_reversesubtract, AST_REVERSESUBTRACT, BlendTab_Translucent);
// Modulative blending only requires a single table
BlendTab_Modulative(blendtables[blendtab_modulate]);
}
#define ClipBlendLevel(style, trans) max(min((trans), BlendTab_Count[BlendTab_FromStyle[style]]-1), 0)
#define ClipTransLevel(trans) max(min((trans), NUMTRANSMAPS-2), 0) #define ClipTransLevel(trans) max(min((trans), NUMTRANSMAPS-2), 0)
UINT8 *R_GetTranslucencyTable(INT32 alphalevel) UINT8 *R_GetTranslucencyTable(INT32 alphalevel)
@ -258,7 +339,12 @@ UINT8 *R_GetTranslucencyTable(INT32 alphalevel)
UINT8 *R_GetBlendTable(int style, INT32 alphalevel) UINT8 *R_GetBlendTable(int style, INT32 alphalevel)
{ {
size_t offs = (ClipTransLevel(alphalevel) << FF_TRANSSHIFT); size_t offs;
if (style == AST_COPY || style == AST_OVERLAY)
return NULL;
offs = (ClipBlendLevel(style, alphalevel) << FF_TRANSSHIFT);
// Lactozilla: Returns the equivalent to AST_TRANSLUCENT // Lactozilla: Returns the equivalent to AST_TRANSLUCENT
// if no alpha style matches any of the blend tables. // if no alpha style matches any of the blend tables.
@ -283,6 +369,14 @@ UINT8 *R_GetBlendTable(int style, INT32 alphalevel)
return NULL; return NULL;
} }
boolean R_BlendLevelVisible(INT32 blendmode, INT32 alphalevel)
{
if (blendmode == AST_COPY || blendmode == AST_SUBTRACT || blendmode == AST_MODULATE || blendmode == AST_OVERLAY)
return true;
return (alphalevel < BlendTab_Count[BlendTab_FromStyle[blendmode]]);
}
// Define for getting accurate color brightness readings according to how the human eye sees them. // Define for getting accurate color brightness readings according to how the human eye sees them.
// https://en.wikipedia.org/wiki/Relative_luminance // https://en.wikipedia.org/wiki/Relative_luminance
// 0.2126 to red // 0.2126 to red

View file

@ -2,7 +2,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2020 by Sonic Team Junior. // Copyright (C) 1999-2021 by Sonic Team Junior.
// //
// This program is free software distributed under the // This program is free software distributed under the
// terms of the GNU General Public License, version 2. // terms of the GNU General Public License, version 2.
@ -140,11 +140,12 @@ extern UINT8 *blendtables[NUMBLENDMAPS];
void R_InitTranslucencyTables(void); void R_InitTranslucencyTables(void);
void R_GenerateBlendTables(void); void R_GenerateBlendTables(void);
void R_GenerateTranslucencyTable(UINT8 *table, int style, UINT8 blendamt);
UINT8 *R_GetTranslucencyTable(INT32 alphalevel); UINT8 *R_GetTranslucencyTable(INT32 alphalevel);
UINT8 *R_GetBlendTable(int style, INT32 alphalevel); UINT8 *R_GetBlendTable(int style, INT32 alphalevel);
boolean R_BlendLevelVisible(INT32 blendmode, INT32 alphalevel);
// Color ramp modification should force a recache // Color ramp modification should force a recache
extern UINT8 skincolor_modified[]; extern UINT8 skincolor_modified[];

View file

@ -1803,7 +1803,7 @@ static void R_ProjectSprite(mobj_t *thing)
else if (oldthing->frame & FF_TRANSMASK) else if (oldthing->frame & FF_TRANSMASK)
{ {
trans = (oldthing->frame & FF_TRANSMASK) >> FF_TRANSSHIFT; trans = (oldthing->frame & FF_TRANSMASK) >> FF_TRANSSHIFT;
if (oldthing->blendmode == AST_TRANSLUCENT && trans >= NUMTRANSMAPS) if (!R_BlendLevelVisible(oldthing->blendmode, trans))
return; return;
} }
else else
@ -2200,7 +2200,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
// specific translucency // specific translucency
if (thing->frame & FF_TRANSMASK) if (thing->frame & FF_TRANSMASK)
vis->transmap = (thing->frame & FF_TRANSMASK) - 0x10000 + transtables; vis->transmap = R_GetTranslucencyTable((thing->frame & FF_TRANSMASK) >> FF_TRANSSHIFT);
else else
vis->transmap = NULL; vis->transmap = NULL;