From 0c46d593d8291f3affa1d1416facc07b59241c95 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jan 2024 18:55:19 +0100 Subject: [PATCH] attempt at making colormapped translucent fofs more accurate --- src/hardware/hw_main.c | 68 +++++++++++++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 10 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index d1c01a146..7d4dcc0bd 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3619,20 +3619,68 @@ void HWR_Subsector(size_t num) else if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) { light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < cullHeight ? true : false); - HWR_AddTransparentFloor(levelflats[*rover->toppic].lumpnum, - &extrasubsectors[num], - true, - *rover->topheight, - *gr_frontsector->lightlist[light].lightlevel, - max(0, min(rover->alpha, 255)), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, - false, gr_frontsector->lightlist[light].extra_colormap); + + if(gr_frontsector->lightlist[light].extra_colormap) + { + UINT8 alpha; + + alpha = HWR_FogBlockAlpha(*gr_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); + + HWR_AddTransparentFloor(0, + &extrasubsectors[num], + true, + *rover->topheight-1, //dumbass z-fight fix + *gr_frontsector->lightlist[light].lightlevel, + alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, + true, rover->master->frontsector->extra_colormap); + + HWR_AddTransparentFloor(levelflats[*rover->toppic].lumpnum, + &extrasubsectors[num], + true, + *rover->topheight, + *gr_frontsector->lightlist[light].lightlevel, + max(0, min(rover->alpha, 255)), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, + false, gr_frontsector->lightlist[light].extra_colormap); + } + else + { + HWR_AddTransparentFloor(levelflats[*rover->toppic].lumpnum, + &extrasubsectors[num], + true, + *rover->topheight, + *gr_frontsector->lightlist[light].lightlevel, + max(0, min(rover->alpha, 255)), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, + false, gr_frontsector->lightlist[light].extra_colormap); + } } else { - HWR_GetFlat(levelflats[*rover->toppic].lumpnum, R_NoEncore(gr_frontsector, true)); light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < cullHeight ? true : false); - HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum, - rover->master->frontsector, 255, gr_frontsector->lightlist[light].extra_colormap); + + if(gr_frontsector->lightlist[light].extra_colormap) + { + UINT8 alpha; + + alpha = HWR_FogBlockAlpha(*gr_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); + + HWR_AddTransparentFloor(0, + &extrasubsectors[num], + true, + *rover->topheight-1, //dumbass z-fight fix + *gr_frontsector->lightlist[light].lightlevel, + alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, + true, rover->master->frontsector->extra_colormap); + + HWR_GetFlat(levelflats[*rover->toppic].lumpnum, R_NoEncore(gr_frontsector, true)); + HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum, + rover->master->frontsector, 255, gr_frontsector->lightlist[light].extra_colormap); + } + else + { + HWR_GetFlat(levelflats[*rover->toppic].lumpnum, R_NoEncore(gr_frontsector, true)); + HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum, + rover->master->frontsector, 255, gr_frontsector->lightlist[light].extra_colormap); + } } } }