diff --git a/src/hwr2/pass_twodee.cpp b/src/hwr2/pass_twodee.cpp index da3e47176..e9316502f 100644 --- a/src/hwr2/pass_twodee.cpp +++ b/src/hwr2/pass_twodee.cpp @@ -287,7 +287,7 @@ static PipelineDesc make_pipeline_desc(TwodeePipelineKey key) BlendDesc blend_desc; switch (key.blend) { - case Draw2dBlend::kModulate: + case Draw2dBlend::kAlphaTransparent: blend_desc.source_factor_color = BlendFactor::kSourceAlpha; blend_desc.dest_factor_color = BlendFactor::kOneMinusSourceAlpha; blend_desc.color_function = BlendFunction::kAdd; @@ -295,6 +295,14 @@ static PipelineDesc make_pipeline_desc(TwodeePipelineKey key) blend_desc.dest_factor_alpha = BlendFactor::kOneMinusSourceAlpha; blend_desc.alpha_function = BlendFunction::kAdd; break; + case Draw2dBlend::kModulate: + blend_desc.source_factor_color = BlendFactor::kDest; + blend_desc.dest_factor_color = BlendFactor::kZero; + blend_desc.color_function = BlendFunction::kAdd; + blend_desc.source_factor_alpha = BlendFactor::kDestAlpha; + blend_desc.dest_factor_alpha = BlendFactor::kZero; + blend_desc.alpha_function = BlendFunction::kAdd; + break; case Draw2dBlend::kAdditive: blend_desc.source_factor_color = BlendFactor::kSourceAlpha; blend_desc.dest_factor_color = BlendFactor::kOne; @@ -454,21 +462,25 @@ void TwodeePass::prepass(Rhi& rhi) if (data_->pipelines.size() == 0) { + TwodeePipelineKey alpha_transparent_tris = {Draw2dBlend::kAlphaTransparent, false}; TwodeePipelineKey modulate_tris = {Draw2dBlend::kModulate, false}; TwodeePipelineKey additive_tris = {Draw2dBlend::kAdditive, false}; TwodeePipelineKey subtractive_tris = {Draw2dBlend::kSubtractive, false}; TwodeePipelineKey revsubtractive_tris = {Draw2dBlend::kReverseSubtractive, false}; TwodeePipelineKey invertdest_tris = {Draw2dBlend::kInvertDest, false}; + TwodeePipelineKey alpha_transparent_lines = {Draw2dBlend::kAlphaTransparent, true}; TwodeePipelineKey modulate_lines = {Draw2dBlend::kModulate, true}; TwodeePipelineKey additive_lines = {Draw2dBlend::kAdditive, true}; TwodeePipelineKey subtractive_lines = {Draw2dBlend::kSubtractive, true}; TwodeePipelineKey revsubtractive_lines = {Draw2dBlend::kReverseSubtractive, true}; TwodeePipelineKey invertdest_lines = {Draw2dBlend::kInvertDest, true}; + data_->pipelines.insert({alpha_transparent_tris, rhi.create_pipeline(make_pipeline_desc(alpha_transparent_tris))}); data_->pipelines.insert({modulate_tris, rhi.create_pipeline(make_pipeline_desc(modulate_tris))}); data_->pipelines.insert({additive_tris, rhi.create_pipeline(make_pipeline_desc(additive_tris))}); data_->pipelines.insert({subtractive_tris, rhi.create_pipeline(make_pipeline_desc(subtractive_tris))}); data_->pipelines.insert({revsubtractive_tris, rhi.create_pipeline(make_pipeline_desc(revsubtractive_tris))}); data_->pipelines.insert({invertdest_tris, rhi.create_pipeline(make_pipeline_desc(invertdest_tris))}); + data_->pipelines.insert({alpha_transparent_lines, rhi.create_pipeline(make_pipeline_desc(alpha_transparent_lines))}); data_->pipelines.insert({modulate_lines, rhi.create_pipeline(make_pipeline_desc(modulate_lines))}); data_->pipelines.insert({additive_lines, rhi.create_pipeline(make_pipeline_desc(additive_lines))}); data_->pipelines.insert({subtractive_lines, rhi.create_pipeline(make_pipeline_desc(subtractive_lines))}); diff --git a/src/hwr2/twodee.hpp b/src/hwr2/twodee.hpp index 10cc8e6b1..af0f60bc5 100644 --- a/src/hwr2/twodee.hpp +++ b/src/hwr2/twodee.hpp @@ -40,6 +40,7 @@ struct TwodeeVertex enum class Draw2dBlend { + kAlphaTransparent, kModulate, kAdditive, kSubtractive, @@ -80,7 +81,7 @@ struct Draw2dVertices std::size_t begin_index = 0; std::size_t begin_element = 0; std::size_t elements = 0; - Draw2dBlend blend = Draw2dBlend::kModulate; + Draw2dBlend blend = Draw2dBlend::kAlphaTransparent; lumpnum_t flat_lump = UINT32_MAX; // LUMPERROR but not loading w_wad.h from this header bool lines = false; }; diff --git a/src/v_video.cpp b/src/v_video.cpp index b9ea539bb..65bc2b2ef 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -914,7 +914,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca { falpha = (10 - alphalevel) / 10.f; } - hwr2::Draw2dBlend blend = hwr2::Draw2dBlend::kModulate; + hwr2::Draw2dBlend blend = hwr2::Draw2dBlend::kAlphaTransparent; switch (blendmode) { case AST_MODULATE: @@ -934,7 +934,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca blend = hwr2::Draw2dBlend::kSubtractive; break; default: - blend = hwr2::Draw2dBlend::kModulate; + blend = hwr2::Draw2dBlend::kAlphaTransparent; break; } @@ -1187,7 +1187,7 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) float a = 0.5f; // alphalevel is unused in GL?? g_2d.begin_quad() .rect(x, y, w, h) - .blend(hwr2::Draw2dBlend::kModulate) + .blend(hwr2::Draw2dBlend::kAlphaTransparent) .color(r, g, b, a) .done(); } @@ -1356,7 +1356,7 @@ void V_DrawFadeFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c, UINT16 color, U g = bc.green / 255.f; b = bc.blue / 255.f; a = softwaretranstohwr[std::clamp(static_cast(strength), 0, 10)] / 255.f; - blendmode = hwr2::Draw2dBlend::kModulate; + blendmode = hwr2::Draw2dBlend::kAlphaTransparent; } g_2d.begin_quad() @@ -1553,7 +1553,7 @@ void V_DrawFadeScreen(UINT16 color, UINT8 strength) g = bc.green / 255.f; b = bc.blue / 255.f; a = softwaretranstohwr[std::clamp(static_cast(strength), 0, 10)] / 255.f; - blendmode = hwr2::Draw2dBlend::kModulate; + blendmode = hwr2::Draw2dBlend::kAlphaTransparent; } g_2d.begin_quad() @@ -1629,7 +1629,7 @@ void V_DrawFadeConsBack(INT32 plines) float a = 0.5f; g_2d.begin_quad() .rect(0, 0, vid.width, plines) - .blend(hwr2::Draw2dBlend::kModulate) + .blend(hwr2::Draw2dBlend::kAlphaTransparent) .color(r, g, b, a) .done(); }