From 9a07c1ca8c25996e091d9f442578be4cea60db4c Mon Sep 17 00:00:00 2001 From: spherallic Date: Wed, 19 Jan 2022 10:09:57 +0100 Subject: [PATCH 1/2] Fix HUD/graphic blendmodes not working at full opacity in Software. --- src/v_video.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index 12588f9c2..49601ad78 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -539,7 +539,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca patchdrawfunc = standardpdraw; v_translevel = NULL; - if (alphalevel) + if (alphalevel || blendmode) { if (alphalevel == 10) alphalevel = hudminusalpha[st_translucency]; @@ -551,15 +551,13 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca if (alphalevel >= 10) return; // invis - if (alphalevel) - { - if (blendmode) - v_translevel = R_GetBlendTable(blendmode+1, alphalevel); - else - v_translevel = R_GetTranslucencyTable(alphalevel); + if (blendmode) + v_translevel = R_GetBlendTable(blendmode+1, alphalevel); + else if (alphalevel) + v_translevel = R_GetTranslucencyTable(alphalevel); + if (v_translevel) patchdrawfunc = translucentpdraw; - } } v_colormap = NULL; @@ -833,7 +831,7 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, IN patchdrawfunc = standardpdraw; v_translevel = NULL; - if (alphalevel) + if (alphalevel || blendmode) { if (alphalevel == 10) alphalevel = hudminusalpha[st_translucency]; @@ -845,15 +843,13 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, IN if (alphalevel >= 10) return; // invis - if (alphalevel) - { - if (blendmode) - v_translevel = R_GetBlendTable(blendmode+1, alphalevel); - else - v_translevel = R_GetTranslucencyTable(alphalevel); + if (blendmode) + v_translevel = R_GetBlendTable(blendmode+1, alphalevel); + else if (alphalevel) + v_translevel = R_GetTranslucencyTable(alphalevel); + if (v_translevel) patchdrawfunc = translucentpdraw; - } } v_colormap = NULL; From 15755ef992de4b44fc5a18d3b0e5ebf6e151c7e5 Mon Sep 17 00:00:00 2001 From: spherallic Date: Wed, 19 Jan 2022 13:17:57 +0100 Subject: [PATCH 2/2] Remove unneeded R_GetTranslucencyTable calls, add V_HUDTRANS* comments --- src/hardware/hw_draw.c | 22 ++++++++-------------- src/v_video.c | 34 +++++++++++++++------------------- 2 files changed, 23 insertions(+), 33 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index e02dbea5b..02697789e 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -347,19 +347,16 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p v[2].t = v[3].t = hwrPatch->max_t; // clip it since it is used for bunny scroll in doom I - if (blendmode) - flags = HWR_GetBlendModeFlag(blendmode+1)|PF_NoDepthTest; - else - flags = PF_Translucent|PF_NoDepthTest; + flags = HWR_GetBlendModeFlag(blendmode+1)|PF_NoDepthTest; if (alphalevel) { FSurfaceInfo Surf; Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff; - if (alphalevel == 10) Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency]; - else if (alphalevel == 11) Surf.PolyColor.s.alpha = softwaretranstogl[st_translucency]; - else if (alphalevel == 12) Surf.PolyColor.s.alpha = softwaretranstogl_hi[st_translucency]; + if (alphalevel == 10) Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency]; // V_HUDTRANSHALF + else if (alphalevel == 11) Surf.PolyColor.s.alpha = softwaretranstogl[st_translucency]; // V_HUDTRANS + else if (alphalevel == 12) Surf.PolyColor.s.alpha = softwaretranstogl_hi[st_translucency]; // V_HUDTRANSDOUBLE else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; flags |= PF_Modulated; HWD.pfnDrawPolygon(&Surf, v, 4, flags); @@ -644,19 +641,16 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, } // clip it since it is used for bunny scroll in doom I - if (blendmode) - flags = HWR_GetBlendModeFlag(blendmode+1)|PF_NoDepthTest; - else - flags = PF_Translucent|PF_NoDepthTest; + flags = HWR_GetBlendModeFlag(blendmode+1)|PF_NoDepthTest; if (alphalevel) { FSurfaceInfo Surf; Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff; - if (alphalevel == 10) Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency]; - else if (alphalevel == 11) Surf.PolyColor.s.alpha = softwaretranstogl[st_translucency]; - else if (alphalevel == 12) Surf.PolyColor.s.alpha = softwaretranstogl_hi[st_translucency]; + if (alphalevel == 10) Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency]; // V_HUDTRANSHALF + else if (alphalevel == 11) Surf.PolyColor.s.alpha = softwaretranstogl[st_translucency]; // V_HUDTRANS + else if (alphalevel == 12) Surf.PolyColor.s.alpha = softwaretranstogl_hi[st_translucency]; // V_HUDTRANSDOUBLE else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; flags |= PF_Modulated; diff --git a/src/v_video.c b/src/v_video.c index 49601ad78..4e17a4497 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -541,23 +541,21 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca v_translevel = NULL; if (alphalevel || blendmode) { - if (alphalevel == 10) + if (alphalevel == 10) // V_HUDTRANSHALF alphalevel = hudminusalpha[st_translucency]; - else if (alphalevel == 11) + else if (alphalevel == 11) // V_HUDTRANS alphalevel = 10 - st_translucency; - else if (alphalevel == 12) + else if (alphalevel == 12) // V_HUDTRANSDOUBLE alphalevel = hudplusalpha[st_translucency]; if (alphalevel >= 10) return; // invis - if (blendmode) + if (alphalevel || blendmode) + { v_translevel = R_GetBlendTable(blendmode+1, alphalevel); - else if (alphalevel) - v_translevel = R_GetTranslucencyTable(alphalevel); - - if (v_translevel) patchdrawfunc = translucentpdraw; + } } v_colormap = NULL; @@ -833,23 +831,21 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, IN v_translevel = NULL; if (alphalevel || blendmode) { - if (alphalevel == 10) + if (alphalevel == 10) // V_HUDTRANSHALF alphalevel = hudminusalpha[st_translucency]; - else if (alphalevel == 11) + else if (alphalevel == 11) // V_HUDTRANS alphalevel = 10 - st_translucency; - else if (alphalevel == 12) + else if (alphalevel == 12) // V_HUDTRANSDOUBLE alphalevel = hudplusalpha[st_translucency]; if (alphalevel >= 10) return; // invis - if (blendmode) + if (alphalevel || blendmode) + { v_translevel = R_GetBlendTable(blendmode+1, alphalevel); - else if (alphalevel) - v_translevel = R_GetTranslucencyTable(alphalevel); - - if (v_translevel) patchdrawfunc = translucentpdraw; + } } v_colormap = NULL; @@ -1406,11 +1402,11 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) if ((alphalevel = ((c & V_ALPHAMASK) >> V_ALPHASHIFT))) { - if (alphalevel == 10) + if (alphalevel == 10) // V_HUDTRANSHALF alphalevel = hudminusalpha[st_translucency]; - else if (alphalevel == 11) + else if (alphalevel == 11) // V_HUDTRANS alphalevel = 10 - st_translucency; - else if (alphalevel == 12) + else if (alphalevel == 12) // V_HUDTRANSDOUBLE alphalevel = hudplusalpha[st_translucency]; if (alphalevel >= 10)