Add line and FOF blending, fix model and shadow blending

also a bit of cleanup in r_things but it's too minor to headline
This commit is contained in:
Alug committed 2025-02-03 18:00:04 +01:00
1 parent 3e563df999
commit 73dc9a794f
10 files changed
+138 -87

No files matched your search

+35 -16
View File
@@ -1279,10 +1279,20 @@ static inline boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf)
case 195:
case 221:
case 253 ... 256:
blendmode = PF_Translucent;
if (gl_linedef->blendmode)
blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), pSurf);
else
blendmode = PF_Translucent;
break;
default:
if (gl_linedef->alpha > 0 && gl_linedef->alpha < FRACUNIT)
if (gl_linedef->blendmode)
{
if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT)
blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), pSurf);
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), pSurf);
else
blendmode = PF_Masked;
@@ -1834,7 +1844,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope);
if (gl_frontsector->numlights)
{
HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, noencore, &Surf, FF_CUTLEVEL, NULL, 0);
}
else // I don't think that solid walls can use translucent linedef types...
{
if (glTex->mipmap.flags & TF_TRANSPARENT)
@@ -2015,7 +2027,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gl_curline);
if (gl_frontsector->numlights)
HWR_SplitWall(gl_frontsector, wallVerts, 0, false, &Surf, rover->flags, rover, 0);
HWR_SplitWall(gl_frontsector, wallVerts, 0, false, &Surf, rover->flags, rover, blendmode);
else
HWR_AddTransparentWall(wallVerts, &Surf, 0, false, blendmode, true, lightnum, colormap);
}
@@ -2023,14 +2035,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
{
FBITFIELD blendmode = PF_Masked;
if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256)
if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend)
{
blendmode = PF_Translucent;
blendmode = rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent;
Surf.PolyColor.s.alpha = CLAMP(rover->alpha, 0, 255);
}
if (gl_frontsector->numlights)
HWR_SplitWall(gl_frontsector, wallVerts, texnum, noencore, &Surf, rover->flags, rover, 0);
HWR_SplitWall(gl_frontsector, wallVerts, texnum, noencore, &Surf, rover->flags, rover, blendmode);
else
{
if (blendmode != PF_Masked)
@@ -2130,7 +2142,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gl_curline);
if (gl_backsector->numlights)
HWR_SplitWall(gl_backsector, wallVerts, 0, false, &Surf, rover->flags, rover, 0);
HWR_SplitWall(gl_backsector, wallVerts, 0, false, &Surf, rover->flags, rover, blendmode);
else
HWR_AddTransparentWall(wallVerts, &Surf, 0, false, blendmode, true, lightnum, colormap);
}
@@ -2138,14 +2150,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
{
FBITFIELD blendmode = PF_Masked;
if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256)
if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend)
{
blendmode = PF_Translucent;
blendmode = rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent;
Surf.PolyColor.s.alpha = CLAMP(rover->alpha, 0, 255);
}
if (gl_backsector->numlights)
HWR_SplitWall(gl_backsector, wallVerts, texnum, noencore, &Surf, rover->flags, rover, 0);
HWR_SplitWall(gl_backsector, wallVerts, texnum, noencore, &Surf, rover->flags, rover, blendmode);
else
{
if (blendmode != PF_Masked)
@@ -2822,6 +2834,13 @@ static boolean HWR_DoCulling(line_t *cullheight, line_t *viewcullheight, float v
return false;
}
static FBITFIELD HWR_RippleBlend(sector_t *sector, ffloor_t *rover, boolean ceiling)
{
(void)sector;
(void)ceiling;
return /*R_IsRipplePlane(sector, rover, ceiling)*/ (rover->flags & FF_RIPPLE) ? PF_Ripple : 0;
}
// -----------------+
// HWR_Subsector : Determine floor/ceiling planes.
// : Add sprites of things in sector.
@@ -3010,7 +3029,7 @@ static void HWR_Subsector(size_t num)
alpha, rover->master->frontsector, PF_Fog|PF_NoTexture,
true, rover->master->frontsector->extra_colormap);
}
else if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) // SoM: Flags are more efficient
else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) // SoM: Flags are more efficient
{
light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < bottomCullHeight ? true : false);
@@ -3019,7 +3038,7 @@ static void HWR_Subsector(size_t num)
false,
*rover->bottomheight,
*gl_frontsector->lightlist[light].lightlevel,
CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent,
CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent),
false, gl_frontsector->lightlist[light].extra_colormap);
}
else
@@ -3027,7 +3046,7 @@ static void HWR_Subsector(size_t num)
HWR_GetFlat(levelflats[*rover->bottompic].lumpnum, R_NoEncore(gl_frontsector, false));
light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < bottomCullHeight ? true : false);
HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, levelflats[*rover->bottompic].lumpnum,
HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, levelflats[*rover->bottompic].lumpnum,
rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap);
}
}
@@ -3056,7 +3075,7 @@ static void HWR_Subsector(size_t num)
alpha, rover->master->frontsector, PF_Fog|PF_NoTexture,
true, rover->master->frontsector->extra_colormap);
}
else if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256)
else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend)
{
light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < topCullHeight ? true : false);
@@ -3065,7 +3084,7 @@ static void HWR_Subsector(size_t num)
true,
*rover->topheight,
*gl_frontsector->lightlist[light].lightlevel,
CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent,
CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent),
false, gl_frontsector->lightlist[light].extra_colormap);
}
else
@@ -3073,7 +3092,7 @@ static void HWR_Subsector(size_t num)
HWR_GetFlat(levelflats[*rover->toppic].lumpnum, R_NoEncore(gl_frontsector, true));
light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < topCullHeight ? true : false);
HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum,
HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum,
rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap);
}
}
+13 -4
View File
@@ -1179,21 +1179,30 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
// Apparently people don't like jump frames like that, so back it goes
//if (tics > durs)
//durs = tics;
INT32 blendmode;
if (spr->mobj->frame & FF_BLENDMASK)
blendmode = ((spr->mobj->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1;
else
blendmode = spr->mobj->blendmode;
blendmode = min(AST_MODULATE, blendmode);
if (spr->mobj->flags2 & MF2_SHADOW)
{
Surf.PolyColor.s.alpha = 0x40;
Surf.PolyFlags = HWR_GetBlendModeFlag(spr->mobj->blendmode);
Surf.PolyFlags = HWR_GetBlendModeFlag(blendmode);
}
else if (spr->mobj->frame & FF_TRANSMASK)
{
HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf);
Surf.PolyFlags = HWR_SurfaceBlend(spr->mobj->blendmode, (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf);
Surf.PolyFlags = HWR_SurfaceBlend(blendmode, (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf);
}
else
{
Surf.PolyColor.s.alpha = 0xFF;
Surf.PolyFlags = 0;
// this hack is dumb, but the blendmodes refuse to work otherwise
Surf.PolyColor.s.alpha = (blendmode == AST_TRANSLUCENT) ? 0xFF : 0xFE;
Surf.PolyFlags = HWR_GetBlendModeFlag(blendmode);
}
// dont forget to enabled the depth test because we can't do this like
+8
View File
@@ -188,6 +188,7 @@ enum ffloor_e {
ffloor_next,
ffloor_prev,
ffloor_alpha,
ffloor_blend,
};
static const char *const ffloor_opt[] = {
@@ -206,6 +207,7 @@ static const char *const ffloor_opt[] = {
"next",
"prev",
"alpha",
"blend",
NULL};
static int ffloor_fields_ref = LUA_NOREF;
@@ -1172,6 +1174,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;
}
@@ -1250,6 +1255,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;
}
+1
View File
@@ -10017,6 +10017,7 @@ mobj_t *P_SpawnShadowMobj(mobj_t * caster)
mobj->radius = info->radius;
mobj->height = info->height;
mobj->flags = info->flags;
mobj->blendmode = AST_TRANSLUCENT;
mobj->health = info->spawnhealth;
+25 -13
View File
@@ -1197,6 +1197,7 @@ static void P_SetupLines(void)
ld->dy = v2->y - v1->y;
ld->alpha = FRACUNIT;
ld->blendmode = 0;
if (!ld->dx)
ld->slopetype = ST_VERTICAL;
@@ -1304,18 +1305,27 @@ static void P_LoadLineDefs2(void)
M_Memcpy(ld->text+strlen(ld->text)+1, sides[ld->sidenum[1]].text, strlen(sides[ld->sidenum[1]].text)+1);
}
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%)
ld->alpha = ((909 - ld->special) << FRACBITS)/10;
break;
}
// Set alpha for translucent walls
if (ld->special >= 900 && ld->special < 909)
ld->alpha = ((909 - ld->special) << FRACBITS)/10;
// Set alpha for additive/subtractive/reverse subtractive walls
if (ld->special >= 910 && ld->special <= 939)
ld->alpha = ((10 - ld->special % 10) << FRACBITS)/10;
if (ld->special >= 910 && ld->special <= 919) // additive
ld->blendmode = AST_ADD;
if (ld->special >= 920 && ld->special <= 929) // subtractive
ld->blendmode = AST_SUBTRACT;
if (ld->special >= 930 && ld->special <= 939) // reverse subtractive
ld->blendmode = AST_REVERSESUBTRACT;
if (ld->special == 940) // modulate
ld->blendmode = AST_MODULATE;
}
}
@@ -1594,8 +1604,10 @@ static void P_LoadRawSideDefs2(void *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->midtexture = R_TextureNumForName(msd->midtexture);
}
else
+20 -2
View File
@@ -4746,16 +4746,34 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f
else th = th->next;
}
if (flags & FF_TRANSLUCENT)
{
if (sides[master->sidenum[0]].toptexture > 0)
ffloor->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
ffloor->alpha = sides[master->sidenum[0]].toptexture;
if (ffloor->alpha >= 1001) // fourth digit
{
ffloor->blend = (ffloor->alpha/1000)+1; // becomes an AST
ffloor->alpha %= 1000;
}
else
{
ffloor->blend = 0;
}
}
else
{
ffloor->alpha = 0x80;
ffloor->blend = 0;
}
}
else
{
ffloor->alpha = 0xff;
ffloor->blend = 0;
}
ffloor->spawnalpha = ffloor->alpha; // save for netgames
+1
View File
@@ -172,6 +172,7 @@ typedef struct ffloor_s
INT32 lastlight;
INT32 alpha;
UINT8 blend; // blendmode
tic_t norender; // for culling
// these are saved for netgames, so do not let Lua touch these!
+11 -22
View File
@@ -842,28 +842,17 @@ void R_DrawSinglePlane(visplane_t *pl)
spanfunc = R_DrawTranslucentSpan_8;
// Hacked up support for alpha value in software mode Tails 09-24-2002
if (pl->ffloor->alpha < 12)
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 // Opaque, but allow transparent flat pixels
spanfunc = splatfunc;
// ...unhacked by toaster 04-01-2021, re-hacked a little by sphere 19-11-2021
// and mercilessly shoved into saturn by chearii 02-02-2025
{
INT32 trans = (10*((256+12) - pl->ffloor->alpha))/255;
if (trans >= 10)
return; // Don't even draw it
if (pl->ffloor->blend) // additive, (reverse) subtractive, modulative
ds_transmap = R_GetBlendTable(pl->ffloor->blend, trans);
else if (!(ds_transmap = R_GetTranslucencyTable(trans)) || trans == 0)
spanfunc = splatfunc; // Opaque, but allow transparent flat pixels
}
#ifdef SHITPLANESPARENCY
if (spanfunc == splatfunc || (pl->extra_colormap && pl->extra_colormap->fog))
+24 -23
View File
@@ -337,7 +337,19 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
// hack translucent linedef types (900-909 for transtables 1-9)
ldef = curline->linedef;
if (ldef->alpha > 0 && ldef->alpha < FRACUNIT)
if (!ldef->alpha)
return;
if (ldef->blendmode)
{
if (ldef->alpha == NUMTRANSMAPS || ldef->blendmode == AST_MODULATE)
dc_transmap = R_GetBlendTable(ldef->blendmode, 0);
else
dc_transmap = R_GetBlendTable(ldef->blendmode, R_GetLinedefTransTable(ldef->alpha));
colfunc = fuzzcolfunc;
}
else if (ldef->alpha > 0 && ldef->alpha < FRACUNIT)
{
dc_transmap = transtables + ((R_GetLinedefTransTable(ldef->alpha) - 1) << FF_TRANSSHIFT);
colfunc = fuzzcolfunc;
@@ -726,28 +738,17 @@ 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)
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
fuzzy = false; // Opaque
// ...unhacked by toaster 04-01-2021, re-hacked a little by sphere 19-11-2021
// and mercilessly shoved into saturn by chearii 02-02-2025
{
INT32 trans = (10*((256+12) - pfloor->alpha))/255;
if (trans >= 10)
return; // Don't even draw it
if (pfloor->blend) // additive, (reverse) subtractive, modulative
dc_transmap = R_GetBlendTable(pfloor->blend, trans);
else if (!(dc_transmap = R_GetTranslucencyTable(trans)) || trans == 0)
fuzzy = false; // Opaque
}
if (fuzzy)
colfunc = fuzzcolfunc;
-7
View File
@@ -1864,7 +1864,6 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
fixed_t this_scale;
INT32 dist = 1;
INT32 trans;
if (!thing || thing->subsector == NULL)
return;
@@ -1968,12 +1967,6 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
return;
}
// Determine the translucency value.
if (thing->frame & FF_TRANSMASK)
trans = (thing->frame & FF_TRANSMASK) >> FF_TRANSSHIFT;
else
trans = 0;
//SoM: 3/17/2000: Disregard sprites that are out of view..
gzt = interp.z + FixedMul(spritecachedinfo[lump].topoffset, this_scale);
gz = gzt - FixedMul(spritecachedinfo[lump].height, this_scale);