Turn the fog wall linedef type into a blendmode

This commit is contained in:
MascaraSnake 2021-12-31 15:00:27 +01:00 committed by Sally Coolatta
parent 974c099e8a
commit f16c1cd95f
8 changed files with 72 additions and 65 deletions

View file

@ -74,6 +74,7 @@ linedefrenderstyles
subtract = "Subtract";
reversesubtract = "Reverse subtract";
modulate = "Modulate";
fog = "Fog";
}
sectorflags

View file

@ -6172,6 +6172,7 @@ struct int_const_s const INT_CONST[] = {
{"AST_REVERSESUBTRACT",AST_REVERSESUBTRACT},
{"AST_MODULATE",AST_MODULATE},
{"AST_OVERLAY",AST_OVERLAY},
{"AST_FOG",AST_FOG},
// Render flags
{"RF_HORIZONTALFLIP",RF_HORIZONTALFLIP},

View file

@ -222,6 +222,7 @@ enum EPolyFlags
PF_Fog = 0x20000000, // Fog blocks
PF_NoAlphaTest = 0x40000000, // Disables alpha testing
PF_Blending = (PF_Masked|PF_Translucent|PF_Environment|PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Invert|PF_Fog) & ~PF_NoAlphaTest,
PF_EnvironmentTrans = (PF_Translucent|PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Environment),
// other flag bits
PF_Occlude = 0x00000100, // Updates the depth buffer

View file

@ -503,7 +503,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
lightlevel = HWR_CalcSlopeLight(lightlevel, slope);
HWR_Lighting(&Surf, lightlevel, planecolormap);
if (PolyFlags & (PF_Translucent|PF_Additive|PF_Subtractive|PF_Fog))
if (PolyFlags & PF_EnvironmentTrans)
{
Surf.PolyColor.s.alpha = (UINT8)alpha;
PolyFlags |= PF_Modulated;
@ -932,7 +932,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum,
if (polyflags & PF_Fog)
HWR_AddTransparentWall(wallVerts, Surf, texnum, polyflags, true, HWR_CalcWallLight(lightnum, gl_curline), colormap);
else if (polyflags & (PF_Translucent|PF_Additive|PF_Subtractive|PF_Environment))
else if (polyflags & PF_EnvironmentTrans)
HWR_AddTransparentWall(wallVerts, Surf, texnum, polyflags, false, HWR_CalcWallLight(lightnum, gl_curline), colormap);
else
HWR_ProjectWall(wallVerts, Surf, polyflags, HWR_CalcWallLight(lightnum, gl_curline), colormap);
@ -961,7 +961,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum,
if (polyflags & PF_Fog)
HWR_AddTransparentWall(wallVerts, Surf, texnum, polyflags, true, HWR_CalcWallLight(lightnum, gl_curline), colormap);
else if (polyflags & (PF_Translucent|PF_Additive|PF_Subtractive|PF_Environment))
else if (polyflags & PF_EnvironmentTrans)
HWR_AddTransparentWall(wallVerts, Surf, texnum, polyflags, false, HWR_CalcWallLight(lightnum, gl_curline), colormap);
else
HWR_ProjectWall(wallVerts, Surf, polyflags, HWR_CalcWallLight(lightnum, gl_curline), colormap);
@ -1419,29 +1419,24 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
case 221:
case 253:
case 256:
blendmode = PF_Translucent;
break;
case 913:
blendmode = PF_Multiplicative;
Surf.PolyColor.s.alpha = 0xff;
if (gl_linedef->blendmode != AST_FOG)
blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), &Surf);
else
blendmode = PF_Translucent;
break;
default:
{
UINT32 blend = 0;
transnum_t transtable = R_GetLinedefTransTable(gl_linedef);
if (transtable == NUMTRANSMAPS)
transtable = 0;
if (gl_linedef->special == 910 ||
P_IsLineTripWire(gl_linedef))
blend = AST_ADD;
else if (gl_linedef->special == 911)
blend = AST_SUBTRACT;
else if (gl_linedef->special == 912)
blend = AST_REVERSESUBTRACT;
blendmode = HWR_SurfaceBlend(blend, transtable, &Surf);
if (gl_linedef->blendmode != AST_FOG)
{
if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT)
blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), &Surf);
else
blendmode = HWR_GetBlendModeFlag(gl_linedef->blendmode);
}
else if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT)
blendmode = HWR_TranstableToAlpha(R_GetLinedefTransTable(gl_linedef->alpha), &Surf);
else
blendmode = PF_Masked;
break;
}
}
if (gl_curline->polyseg && gl_curline->polyseg->translucency > 0)

View file

@ -1538,6 +1538,8 @@ static void ParseTextmapLinedefParameter(UINT32 i, char *param, char *val)
lines[i].blendmode = AST_REVERSESUBTRACT;
else if (fastcmp(val, "modulate"))
lines[i].blendmode = AST_MODULATE;
if (fastcmp(val, "fog"))
lines[i].blendmode = AST_FOG;
}
else if (fastcmp(param, "executordelay"))
lines[i].executordelay = atol(val);
@ -1939,6 +1941,12 @@ static void P_ProcessLinedefsAfterSidedefs(void)
P_CheckLineSideTripWire(ld, 0) ||
P_CheckLineSideTripWire(ld, 1);
if (ld->tripwire)
{
ld->blendmode = AST_ADD;
ld->alpha = 0;
}
switch (ld->special)
{
// Compile linedef 'text' from both sidedefs 'text' for appropriate specials.
@ -3279,22 +3287,33 @@ static void P_ConvertBinaryMap(void)
lines[i].args[4] |= TMSC_BACKTOFRONTCEILING;
lines[i].special = 720;
break;
case 900: //Translucent wall (10%)
case 901: //Translucent wall (20%)
case 902: //Translucent wall (30%)
case 903: //Translucent wall (40%)
case 904: //Translucent wall (50%)
case 905: //Translucent wall (60%)
case 906: //Translucent wall (70%)
case 907: //Translucent wall (80%)
case 908: //Translucent wall (90%)
lines[i].alpha = ((909 - lines[i].special) << FRACBITS)/10;
case 909: //Fog wall
lines[i].blendmode = AST_FOG;
break;
default:
break;
}
// Set alpha for translucent walls
if (lines[i].special >= 900 && lines[i].special < 909)
lines[i].alpha = ((909 - lines[i].special) << FRACBITS)/10;
// Set alpha for additive/subtractive/reverse subtractive walls
if (lines[i].special >= 910 && lines[i].special <= 939)
lines[i].alpha = ((10 - lines[i].special % 10) << FRACBITS)/10;
if (lines[i].special >= 910 && lines[i].special <= 919) // additive
lines[i].blendmode = AST_ADD;
if (lines[i].special >= 920 && lines[i].special <= 929) // subtractive
lines[i].blendmode = AST_SUBTRACT;
if (lines[i].special >= 930 && lines[i].special <= 939) // reverse subtractive
lines[i].blendmode = AST_REVERSESUBTRACT;
if (lines[i].special == 940) // modulate
lines[i].blendmode = AST_MODULATE;
//Linedef executor delay
if (lines[i].special >= 400 && lines[i].special < 500)
{

View file

@ -411,6 +411,7 @@ typedef struct line_s
// Visual appearance: sidedefs.
UINT16 sidenum[2]; // sidenum[1] will be 0xffff if one-sided
fixed_t alpha; // translucency
UINT8 blendmode; // blendmode
INT32 executordelay;
fixed_t bbox[4]; // bounding box for the extent of the linedef
@ -739,7 +740,7 @@ typedef struct
#endif
// Possible alpha types for a patch.
typedef enum {AST_COPY, AST_TRANSLUCENT, AST_ADD, AST_SUBTRACT, AST_REVERSESUBTRACT, AST_MODULATE, AST_OVERLAY} patchalphastyle_t;
typedef enum {AST_COPY, AST_TRANSLUCENT, AST_ADD, AST_SUBTRACT, AST_REVERSESUBTRACT, AST_MODULATE, AST_OVERLAY, AST_FOG} patchalphastyle_t;
typedef enum
{

View file

@ -130,12 +130,15 @@ static void R_Render2sidedMultiPatchColumn(column_t *column, column_t *brightmap
}
}
transnum_t R_GetLinedefTransTable(line_t *ldef)
transnum_t R_GetLinedefTransTable(fixed_t alpha)
{
transnum_t transnum = NUMTRANSMAPS; // Send back NUMTRANSMAPS for none
fixed_t alpha = ldef->alpha;
if (alpha > 0 && alpha < FRACUNIT)
{
transnum = (20*(FRACUNIT - alpha - 1) + FRACUNIT) >> (FRACBITS+1);
}
return transnum;
}
@ -172,41 +175,27 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
if (!ldef->alpha)
return;
transtable = R_GetLinedefTransTable(ldef);
if (ldef->special == 910 || P_IsLineTripWire(ldef))
{
if (transtable == NUMTRANSMAPS)
transtable = 0;
blendmode = AST_ADD;
}
else if (ldef->special == 911)
{
if (transtable == NUMTRANSMAPS)
transtable = 0;
blendmode = AST_SUBTRACT;
}
else if (ldef->special == 912)
{
if (transtable == NUMTRANSMAPS)
transtable = 0;
blendmode = AST_REVERSESUBTRACT;
}
else if (ldef->special == 913)
transtable = R_GetLinedefTransTable(ldef->alpha);
blendmode = ldef->blendmode;
if (transtable == NUMTRANSMAPS
|| blendmode == AST_MODULATE
|| blendmode == AST_FOG)
{
transtable = 0;
blendmode = AST_MODULATE;
}
if (transtable != NUMTRANSMAPS && (blendmode || transtable))
{
dc_transmap = R_GetBlendTable(blendmode, transtable);
R_SetColumnFunc(COLDRAWFUNC_FUZZY, bmnum != 0);
}
else if (ldef->special == 909)
if (blendmode == AST_FOG)
{
R_SetColumnFunc(COLDRAWFUNC_FOG, bmnum != 0);
windowtop = frontsector->ceilingheight;
windowbottom = frontsector->floorheight;
}
else if (transtable != NUMTRANSMAPS && (blendmode || transtable))
{
dc_transmap = R_GetBlendTable(blendmode, transtable);
R_SetColumnFunc(COLDRAWFUNC_FUZZY, bmnum != 0);
}
else
{
R_SetColumnFunc(BASEDRAWFUNC, bmnum != 0);

View file

@ -18,7 +18,7 @@
#pragma interface
#endif
transnum_t R_GetLinedefTransTable(line_t *line);
transnum_t R_GetLinedefTransTable(fixed_t alpha);
void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2);
void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pffloor);
void R_StoreWallRange(INT32 start, INT32 stop);