Implement linedef alpha field (replaces specials 900-908)

This commit is contained in:
MascaraSnake 2020-01-26 12:24:52 +01:00
parent 3775e6447e
commit cedfc02f19
6 changed files with 61 additions and 51 deletions

View File

@ -1818,37 +1818,10 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
}
#endif
// set alpha for transparent walls (new boom and legacy linedef types)
// set alpha for transparent walls
// ooops ! this do not work at all because render order we should render it in backtofront order
switch (gr_linedef->special)
{
case 900:
blendmode = HWR_TranstableToAlpha(tr_trans10, &Surf);
break;
case 901:
blendmode = HWR_TranstableToAlpha(tr_trans20, &Surf);
break;
case 902:
blendmode = HWR_TranstableToAlpha(tr_trans30, &Surf);
break;
case 903:
blendmode = HWR_TranstableToAlpha(tr_trans40, &Surf);
break;
case 904:
blendmode = HWR_TranstableToAlpha(tr_trans50, &Surf);
break;
case 905:
blendmode = HWR_TranstableToAlpha(tr_trans60, &Surf);
break;
case 906:
blendmode = HWR_TranstableToAlpha(tr_trans70, &Surf);
break;
case 907:
blendmode = HWR_TranstableToAlpha(tr_trans80, &Surf);
break;
case 908:
blendmode = HWR_TranstableToAlpha(tr_trans90, &Surf);
break;
// Translucent
case 102:
case 121:
@ -1869,7 +1842,10 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
blendmode = PF_Translucent;
break;
default:
blendmode = PF_Masked;
if (gr_linedef->alpha > 0 && gr_linedef->alpha < FRACUNIT)
blendmode = HWR_TranstableToAlpha(R_GetLinedefTransTable(gr_linedef->alpha), &Surf);
else
blendmode = PF_Masked;
break;
}

View File

@ -99,6 +99,7 @@ enum line_e {
line_sidenum,
line_frontside,
line_backside,
line_alpha,
line_slopetype,
line_frontsector,
line_backsector,
@ -122,6 +123,7 @@ static const char *const line_opt[] = {
"sidenum",
"frontside",
"backside",
"alpha",
"slopetype",
"frontsector",
"backsector",
@ -806,6 +808,9 @@ static int line_get(lua_State *L)
return 0;
LUA_PushUserdata(L, &sides[line->sidenum[1]], META_SIDE);
return 1;
case line_alpha:
lua_pushfixed(L, line->alpha);
return 1;
case line_slopetype:
switch(line->slopetype)
{

View File

@ -960,6 +960,8 @@ static void P_InitializeLinedef(line_t *ld)
ld->dx = v2->x - v1->x;
ld->dy = v2->y - v1->y;
ld->alpha = FRACUNIT;
ld->bbox[BOXLEFT] = min(v1->x, v2->x);
ld->bbox[BOXRIGHT] = max(v1->x, v2->x);
ld->bbox[BOXBOTTOM] = min(v1->y, v2->y);
@ -1461,6 +1463,8 @@ static void ParseTextmapLinedefParameter(UINT32 i, char *param, char *val)
lines[i].sidenum[0] = atol(val);
else if (fastcmp(param, "sideback"))
lines[i].sidenum[1] = atol(val);
else if (fastcmp(param, "alpha"))
lines[i].alpha = FLOAT_TO_FIXED(atof(val));
// Flags
else if (fastcmp(param, "blocking") && fastcmp("true", val))
@ -2766,6 +2770,17 @@ static void P_ConvertBinaryMap(void)
lines[i].args[1] = lines[i].tag;
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;
break;
default:
break;
}

View File

@ -423,6 +423,7 @@ typedef struct line_s
// Visual appearance: sidedefs.
UINT16 sidenum[2]; // sidenum[1] will be 0xffff if one-sided
fixed_t alpha; // translucency
fixed_t bbox[4]; // bounding box for the extent of the linedef

View File

@ -286,6 +286,28 @@ static void R_DrawFlippedMaskedSegColumn(column_t *column)
R_DrawFlippedMaskedColumn(column, column2s_length);
}
transnum_t R_GetLinedefTransTable(fixed_t alpha)
{
if (alpha < 9830)
return tr_trans90;
else if (alpha < 16384)
return tr_trans80;
else if (alpha < 22937)
return tr_trans70;
else if (alpha < 29491)
return tr_trans60;
else if (alpha < 36044)
return tr_trans50;
else if (alpha < 42598)
return tr_trans40;
else if (alpha < 49152)
return tr_trans30;
else if (alpha < 55705)
return tr_trans20;
else
return tr_trans10;
}
void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
{
size_t pindex;
@ -314,31 +336,21 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
texnum = R_GetTextureNum(curline->sidedef->midtexture);
windowbottom = windowtop = sprbotscreen = INT32_MAX;
// hack translucent linedef types (900-909 for transtables 1-9)
ldef = curline->linedef;
switch (ldef->special)
if (ldef->alpha > 0 && ldef->alpha < FRACUNIT)
{
case 900:
case 901:
case 902:
case 903:
case 904:
case 905:
case 906:
case 907:
case 908:
dc_transmap = transtables + ((ldef->special-900)<<FF_TRANSSHIFT);
colfunc = colfuncs[COLDRAWFUNC_FUZZY];
break;
case 909:
colfunc = colfuncs[COLDRAWFUNC_FOG];
windowtop = frontsector->ceilingheight;
windowbottom = frontsector->floorheight;
break;
default:
colfunc = colfuncs[BASEDRAWFUNC];
break;
dc_transmap = transtables + ((R_GetLinedefTransTable(ldef->alpha) - 1) << FF_TRANSSHIFT);
colfunc = colfuncs[COLDRAWFUNC_FUZZY];
}
else if (ldef->special == 909)
{
colfunc = colfuncs[COLDRAWFUNC_FOG];
windowtop = frontsector->ceilingheight;
windowbottom = frontsector->floorheight;
}
else
colfunc = colfuncs[BASEDRAWFUNC];
if (curline->polyseg && curline->polyseg->translucency > 0)
{

View File

@ -18,6 +18,7 @@
#pragma interface
#endif
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);