mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
hwr2: separate Modulate and Alpha blending in 2d
This commit is contained in:
parent
35ae8f01f4
commit
df5f24e5c7
3 changed files with 21 additions and 8 deletions
|
|
@ -287,7 +287,7 @@ static PipelineDesc make_pipeline_desc(TwodeePipelineKey key)
|
||||||
BlendDesc blend_desc;
|
BlendDesc blend_desc;
|
||||||
switch (key.blend)
|
switch (key.blend)
|
||||||
{
|
{
|
||||||
case Draw2dBlend::kModulate:
|
case Draw2dBlend::kAlphaTransparent:
|
||||||
blend_desc.source_factor_color = BlendFactor::kSourceAlpha;
|
blend_desc.source_factor_color = BlendFactor::kSourceAlpha;
|
||||||
blend_desc.dest_factor_color = BlendFactor::kOneMinusSourceAlpha;
|
blend_desc.dest_factor_color = BlendFactor::kOneMinusSourceAlpha;
|
||||||
blend_desc.color_function = BlendFunction::kAdd;
|
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.dest_factor_alpha = BlendFactor::kOneMinusSourceAlpha;
|
||||||
blend_desc.alpha_function = BlendFunction::kAdd;
|
blend_desc.alpha_function = BlendFunction::kAdd;
|
||||||
break;
|
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:
|
case Draw2dBlend::kAdditive:
|
||||||
blend_desc.source_factor_color = BlendFactor::kSourceAlpha;
|
blend_desc.source_factor_color = BlendFactor::kSourceAlpha;
|
||||||
blend_desc.dest_factor_color = BlendFactor::kOne;
|
blend_desc.dest_factor_color = BlendFactor::kOne;
|
||||||
|
|
@ -454,21 +462,25 @@ void TwodeePass::prepass(Rhi& rhi)
|
||||||
|
|
||||||
if (data_->pipelines.size() == 0)
|
if (data_->pipelines.size() == 0)
|
||||||
{
|
{
|
||||||
|
TwodeePipelineKey alpha_transparent_tris = {Draw2dBlend::kAlphaTransparent, false};
|
||||||
TwodeePipelineKey modulate_tris = {Draw2dBlend::kModulate, false};
|
TwodeePipelineKey modulate_tris = {Draw2dBlend::kModulate, false};
|
||||||
TwodeePipelineKey additive_tris = {Draw2dBlend::kAdditive, false};
|
TwodeePipelineKey additive_tris = {Draw2dBlend::kAdditive, false};
|
||||||
TwodeePipelineKey subtractive_tris = {Draw2dBlend::kSubtractive, false};
|
TwodeePipelineKey subtractive_tris = {Draw2dBlend::kSubtractive, false};
|
||||||
TwodeePipelineKey revsubtractive_tris = {Draw2dBlend::kReverseSubtractive, false};
|
TwodeePipelineKey revsubtractive_tris = {Draw2dBlend::kReverseSubtractive, false};
|
||||||
TwodeePipelineKey invertdest_tris = {Draw2dBlend::kInvertDest, false};
|
TwodeePipelineKey invertdest_tris = {Draw2dBlend::kInvertDest, false};
|
||||||
|
TwodeePipelineKey alpha_transparent_lines = {Draw2dBlend::kAlphaTransparent, true};
|
||||||
TwodeePipelineKey modulate_lines = {Draw2dBlend::kModulate, true};
|
TwodeePipelineKey modulate_lines = {Draw2dBlend::kModulate, true};
|
||||||
TwodeePipelineKey additive_lines = {Draw2dBlend::kAdditive, true};
|
TwodeePipelineKey additive_lines = {Draw2dBlend::kAdditive, true};
|
||||||
TwodeePipelineKey subtractive_lines = {Draw2dBlend::kSubtractive, true};
|
TwodeePipelineKey subtractive_lines = {Draw2dBlend::kSubtractive, true};
|
||||||
TwodeePipelineKey revsubtractive_lines = {Draw2dBlend::kReverseSubtractive, true};
|
TwodeePipelineKey revsubtractive_lines = {Draw2dBlend::kReverseSubtractive, true};
|
||||||
TwodeePipelineKey invertdest_lines = {Draw2dBlend::kInvertDest, 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({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({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({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({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({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({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({additive_lines, rhi.create_pipeline(make_pipeline_desc(additive_lines))});
|
||||||
data_->pipelines.insert({subtractive_lines, rhi.create_pipeline(make_pipeline_desc(subtractive_lines))});
|
data_->pipelines.insert({subtractive_lines, rhi.create_pipeline(make_pipeline_desc(subtractive_lines))});
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ struct TwodeeVertex
|
||||||
|
|
||||||
enum class Draw2dBlend
|
enum class Draw2dBlend
|
||||||
{
|
{
|
||||||
|
kAlphaTransparent,
|
||||||
kModulate,
|
kModulate,
|
||||||
kAdditive,
|
kAdditive,
|
||||||
kSubtractive,
|
kSubtractive,
|
||||||
|
|
@ -80,7 +81,7 @@ struct Draw2dVertices
|
||||||
std::size_t begin_index = 0;
|
std::size_t begin_index = 0;
|
||||||
std::size_t begin_element = 0;
|
std::size_t begin_element = 0;
|
||||||
std::size_t elements = 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
|
lumpnum_t flat_lump = UINT32_MAX; // LUMPERROR but not loading w_wad.h from this header
|
||||||
bool lines = false;
|
bool lines = false;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -914,7 +914,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
|
||||||
{
|
{
|
||||||
falpha = (10 - alphalevel) / 10.f;
|
falpha = (10 - alphalevel) / 10.f;
|
||||||
}
|
}
|
||||||
hwr2::Draw2dBlend blend = hwr2::Draw2dBlend::kModulate;
|
hwr2::Draw2dBlend blend = hwr2::Draw2dBlend::kAlphaTransparent;
|
||||||
switch (blendmode)
|
switch (blendmode)
|
||||||
{
|
{
|
||||||
case AST_MODULATE:
|
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;
|
blend = hwr2::Draw2dBlend::kSubtractive;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
blend = hwr2::Draw2dBlend::kModulate;
|
blend = hwr2::Draw2dBlend::kAlphaTransparent;
|
||||||
break;
|
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??
|
float a = 0.5f; // alphalevel is unused in GL??
|
||||||
g_2d.begin_quad()
|
g_2d.begin_quad()
|
||||||
.rect(x, y, w, h)
|
.rect(x, y, w, h)
|
||||||
.blend(hwr2::Draw2dBlend::kModulate)
|
.blend(hwr2::Draw2dBlend::kAlphaTransparent)
|
||||||
.color(r, g, b, a)
|
.color(r, g, b, a)
|
||||||
.done();
|
.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;
|
g = bc.green / 255.f;
|
||||||
b = bc.blue / 255.f;
|
b = bc.blue / 255.f;
|
||||||
a = softwaretranstohwr[std::clamp(static_cast<int>(strength), 0, 10)] / 255.f;
|
a = softwaretranstohwr[std::clamp(static_cast<int>(strength), 0, 10)] / 255.f;
|
||||||
blendmode = hwr2::Draw2dBlend::kModulate;
|
blendmode = hwr2::Draw2dBlend::kAlphaTransparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_2d.begin_quad()
|
g_2d.begin_quad()
|
||||||
|
|
@ -1553,7 +1553,7 @@ void V_DrawFadeScreen(UINT16 color, UINT8 strength)
|
||||||
g = bc.green / 255.f;
|
g = bc.green / 255.f;
|
||||||
b = bc.blue / 255.f;
|
b = bc.blue / 255.f;
|
||||||
a = softwaretranstohwr[std::clamp(static_cast<int>(strength), 0, 10)] / 255.f;
|
a = softwaretranstohwr[std::clamp(static_cast<int>(strength), 0, 10)] / 255.f;
|
||||||
blendmode = hwr2::Draw2dBlend::kModulate;
|
blendmode = hwr2::Draw2dBlend::kAlphaTransparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_2d.begin_quad()
|
g_2d.begin_quad()
|
||||||
|
|
@ -1629,7 +1629,7 @@ void V_DrawFadeConsBack(INT32 plines)
|
||||||
float a = 0.5f;
|
float a = 0.5f;
|
||||||
g_2d.begin_quad()
|
g_2d.begin_quad()
|
||||||
.rect(0, 0, vid.width, plines)
|
.rect(0, 0, vid.width, plines)
|
||||||
.blend(hwr2::Draw2dBlend::kModulate)
|
.blend(hwr2::Draw2dBlend::kAlphaTransparent)
|
||||||
.color(r, g, b, a)
|
.color(r, g, b, a)
|
||||||
.done();
|
.done();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue