Convert translucent walls.

This commit is contained in:
Nev3r 2019-12-16 13:01:01 +01:00
parent cae9793f52
commit e2394c1817
4 changed files with 51 additions and 50 deletions

View file

@ -1792,33 +1792,6 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
// 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:
@ -1839,7 +1812,11 @@ 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

@ -6490,6 +6490,18 @@ void P_ConvertBinaryLinedefs(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 = (FRACUNIT * (909 - lines[i].special))/10;
lines[i].special = 0;
break;
default:
break;
}

View file

@ -432,6 +432,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

@ -295,6 +295,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;
@ -322,35 +344,24 @@ 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;
if (curline->glseg)
return;
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)
{