From eb5e93d62569b09b86028a739957323ec989072b Mon Sep 17 00:00:00 2001 From: sphere Date: Sat, 5 Jun 2021 13:00:23 +0200 Subject: [PATCH 1/4] Implement binary map linedef actions for all blendmode strengths anyway. --- extras/conf/SRB2-22.cfg | 186 ++++++++++++++++++++++++++++++++++++++++ src/hardware/hw_main.c | 6 +- src/p_setup.c | 19 ++-- src/r_segs.c | 8 +- 4 files changed, 201 insertions(+), 18 deletions(-) diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg index 3fd4b6ccd..465986542 100644 --- a/extras/conf/SRB2-22.cfg +++ b/extras/conf/SRB2-22.cfg @@ -3129,6 +3129,192 @@ linedeftypes title = "Fog Wall"; prefix = "(909)"; } + + 910 + { + title = "100% Additive"; + prefix = "(910)"; + } + + 911 + { + title = "90% Additive"; + prefix = "(911)"; + } + + 912 + { + title = "80% Additive"; + prefix = "(912)"; + } + + 913 + { + title = "70% Additive"; + prefix = "(913)"; + } + + 914 + { + title = "60% Additive"; + prefix = "(914)"; + } + + 915 + { + title = "50% Additive"; + prefix = "(915)"; + } + + 916 + { + title = "40% Additive"; + prefix = "(916)"; + } + + 917 + { + title = "30% Additive"; + prefix = "(917)"; + } + + 918 + { + title = "20% Additive"; + prefix = "(918)"; + } + + 919 + { + title = "10% Additive"; + prefix = "(919)"; + } + + 920 + { + title = "100% Subtractive"; + prefix = "(920)"; + } + + 921 + { + title = "90% Subtractive"; + prefix = "(921)"; + } + + 922 + { + title = "80% Subtractive"; + prefix = "(922)"; + } + + 923 + { + title = "70% Subtractive"; + prefix = "(923)"; + } + + 924 + { + title = "60% Subtractive"; + prefix = "(924)"; + } + + 925 + { + title = "50% Subtractive"; + prefix = "(925)"; + } + + 926 + { + title = "40% Subtractive"; + prefix = "(926)"; + } + + 927 + { + title = "30% Subtractive"; + prefix = "(927)"; + } + + 928 + { + title = "20% Subtractive"; + prefix = "(928)"; + } + + 929 + { + title = "10% Subtractive"; + prefix = "(929)"; + } + + 930 + { + title = "100% Reverse Subtractive"; + prefix = "(930)"; + } + + 931 + { + title = "90% Reverse Subtractive"; + prefix = "(931)"; + } + + 932 + { + title = "80% Reverse Subtractive"; + prefix = "(932)"; + } + + 933 + { + title = "70% Reverse Subtractive"; + prefix = "(933)"; + } + + 934 + { + title = "60% Reverse Subtractive"; + prefix = "(934)"; + } + + 935 + { + title = "50% Reverse Subtractive"; + prefix = "(935)"; + } + + 936 + { + title = "40% Reverse Subtractive"; + prefix = "(936)"; + } + + 937 + { + title = "30% Reverse Subtractive"; + prefix = "(937)"; + } + + 938 + { + title = "20% Reverse Subtractive"; + prefix = "(938)"; + } + + 939 + { + title = "10% Reverse Subtractive"; + prefix = "(939)"; + } + + 940 + { + title = "Modulate"; + prefix = "(940)"; + } } } diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 92e03aa80..066822e8c 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1494,11 +1494,11 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom transnum_t transtable = R_GetLinedefTransTable(gl_linedef); if (transtable == NUMTRANSMAPS) transtable = 0; - if (gl_linedef->special == 910) + if (gl_linedef->special >= 910 && gl_linedef->special <= 919) blend = AST_ADD; - else if (gl_linedef->special == 911) + else if (gl_linedef->special >= 920 && gl_linedef->special <= 929) blend = AST_SUBTRACT; - else if (gl_linedef->special == 912) + else if (gl_linedef->special >= 930 && gl_linedef->special <= 939) blend = AST_REVERSESUBTRACT; blendmode = HWR_SurfaceBlend(blend, transtable, &Surf); diff --git a/src/p_setup.c b/src/p_setup.c index ffa9444b3..0ffc807f5 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3144,21 +3144,18 @@ static void P_ConvertBinaryMap(void) lines[i].args[1] = tag; lines[i].special = 720; 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%) - lines[i].alpha = ((909 - lines[i].special) << FRACBITS)/10; - break; default: break; } + // Set alpha for translucent walls + if (lines[i].special >= 900 && lines[i].special < 909) + lines[i].alpha = ((909 - lines[i].special) << FRACBITS)/10; + + // Set alpha for additive/subtractive/reverse subtractive walls + if (lines[i].special >= 910 && lines[i].special <= 939) + lines[i].alpha = ((10 - lines[i].special % 10) << FRACBITS)/10; + //Linedef executor delay if (lines[i].special >= 400 && lines[i].special < 500) { diff --git a/src/r_segs.c b/src/r_segs.c index 10f445022..209810059 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -162,25 +162,25 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) return; transtable = R_GetLinedefTransTable(ldef); - if (ldef->special == 910) + if (ldef->special >= 910 && ldef->special <= 919) { if (transtable == NUMTRANSMAPS) transtable = 0; blendmode = AST_ADD; } - else if (ldef->special == 911) + else if (ldef->special >= 920 && ldef->special <= 929) { if (transtable == NUMTRANSMAPS) transtable = 0; blendmode = AST_SUBTRACT; } - else if (ldef->special == 912) + else if (ldef->special >= 930 && ldef->special <= 939) { if (transtable == NUMTRANSMAPS) transtable = 0; blendmode = AST_REVERSESUBTRACT; } - else if (ldef->special == 913) + else if (ldef->special == 940) { transtable = 0; blendmode = AST_MODULATE; From a4042cab4f3234a008073fa9ecd0e567913b97fc Mon Sep 17 00:00:00 2001 From: sphere Date: Sat, 5 Jun 2021 14:43:46 +0200 Subject: [PATCH 2/4] Use blend mode constants instead of hardcoded action numbers. --- src/hardware/hw_main.c | 8 ++------ src/p_setup.c | 12 ++++++++++++ src/r_defs.h | 1 + src/r_segs.c | 18 +++--------------- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 066822e8c..5171ab435 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1494,12 +1494,8 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom transnum_t transtable = R_GetLinedefTransTable(gl_linedef); if (transtable == NUMTRANSMAPS) transtable = 0; - if (gl_linedef->special >= 910 && gl_linedef->special <= 919) - blend = AST_ADD; - else if (gl_linedef->special >= 920 && gl_linedef->special <= 929) - blend = AST_SUBTRACT; - else if (gl_linedef->special >= 930 && gl_linedef->special <= 939) - blend = AST_REVERSESUBTRACT; + if (gl_linedef->blendmode == AST_ADD || gl_linedef->blendmode == AST_SUBTRACT || gl_linedef->blendmode == AST_REVERSESUBTRACT) + blend = gl_linedef->blendmode; blendmode = HWR_SurfaceBlend(blend, transtable, &Surf); break; diff --git a/src/p_setup.c b/src/p_setup.c index 0ffc807f5..744ec3c55 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3156,6 +3156,18 @@ static void P_ConvertBinaryMap(void) if (lines[i].special >= 910 && lines[i].special <= 939) lines[i].alpha = ((10 - lines[i].special % 10) << FRACBITS)/10; + if (lines[i].special >= 910 && lines[i].special <= 919) // additive + lines[i].blendmode = AST_ADD; + + if (lines[i].special >= 920 && lines[i].special <= 929) // subtractive + lines[i].blendmode = AST_SUBTRACT; + + if (lines[i].special >= 930 && lines[i].special <= 939) // reverse subtractive + lines[i].blendmode = AST_REVERSESUBTRACT; + + if (lines[i].special == 940) // modulate + lines[i].blendmode = AST_MODULATE; + //Linedef executor delay if (lines[i].special >= 400 && lines[i].special < 500) { diff --git a/src/r_defs.h b/src/r_defs.h index 681bb3619..16912fca1 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -398,6 +398,7 @@ typedef struct line_s // Visual appearance: sidedefs. UINT16 sidenum[2]; // sidenum[1] will be 0xffff if one-sided fixed_t alpha; // translucency + UINT8 blendmode; // blendmode INT32 executordelay; fixed_t bbox[4]; // bounding box for the extent of the linedef diff --git a/src/r_segs.c b/src/r_segs.c index 209810059..0b9c9a80e 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -162,25 +162,13 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) return; transtable = R_GetLinedefTransTable(ldef); - if (ldef->special >= 910 && ldef->special <= 919) + if (ldef->blendmode == AST_ADD || ldef->blendmode == AST_SUBTRACT || ldef->blendmode == AST_REVERSESUBTRACT) { if (transtable == NUMTRANSMAPS) transtable = 0; - blendmode = AST_ADD; + blendmode = ldef->blendmode; } - else if (ldef->special >= 920 && ldef->special <= 929) - { - if (transtable == NUMTRANSMAPS) - transtable = 0; - blendmode = AST_SUBTRACT; - } - else if (ldef->special >= 930 && ldef->special <= 939) - { - if (transtable == NUMTRANSMAPS) - transtable = 0; - blendmode = AST_REVERSESUBTRACT; - } - else if (ldef->special == 940) + else if (ldef->blendmode == AST_MODULATE) { transtable = 0; blendmode = AST_MODULATE; From b84199faef5fd8dc6399c02eb17a61eb2f9f5590 Mon Sep 17 00:00:00 2001 From: sphere Date: Sun, 6 Jun 2021 12:53:13 +0200 Subject: [PATCH 3/4] Simplify some code at toaster's suggestion. --- src/r_segs.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 0b9c9a80e..1e07364e0 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -162,17 +162,8 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) return; transtable = R_GetLinedefTransTable(ldef); - if (ldef->blendmode == AST_ADD || ldef->blendmode == AST_SUBTRACT || ldef->blendmode == AST_REVERSESUBTRACT) - { - if (transtable == NUMTRANSMAPS) - transtable = 0; - blendmode = ldef->blendmode; - } - else if (ldef->blendmode == AST_MODULATE) - { + if ((blendmode = ldef->blendmode) && (transtable == NUMTRANSMAPS || blendmode == AST_MODULATE)) transtable = 0; - blendmode = AST_MODULATE; - } if (transtable != NUMTRANSMAPS && (dc_transmap = R_GetBlendTable(blendmode, transtable))) { colfunc = colfuncs[COLDRAWFUNC_FUZZY]; From 109c60f700530deaaed189eb978fe903e9f7c47b Mon Sep 17 00:00:00 2001 From: sphere Date: Sun, 6 Jun 2021 14:34:49 +0200 Subject: [PATCH 4/4] Do the same for OpenGL, and also make modulate actually work in it. --- src/hardware/hw_main.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 5171ab435..d800be813 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1484,19 +1484,12 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom case 256: blendmode = PF_Translucent; break; - case 913: - blendmode = PF_Multiplicative; - Surf.PolyColor.s.alpha = 0xff; - break; default: { UINT32 blend = 0; transnum_t transtable = R_GetLinedefTransTable(gl_linedef); - if (transtable == NUMTRANSMAPS) + if ((blend = gl_linedef->blendmode) && (transtable == NUMTRANSMAPS || blendmode == AST_MODULATE)) transtable = 0; - if (gl_linedef->blendmode == AST_ADD || gl_linedef->blendmode == AST_SUBTRACT || gl_linedef->blendmode == AST_REVERSESUBTRACT) - blend = gl_linedef->blendmode; - blendmode = HWR_SurfaceBlend(blend, transtable, &Surf); break; }