mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
* Add a blend field to FOFs.
* Set via a fourth digit in the upper midtexture for transparent FOFs
* For example - #2551 is additive solid, #1282 is subtractive half...
* The original method of setting the upper midtexture to #900 or 901 still works, since I'm not out to break existing maps.
* Software: Remove the horrible `else if` ladder for FOF translucency. Algorithms, baby!
* OpenGL: Move to using `HWR_GetBlendModeFlag` in more places, for more long-term extensible support for multiple blendmodes.
This commit is contained in:
parent
e27506c660
commit
ebe38ff518
9 changed files with 73 additions and 108 deletions
|
|
@ -6467,6 +6467,15 @@ struct int_const_s const INT_CONST[] = {
|
|||
{"tr_trans90",tr_trans90},
|
||||
{"NUMTRANSMAPS",NUMTRANSMAPS},
|
||||
|
||||
// Alpha styles (blend modes)
|
||||
//{"AST_COPY",AST_COPY}, -- not useful in lua
|
||||
//{"AST_TRANSLUCENT",AST_TRANSLUCENT}, -- ditto
|
||||
{"AST_ADD",AST_ADD},
|
||||
{"AST_SUBTRACT",AST_SUBTRACT},
|
||||
{"AST_REVERSESUBTRACT",AST_REVERSESUBTRACT},
|
||||
{"AST_MODULATE",AST_MODULATE},
|
||||
{"AST_OVERLAY",AST_OVERLAY},
|
||||
|
||||
// Render flags
|
||||
{"RF_HORIZONTALFLIP",RF_HORIZONTALFLIP},
|
||||
{"RF_VERTICALFLIP",RF_VERTICALFLIP},
|
||||
|
|
|
|||
|
|
@ -266,16 +266,7 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p
|
|||
FSurfaceInfo Surf;
|
||||
Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff;
|
||||
|
||||
if (!alphalevel)
|
||||
flags &= ~PF_Translucent;
|
||||
if (blendmode == AST_ADD)
|
||||
flags |= PF_Additive;
|
||||
else if (blendmode == AST_SUBTRACT)
|
||||
flags |= PF_Subtractive;
|
||||
else if (blendmode == AST_REVERSESUBTRACT)
|
||||
flags |= PF_ReverseSubtract;
|
||||
else if (blendmode == AST_MODULATE)
|
||||
flags |= PF_Multiplicative;
|
||||
flags |= HWR_GetBlendModeFlag(blendmode);
|
||||
|
||||
if (alphalevel == 10)
|
||||
Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency];
|
||||
|
|
@ -439,16 +430,7 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale,
|
|||
FSurfaceInfo Surf;
|
||||
Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff;
|
||||
|
||||
if (!alphalevel)
|
||||
flags &= ~PF_Translucent;
|
||||
if (blendmode == AST_ADD)
|
||||
flags |= PF_Additive;
|
||||
else if (blendmode == AST_SUBTRACT)
|
||||
flags |= PF_Subtractive;
|
||||
else if (blendmode == AST_REVERSESUBTRACT)
|
||||
flags |= PF_ReverseSubtract;
|
||||
else if (blendmode == AST_MODULATE)
|
||||
flags |= PF_Multiplicative;
|
||||
flags |= HWR_GetBlendModeFlag(blendmode);
|
||||
|
||||
if (alphalevel == 10)
|
||||
Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency];
|
||||
|
|
|
|||
|
|
@ -1752,15 +1752,11 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
|||
|
||||
if (rover->flags & FF_TRANSLUCENT)
|
||||
{
|
||||
if (rover->alpha < 256)
|
||||
if (rover->alpha < 256 || rover->blend)
|
||||
{
|
||||
blendmode = PF_Translucent;
|
||||
Surf.PolyColor.s.alpha = (UINT8)(rover->alpha-1 > 255 ? 255 : rover->alpha-1);
|
||||
blendmode = HWR_GetBlendModeFlag(rover->blend);
|
||||
Surf.PolyColor.s.alpha = (UINT8)(rover->alpha-1);
|
||||
}
|
||||
else if (rover->alpha == FFLOOR_ALPHA_SPECIAL_ADDITIVE)
|
||||
blendmode = PF_Additive;
|
||||
else if (rover->alpha == FFLOOR_ALPHA_SPECIAL_SUBTRACTIVE)
|
||||
blendmode = PF_Subtractive;
|
||||
}
|
||||
|
||||
if (gl_frontsector->numlights)
|
||||
|
|
@ -1871,15 +1867,11 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
|||
|
||||
if (rover->flags & FF_TRANSLUCENT)
|
||||
{
|
||||
if (rover->alpha < 256)
|
||||
if (rover->alpha < 256 || rover->blend)
|
||||
{
|
||||
blendmode = PF_Translucent;
|
||||
Surf.PolyColor.s.alpha = (UINT8)(rover->alpha-1 > 255 ? 255 : rover->alpha-1);
|
||||
blendmode = HWR_GetBlendModeFlag(rover->blend);
|
||||
Surf.PolyColor.s.alpha = (UINT8)(rover->alpha-1);
|
||||
}
|
||||
else if (rover->alpha == FFLOOR_ALPHA_SPECIAL_ADDITIVE)
|
||||
blendmode = PF_Additive;
|
||||
else if (rover->alpha == FFLOOR_ALPHA_SPECIAL_SUBTRACTIVE)
|
||||
blendmode = PF_Subtractive;
|
||||
}
|
||||
|
||||
if (gl_backsector->numlights)
|
||||
|
|
@ -3152,14 +3144,9 @@ static void HWR_Subsector(size_t num)
|
|||
true, rover->master->frontsector->extra_colormap);
|
||||
}
|
||||
else if (rover->flags & FF_TRANSLUCENT
|
||||
&& (rover->alpha < 256
|
||||
|| rover->alpha == FFLOOR_ALPHA_SPECIAL_ADDITIVE || rover->alpha == FFLOOR_ALPHA_SPECIAL_SUBTRACTIVE)) // SoM: Flags are more efficient
|
||||
&& (rover->alpha < 256 || rover->blend)) // SoM: Flags are more efficient
|
||||
{
|
||||
FBITFIELD blendmode = PF_Translucent | HWR_RippleBlend(gl_frontsector, rover, false);
|
||||
if (rover->alpha == FFLOOR_ALPHA_SPECIAL_ADDITIVE)
|
||||
blendmode = PF_Additive;
|
||||
else if (rover->alpha == FFLOOR_ALPHA_SPECIAL_SUBTRACTIVE)
|
||||
blendmode = PF_Subtractive;
|
||||
FBITFIELD blendmode = HWR_GetBlendModeFlag(rover->blend) | HWR_RippleBlend(gl_frontsector, rover, false);
|
||||
|
||||
light = R_GetPlaneLight(gl_frontsector, centerHeight, dup_viewz < cullHeight ? true : false);
|
||||
|
||||
|
|
@ -3168,7 +3155,7 @@ static void HWR_Subsector(size_t num)
|
|||
false,
|
||||
*rover->bottomheight,
|
||||
*gl_frontsector->lightlist[light].lightlevel,
|
||||
rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, blendmode,
|
||||
rover->alpha-1, rover->master->frontsector, blendmode,
|
||||
false, *gl_frontsector->lightlist[light].extra_colormap);
|
||||
}
|
||||
else
|
||||
|
|
@ -3205,14 +3192,9 @@ static void HWR_Subsector(size_t num)
|
|||
true, rover->master->frontsector->extra_colormap);
|
||||
}
|
||||
else if (rover->flags & FF_TRANSLUCENT
|
||||
&& (rover->alpha < 256
|
||||
|| rover->alpha == FFLOOR_ALPHA_SPECIAL_ADDITIVE || rover->alpha == FFLOOR_ALPHA_SPECIAL_SUBTRACTIVE)) // SoM: Flags are more efficient
|
||||
&& (rover->alpha < 256 || rover->blend)) // SoM: Flags are more efficient
|
||||
{
|
||||
FBITFIELD blendmode = PF_Translucent | HWR_RippleBlend(gl_frontsector, rover, true);
|
||||
if (rover->alpha == FFLOOR_ALPHA_SPECIAL_ADDITIVE)
|
||||
blendmode = PF_Additive;
|
||||
else if (rover->alpha == FFLOOR_ALPHA_SPECIAL_SUBTRACTIVE)
|
||||
blendmode = PF_Subtractive;
|
||||
FBITFIELD blendmode = HWR_GetBlendModeFlag(rover->blend) | HWR_RippleBlend(gl_frontsector, rover, false);
|
||||
|
||||
light = R_GetPlaneLight(gl_frontsector, centerHeight, dup_viewz < cullHeight ? true : false);
|
||||
|
||||
|
|
@ -3221,7 +3203,7 @@ static void HWR_Subsector(size_t num)
|
|||
true,
|
||||
*rover->topheight,
|
||||
*gl_frontsector->lightlist[light].lightlevel,
|
||||
rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, blendmode,
|
||||
rover->alpha-1, rover->master->frontsector, blendmode,
|
||||
false, *gl_frontsector->lightlist[light].extra_colormap);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -196,6 +196,7 @@ enum ffloor_e {
|
|||
ffloor_next,
|
||||
ffloor_prev,
|
||||
ffloor_alpha,
|
||||
ffloor_blend,
|
||||
};
|
||||
|
||||
static const char *const ffloor_opt[] = {
|
||||
|
|
@ -214,6 +215,7 @@ static const char *const ffloor_opt[] = {
|
|||
"next",
|
||||
"prev",
|
||||
"alpha",
|
||||
"blend",
|
||||
NULL};
|
||||
|
||||
#ifdef HAVE_LUA_SEGS
|
||||
|
|
@ -1796,6 +1798,9 @@ static int ffloor_get(lua_State *L)
|
|||
case ffloor_alpha:
|
||||
lua_pushinteger(L, ffloor->alpha);
|
||||
return 1;
|
||||
case ffloor_blend:
|
||||
lua_pushinteger(L, ffloor->blend);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1874,6 +1879,9 @@ static int ffloor_set(lua_State *L)
|
|||
case ffloor_alpha:
|
||||
ffloor->alpha = (INT32)luaL_checkinteger(L, 3);
|
||||
break;
|
||||
case ffloor_blend:
|
||||
ffloor->blend = (INT32)luaL_checkinteger(L, 3);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1337,8 +1337,11 @@ static void P_LoadSidedefs(UINT8 *data)
|
|||
if (msd->toptexture[0] == '#')
|
||||
{
|
||||
char *col = msd->toptexture;
|
||||
sd->toptexture = sd->bottomtexture =
|
||||
((col[1]-'0')*100 + (col[2]-'0')*10 + col[3]-'0') + 1;
|
||||
sd->toptexture =
|
||||
((col[1]-'0')*100 + (col[2]-'0')*10 + col[3]-'0')+1;
|
||||
if (col[4]) // extra num for blendmode
|
||||
sd->toptexture += (col[4]-'0')*1000;
|
||||
sd->bottomtexture = sd->toptexture;
|
||||
sd->midtexture = R_TextureNumForName(msd->midtexture);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
21
src/p_spec.c
21
src/p_spec.c
|
|
@ -5380,7 +5380,26 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f
|
|||
if (flags & FF_TRANSLUCENT)
|
||||
{
|
||||
if (sides[master->sidenum[0]].toptexture > 0)
|
||||
fflr->alpha = sides[master->sidenum[0]].toptexture; // for future reference, "#0" is 1, and "#255" is 256. Be warned
|
||||
{
|
||||
// for future reference, "#0" is 1, and "#255" is 256. Be warned
|
||||
fflr->alpha = sides[master->sidenum[0]].toptexture;
|
||||
|
||||
if (fflr->alpha == 901) // additive special
|
||||
{
|
||||
fflr->blend = AST_ADD;
|
||||
fflr->alpha = 0xff;
|
||||
}
|
||||
else if (fflr->alpha == 902) // subtractive special
|
||||
{
|
||||
fflr->blend = AST_SUBTRACT;
|
||||
fflr->alpha = 0xff;
|
||||
}
|
||||
else if (fflr->alpha >= 1001) // fourth digit
|
||||
{
|
||||
fflr->blend = (fflr->alpha/1000)+1; // becomes an AST
|
||||
fflr->alpha %= 1000;
|
||||
}
|
||||
}
|
||||
else
|
||||
fflr->alpha = 0x80;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,9 +154,6 @@ typedef enum
|
|||
FF_GOOWATER = FF_SHATTERBOTTOM, ///< Used with ::FF_SWIMMABLE. Makes thick bouncey goop.
|
||||
} ffloortype_e;
|
||||
|
||||
#define FFLOOR_ALPHA_SPECIAL_ADDITIVE (901)
|
||||
#define FFLOOR_ALPHA_SPECIAL_SUBTRACTIVE (902)
|
||||
|
||||
typedef struct ffloor_s
|
||||
{
|
||||
fixed_t *topheight;
|
||||
|
|
@ -187,6 +184,7 @@ typedef struct ffloor_s
|
|||
|
||||
INT32 lastlight;
|
||||
INT32 alpha;
|
||||
UINT8 blend;
|
||||
tic_t norender; // for culling
|
||||
|
||||
// these are saved for netgames, so do not let Lua touch these!
|
||||
|
|
|
|||
|
|
@ -861,32 +861,14 @@ void R_DrawSinglePlane(visplane_t *pl)
|
|||
spanfunctype = (pl->ffloor->master->flags & ML_EFFECT6) ? SPANDRAWFUNC_TRANSSPLAT : SPANDRAWFUNC_TRANS;
|
||||
|
||||
// Hacked up support for alpha value in software mode Tails 09-24-2002
|
||||
if (pl->ffloor->alpha < 12)
|
||||
// ...unhacked by toaster 04-01-2021
|
||||
{
|
||||
INT32 trans = (10*((256+12) - pl->ffloor->alpha))/255;
|
||||
if (trans >= 10)
|
||||
return; // Don't even draw it
|
||||
else if (pl->ffloor->alpha < 38)
|
||||
ds_transmap = R_GetTranslucencyTable(tr_trans90);
|
||||
else if (pl->ffloor->alpha < 64)
|
||||
ds_transmap = R_GetTranslucencyTable(tr_trans80);
|
||||
else if (pl->ffloor->alpha < 89)
|
||||
ds_transmap = R_GetTranslucencyTable(tr_trans70);
|
||||
else if (pl->ffloor->alpha < 115)
|
||||
ds_transmap = R_GetTranslucencyTable(tr_trans60);
|
||||
else if (pl->ffloor->alpha < 140)
|
||||
ds_transmap = R_GetTranslucencyTable(tr_trans50);
|
||||
else if (pl->ffloor->alpha < 166)
|
||||
ds_transmap = R_GetTranslucencyTable(tr_trans40);
|
||||
else if (pl->ffloor->alpha < 192)
|
||||
ds_transmap = R_GetTranslucencyTable(tr_trans30);
|
||||
else if (pl->ffloor->alpha < 217)
|
||||
ds_transmap = R_GetTranslucencyTable(tr_trans20);
|
||||
else if (pl->ffloor->alpha < 243)
|
||||
ds_transmap = R_GetTranslucencyTable(tr_trans10);
|
||||
else if (pl->ffloor->alpha == FFLOOR_ALPHA_SPECIAL_ADDITIVE)
|
||||
ds_transmap = R_GetTranslucencyTable(tr_trans50); // TODOOOOOOOOOOOOO
|
||||
else if (pl->ffloor->alpha == FFLOOR_ALPHA_SPECIAL_SUBTRACTIVE)
|
||||
ds_transmap = R_GetTranslucencyTable(tr_trans50); // TODOOOOOOOOOOOOO
|
||||
else // Opaque, but allow transparent flat pixels
|
||||
spanfunctype = SPANDRAWFUNC_SPLAT;
|
||||
if (!(ds_transmap = R_GetBlendTable(pl->ffloor->blend, trans)))
|
||||
spanfunctype = SPANDRAWFUNC_SPLAT; // Opaque, but allow transparent flat pixels
|
||||
}
|
||||
|
||||
if ((spanfunctype == SPANDRAWFUNC_SPLAT) || (pl->extra_colormap && (pl->extra_colormap->flags & CMF_FOG)))
|
||||
light = (pl->lightlevel >> LIGHTSEGSHIFT);
|
||||
|
|
|
|||
30
src/r_segs.c
30
src/r_segs.c
|
|
@ -631,32 +631,14 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
|
|||
boolean fuzzy = true;
|
||||
|
||||
// Hacked up support for alpha value in software mode Tails 09-24-2002
|
||||
if (pfloor->alpha < 12)
|
||||
// ...unhacked by toaster 04-01-2021
|
||||
{
|
||||
INT32 trans = (10*((256+12) - pfloor->alpha))/255;
|
||||
if (trans >= 10)
|
||||
return; // Don't even draw it
|
||||
else if (pfloor->alpha < 38)
|
||||
dc_transmap = R_GetTranslucencyTable(tr_trans90);
|
||||
else if (pfloor->alpha < 64)
|
||||
dc_transmap = R_GetTranslucencyTable(tr_trans80);
|
||||
else if (pfloor->alpha < 89)
|
||||
dc_transmap = R_GetTranslucencyTable(tr_trans70);
|
||||
else if (pfloor->alpha < 115)
|
||||
dc_transmap = R_GetTranslucencyTable(tr_trans60);
|
||||
else if (pfloor->alpha < 140)
|
||||
dc_transmap = R_GetTranslucencyTable(tr_trans50);
|
||||
else if (pfloor->alpha < 166)
|
||||
dc_transmap = R_GetTranslucencyTable(tr_trans40);
|
||||
else if (pfloor->alpha < 192)
|
||||
dc_transmap = R_GetTranslucencyTable(tr_trans30);
|
||||
else if (pfloor->alpha < 217)
|
||||
dc_transmap = R_GetTranslucencyTable(tr_trans20);
|
||||
else if (pfloor->alpha < 243)
|
||||
dc_transmap = R_GetTranslucencyTable(tr_trans10);
|
||||
else if (pfloor->alpha == FFLOOR_ALPHA_SPECIAL_ADDITIVE)
|
||||
dc_transmap = R_GetTranslucencyTable(tr_trans50); // TODOOOOOOOOOOOOO
|
||||
else if (pfloor->alpha == FFLOOR_ALPHA_SPECIAL_SUBTRACTIVE)
|
||||
dc_transmap = R_GetTranslucencyTable(tr_trans50); // TODOOOOOOOOOOOOO
|
||||
else
|
||||
if (!(dc_transmap = R_GetBlendTable(pfloor->blend, trans)))
|
||||
fuzzy = false; // Opaque
|
||||
}
|
||||
|
||||
if (fuzzy)
|
||||
colfunc = colfuncs[COLDRAWFUNC_FUZZY];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue