From 9aa1b155694840feec5c898995fce8bc83748016 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 15 Dec 2013 11:54:05 -0800 Subject: [PATCH] softgpu: Fix black objects with bilinear filtering. Dividing by 256 gives us a range of 0-253, and incorrectly gets zero for some components (guessing alpha, primarily?) in some games. Dividing by 255 has a speed hit, so a slight bias to the top left seems like a decent performance compromise (and it's a very slight bias.) --- GPU/Software/Rasterizer.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/GPU/Software/Rasterizer.cpp b/GPU/Software/Rasterizer.cpp index e26614d285..4fa96379ac 100644 --- a/GPU/Software/Rasterizer.cpp +++ b/GPU/Software/Rasterizer.cpp @@ -997,9 +997,10 @@ void DrawTriangleSlice( Vec4 texcolor_tr = Vec4::FromRGBA(SampleNearest(texlevel, u[1], v[1], tptr, bufwbits)); Vec4 texcolor_bl = Vec4::FromRGBA(SampleNearest(texlevel, u[2], v[2], tptr, bufwbits)); Vec4 texcolor_br = Vec4::FromRGBA(SampleNearest(texlevel, u[3], v[3], tptr, bufwbits)); - Vec4 t = texcolor_tl * (0xff - frac_u) + texcolor_tr * frac_u; - Vec4 b = texcolor_bl * (0xff - frac_u) + texcolor_br * frac_u; - texcolor = (t * (0xff - frac_v) + b * frac_v) / (256 * 256); + // 0x100 causes a slight bias to tl, but without it we'd have to divide by 255 * 255. + Vec4 t = texcolor_tl * (0x100 - frac_u) + texcolor_tr * frac_u; + Vec4 b = texcolor_bl * (0x100 - frac_u) + texcolor_br * frac_u; + texcolor = (t * (0x100 - frac_v) + b * frac_v) / (256 * 256); } Vec4 out = GetTextureFunctionOutput(prim_color_rgb, prim_color_a, texcolor); prim_color_rgb = out.rgb();