From 274b9c712cfabe37099537011ef80323a444b634 Mon Sep 17 00:00:00 2001 From: raven02 Date: Tue, 7 May 2013 16:47:53 +0800 Subject: [PATCH] Add rounding to equality check for ColorTest --- GPU/GLES/FragmentShaderGenerator.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/GPU/GLES/FragmentShaderGenerator.cpp b/GPU/GLES/FragmentShaderGenerator.cpp index fecacef681..303d6419e1 100644 --- a/GPU/GLES/FragmentShaderGenerator.cpp +++ b/GPU/GLES/FragmentShaderGenerator.cpp @@ -256,7 +256,7 @@ void GenerateFragmentShader(char *buffer) { if (alphaTestFuncs[alphaTestFunc][0] != '#') { // If it's an equality check (!=, ==, <=, >=), rounding is more likely to be important. if (alphaTestFuncs[alphaTestFunc][2] == '=') - WRITE(p, " if (round255f(v.a) %s round255f(u_alphacolorref.a)) discard;\n", alphaTestFuncs[alphaTestFunc]); + WRITE(p, " if (round255f(v.a) %s u_alphacolorref.a) discard;\n", alphaTestFuncs[alphaTestFunc]); else WRITE(p, " if (v.a %s u_alphacolorref.a) discard;\n", alphaTestFuncs[alphaTestFunc]); } @@ -271,7 +271,10 @@ void GenerateFragmentShader(char *buffer) { const char *colorTestFuncs[] = { "#", "#", " != ", " == " }; // never/always don't make sense int colorTestMask = gstate.colormask; if (colorTestFuncs[colorTestFunc][0] != '#') - WRITE(p, "if (v.rgb %s u_alphacolorref.rgb) discard;\n", colorTestFuncs[colorTestFunc]); + if (colorTestFuncs[colorTestFunc][2] == '=') + WRITE(p, "if (round255f(v.rgb) %s u_alphacolorref.rgb) discard;\n", colorTestFuncs[colorTestFunc]); + else + WRITE(p, "if (v.rgb %s u_alphacolorref.rgb) discard;\n", colorTestFuncs[colorTestFunc]); } if (enableFog) {