From fb1c14e2ccd147a17ebaac2d162ce063cd0ca756 Mon Sep 17 00:00:00 2001 From: Rodolfo Osvaldo Bogado Date: Mon, 16 Aug 2010 22:37:04 +0000 Subject: [PATCH] long time no commits :). fixed one of the last graphic problems in smg, now the glow in the plants and planets must be correct. the error was caused by a error in lighting calculations. so it must affect other games. please test and let me know the results. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6103 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/LinearDiskCache.cpp | 2 +- .../Core/VideoCommon/Src/PixelShaderGen.cpp | 46 +++++++++++++------ .../Core/VideoCommon/Src/VertexShaderGen.cpp | 7 +-- 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/Source/Core/Common/Src/LinearDiskCache.cpp b/Source/Core/Common/Src/LinearDiskCache.cpp index cc0f18e48c..b7273d4935 100644 --- a/Source/Core/Common/Src/LinearDiskCache.cpp +++ b/Source/Core/Common/Src/LinearDiskCache.cpp @@ -22,7 +22,7 @@ static const char ID[4] = {'D', 'C', 'A', 'C'}; // Update this to the current SVN revision every time you change shader generation code. // We don't automatically get this from SVN_REV because that would mean regenerating the // shader cache for every revision, graphics-related or not, which is simply annoying. -const int version = 6078; +const int version = 6103; LinearDiskCache::LinearDiskCache() : file_(NULL), num_entries_(0) { diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index 1c5a615f8e..3460fde927 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -275,11 +275,11 @@ static const char *tevCInputTable[] = // CC "(cc2.aaa)", // A2, "(textemp.rgb)", // TEXC, "(textemp.aaa)", // TEXA, - "(rastemp.rgb)", // RASC, - "(rastemp.aaa)", // RASA, + "(crastemp.rgb)", // RASC, + "(crastemp.aaa)", // RASA, "float3(1.0f, 1.0f, 1.0f)", // ONE "float3(0.5f, 0.5f, 0.5f)", // HALF - "(konsttemp.rgb)", //"konsttemp.rgb", // KONST + "(ckonsttemp.rgb)", //"konsttemp.rgb", // KONST "float3(0.0f, 0.0f, 0.0f)", // ZERO "PADERROR", "PADERROR", "PADERROR", "PADERROR" }; @@ -300,8 +300,8 @@ static const char *tevAInputTable[] = // CA "cc1", // A1, "cc2", // A2, "textemp", // TEXA, - "rastemp", // RASA, - "konsttemp", // KONST, (hw1 had quarter) + "crastemp", // RASA, + "ckonsttemp", // KONST, (hw1 had quarter) "float4(0.0f, 0.0f, 0.0f, 0.0f)", // ZERO "PADERROR", "PADERROR", "PADERROR", "PADERROR", "PADERROR", "PADERROR", "PADERROR", "PADERROR", @@ -487,7 +487,7 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_T " float4 alphabump=0;\n" " float3 tevcoord;\n" " float2 wrappedcoord, tempcoord;\n" - " float4 cc0, cc1, cc2, cprev;\n\n"); + " float4 cc0, cc1, cc2, cprev,crastemp,ckonsttemp;\n\n"); // HACK to handle cases where the tex gen is not enabled if (numTexgen == 0) @@ -739,7 +739,18 @@ static void WriteStage(char *&p, int n, u32 texture_mask, API_TYPE ApiType) WRITE(p, "tevcoord.xy = wrappedcoord + indtevtrans%d;\n", n); } - WRITE(p, "rastemp = %s.%s;\n", tevRasTable[bpmem.tevorders[n / 2].getColorChan(n & 1)], rasswap); + TevStageCombiner::ColorCombiner &cc = bpmem.combiners[n].colorC; + TevStageCombiner::AlphaCombiner &ac = bpmem.combiners[n].alphaC; + + bool bCRas = cc.a == TEVCOLORARG_RASA || cc.a == TEVCOLORARG_RASC || cc.b == TEVCOLORARG_RASA || cc.b == TEVCOLORARG_RASC || cc.c == TEVCOLORARG_RASA || cc.c == TEVCOLORARG_RASC || cc.d == TEVCOLORARG_RASA || cc.d == TEVCOLORARG_RASC; + bool bARas = ac.a == TEVALPHAARG_RASA || ac.b == TEVALPHAARG_RASA || ac.c == TEVALPHAARG_RASA || ac.d == TEVALPHAARG_RASA; + + if(bCRas || bARas) + { + WRITE(p, "rastemp = %s.%s;\n", tevRasTable[bpmem.tevorders[n / 2].getColorChan(n & 1)], rasswap); + WRITE(p, "crastemp = frac(4.0f + rastemp * (255.0f/256.0f)) * (256.0f/255.0f);\n"); + } + if (bpmem.tevorders[n/2].getEnable(n&1)) { @@ -761,13 +772,22 @@ static void WriteStage(char *&p, int n, u32 texture_mask, API_TYPE ApiType) int kc = bpmem.tevksel[n / 2].getKC(n & 1); int ka = bpmem.tevksel[n / 2].getKA(n & 1); - TevStageCombiner::ColorCombiner &cc = bpmem.combiners[n].colorC; - TevStageCombiner::AlphaCombiner &ac = bpmem.combiners[n].alphaC; + bool bCKonst = cc.a == TEVCOLORARG_KONST || cc.b == TEVCOLORARG_KONST || cc.c == TEVCOLORARG_KONST || cc.d == TEVCOLORARG_KONST; bool bAKonst = ac.a == TEVALPHAARG_KONST || ac.b == TEVALPHAARG_KONST || ac.c == TEVALPHAARG_KONST || ac.d == TEVALPHAARG_KONST; if (bCKonst || bAKonst ) + { WRITE(p, "konsttemp = float4(%s, %s);\n", tevKSelTableC[kc], tevKSelTableA[ka]); + if(kc > 12 || ka > 15) + { + WRITE(p, "ckonsttemp = frac(4.0f + konsttemp * (255.0f/256.0f)) * (256.0f/255.0f);\n"); + } + else + { + WRITE(p, "ckonsttemp = konsttemp;\n"); + } + } if(cc.a == TEVCOLORARG_CPREV || cc.a == TEVCOLORARG_APREV @@ -1067,10 +1087,10 @@ static const char *tevFogFuncsTable[] = "", //? "", //Linear "", //? - " fog = 1.0f - pow(2, -8.0f * fog);\n", //exp - " fog = 1.0f - pow(2, -8.0f * fog * fog);\n", //exp2 - " fog = pow(2, -8.0f * (1.0f - fog));\n", //backward exp - " fog = 1.0f - fog;\n fog = pow(2, -8.0f * fog * fog);\n" //backward exp2 + " fog = 1.0f - pow(2.0f, -8.0f * fog);\n", //exp + " fog = 1.0f - pow(2.0f, -8.0f * fog * fog);\n", //exp2 + " fog = pow(2.0f, -8.0f * (1.0f - fog));\n", //backward exp + " fog = 1.0f - fog;\n fog = pow(2.0f, -8.0f * fog * fog);\n" //backward exp2 }; static void WriteFog(char *&p) diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp index dfda6c1673..4efeecd123 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp @@ -260,18 +260,19 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type) if (alpha.matsource) {// from vertex if (components & (VB_HAS_COL0<