From e6156e2adbf8c00b18b1aebf8f5ada036cd68c1d Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Wed, 12 Aug 2020 02:27:13 +1000 Subject: [PATCH] GPU/ShaderGen: Move transparent compensation to bilinear function --- src/core/gpu_hw_shadergen.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/gpu_hw_shadergen.cpp b/src/core/gpu_hw_shadergen.cpp index 6e8a556d4..118dfe51e 100644 --- a/src/core/gpu_hw_shadergen.cpp +++ b/src/core/gpu_hw_shadergen.cpp @@ -734,6 +734,10 @@ void BilinearSampleFromVRAM(uint4 texpage, float2 coords, float4 uv_limits, float2 weights = abs(texel_top_left); texcol = lerp(lerp(s00, s10, weights.x), lerp(s01, s11, weights.x), weights.y); ialpha = lerp(lerp(a00, a10, weights.x), lerp(a01, a11, weights.x), weights.y); + + // Compensate for partially transparent sampling. + if (ialpha > 0.0) + texcol.rgb /= float3(ialpha, ialpha, ialpha); } #endif @@ -793,9 +797,6 @@ void BilinearSampleFromVRAM(uint4 texpage, float2 coords, float4 uv_limits, BilinearSampleFromVRAM(v_texpage, coords, uv_limits, texcol, ialpha); if (ialpha < 0.5) discard; - - texcol.rgb /= float3(ialpha, ialpha, ialpha); - semitransparent = (texcol.a != 0.0); #else #if UV_LIMITS texcol = SampleFromVRAM(v_texpage, clamp(coords, uv_limits.xy, uv_limits.zw));