diff options
| author | Pokechu22 <Pokechu022@gmail.com> | 2022-01-24 22:48:43 -0800 |
|---|---|---|
| committer | Pokechu22 <Pokechu022@gmail.com> | 2022-02-08 15:15:15 -0800 |
| commit | 444f6fd0cb84a673329cf33eacf8907bf96b5951 (patch) | |
| tree | bbb8a34251b7369a4f39355d61dfacbbed60954e /Source | |
| parent | 0327e6acb4a4f883003fb00b04a8092a1914090a (diff) | |
Treat alpha as 0 if alpha is 1 for blending
This removes the white box in fortune street again, without causing Mario Kart Wii to regress.
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Core/VideoBackends/Software/Tev.cpp | 13 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/PixelShaderGen.cpp | 12 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/UberShaderPixel.cpp | 3 |
3 files changed, 28 insertions, 0 deletions
diff --git a/Source/Core/VideoBackends/Software/Tev.cpp b/Source/Core/VideoBackends/Software/Tev.cpp index ee0a789ec6..6905920405 100644 --- a/Source/Core/VideoBackends/Software/Tev.cpp +++ b/Source/Core/VideoBackends/Software/Tev.cpp @@ -714,6 +714,19 @@ void Tev::Draw() if (!TevAlphaTest(output[ALP_C])) return; + // Hardware testing indicates that an alpha of 1 can pass an alpha test, + // but doesn't do anything in blending + // This situation is important for Mario Kart Wii's menus (they will render incorrectly if the + // alpha test for the FMV in the background fails, since they depend on depth for drawing a yellow + // border) and Fortune Street's gameplay (where a rectangle with an alpha value of 1 is drawn over + // the center of the screen several times, but those rectangles shouldn't be visible). + // Blending seems to result in no changes to the output with an alpha of 1, even if the input + // color is white. + // TODO: Investigate this further: we might be handling blending incorrectly in general (though + // there might not be any good way of changing blending behavior) + if (output[ALP_C] == 1) + output[ALP_C] = 0; + // z texture if (bpmem.ztex2.op != ZTexOp::Disabled) { diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp index af21e64156..ddb03f8e96 100644 --- a/Source/Core/VideoCommon/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/PixelShaderGen.cpp @@ -1234,6 +1234,18 @@ ShaderCode GeneratePixelShaderCode(APIType api_type, const ShaderHostConfig& hos use_dual_source || use_shader_blend); } + // This situation is important for Mario Kart Wii's menus (they will render incorrectly if the + // alpha test for the FMV in the background fails, since they depend on depth for drawing a yellow + // border) and Fortune Street's gameplay (where a rectangle with an alpha value of 1 is drawn over + // the center of the screen several times, but those rectangles shouldn't be visible). + // Blending seems to result in no changes to the output with an alpha of 1, even if the input + // color is white. + // TODO: Investigate this further: we might be handling blending incorrectly in general (though + // there might not be any good way of changing blending behavior) + out.Write("\t// Hardware testing indicates that an alpha of 1 can pass an alpha test,\n" + "\t// but doesn't do anything in blending\n" + "\tif (prev.a == 1) prev.a = 0;\n"); + if (uid_data->zfreeze) { out.SetConstantsUsed(C_ZSLOPE, C_ZSLOPE); diff --git a/Source/Core/VideoCommon/UberShaderPixel.cpp b/Source/Core/VideoCommon/UberShaderPixel.cpp index 0ce13725d6..fa6ad7bc75 100644 --- a/Source/Core/VideoCommon/UberShaderPixel.cpp +++ b/Source/Core/VideoCommon/UberShaderPixel.cpp @@ -1032,6 +1032,9 @@ ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config, " }}\n" "\n"); + out.Write(" // Hardware testing indicates that an alpha of 1 can pass an alpha test,\n" + " // but doesn't do anything in blending\n" + " if (TevResult.a == 1) TevResult.a = 0;\n"); // ========= // Dithering // ========= |
