From cd8a160d8d8617c7490b57a90996a96cf2db502f Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 16 Jan 2025 23:25:23 +1000 Subject: [PATCH] GPU/HW: Clear alpha channel in opaque replacements This is the value for bit15 in the framebuffer. Silent Hill needs it to be zero, I'm not aware of anything that needs specific values yet. If it did, we'd need a different dumping technique. --- src/core/gpu_hw_shadergen.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/gpu_hw_shadergen.cpp b/src/core/gpu_hw_shadergen.cpp index 734850c688..44499bc67a 100644 --- a/src/core/gpu_hw_shadergen.cpp +++ b/src/core/gpu_hw_shadergen.cpp @@ -1880,11 +1880,14 @@ std::string GPU_HW_ShaderGen::GenerateReplacementMergeFragmentShader(bool semitr o_col0.a = (color.a <= 0.95f) ? 1.0f : 0.0f; o_col0.a = VECTOR_EQ(color, float4(0.0, 0.0, 0.0, 0.0)) ? 0.0f : o_col0.a; #else + // Map anything with an alpha below 0.5 to transparent. // Leave (0,0,0,0) as 0000 for opaque replacements for cutout alpha. - o_col0.a = color.a; + o_col0.rgb = lerp(o_col0.rgb, float3(0.0, 0.0, 0.0), float(color.a < 0.5)); - // Map anything with an alpha below 0.5 to transparent. - o_col0 = lerp(o_col0, float4(0.0, 0.0, 0.0, 0.0), float(o_col0.a < 0.5)); + // Clear alpha channel. This is the value for bit15 in the framebuffer. + // Silent Hill needs it to be zero, I'm not aware of anything that needs + // specific values yet. If it did, we'd need a different dumping technique. + o_col0.a = 0.0; #endif } )";