diff --git a/Source/Core/Common/Src/LinearDiskCache.cpp b/Source/Core/Common/Src/LinearDiskCache.cpp index b7273d4935..7e2d1b2e4d 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 = 6103; +const int version = 6123; LinearDiskCache::LinearDiskCache() : file_(NULL), num_entries_(0) { diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp index 4efeecd123..594b2b7d2b 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp @@ -112,7 +112,8 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type) WRITE(p, "struct VS_OUTPUT {\n"); WRITE(p, " float4 pos : POSITION;\n"); - WRITE(p, " float4 colors[2] : COLOR0;\n"); + WRITE(p, " float4 colors_0 : COLOR0;\n"); + WRITE(p, " float4 colors_1 : COLOR1;\n"); if (xfregs.numTexGens < 7) { for (int i = 0; i < xfregs.numTexGens; ++i) @@ -224,20 +225,26 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type) "float3 ldir, h;\n" "float dist, dist2, attn;\n"); + if(xfregs.nNumChans == 0) + { + if (components & VB_HAS_COL0) + WRITE(p, "o.colors_0 = color0;\n"); + else + WRITE(p, "o.colors_0 = float4(1.0f, 1.0f, 1.0f, 1.0f);\n"); + } // lights/colors for (int j = 0; j < xfregs.nNumChans; j++) { - - // bool bColorAlphaSame = xfregs.colChans[j].color.hex == xfregs.colChans[j].alpha.hex; unused const LitChannel& color = xfregs.colChans[j].color; const LitChannel& alpha = xfregs.colChans[j].alpha; WRITE(p, "{\n"); - WRITE(p, "lacc = float4(1.0f, 1.0f, 1.0f, 1.0f);\n"); if (color.matsource) {// from vertex if (components & (VB_HAS_COL0 << j)) WRITE(p, "mat = color%d;\n", j); + else if (components & VB_HAS_COL0) + WRITE(p, "mat = color0;\n", j); else WRITE(p, "mat = float4(1.0f, 1.0f, 1.0f, 1.0f);\n"); } @@ -248,35 +255,50 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type) if (color.ambsource) { // from vertex if (components & (VB_HAS_COL0< 0.0f) ? max(0.0f, dot(_norm0, "I_LIGHTS".lights[%d].dir.xyz)) : 0.0f;\n", index, index); - WRITE(p, "ldir = float3(1,attn,attn*attn);\n"); - WRITE(p, "attn = max(0.0f, dot("I_LIGHTS".lights[%d].cosatt.xyz, ldir)) / dot("I_LIGHTS".lights[%d].distatt.xyz, ldir);\n", index, index); + else if (chan.attnfunc == 1) + { // specular + WRITE(p, "ldir = normalize("I_LIGHTS".lights[%d].pos.xyz);\n",index); + WRITE(p, "attn = (dot(_norm0,ldir) > 0.0f) ? max(0.0f, dot(_norm0, "I_LIGHTS".lights[%d].dir.xyz)) : 0.0f;\n", index, index); + WRITE(p, "attn = max(0.0f, dot("I_LIGHTS".lights[%d].cosatt.xyz, float3(1,attn,attn*attn))) / dot("I_LIGHTS".lights[%d].distatt.xyz, float3(1,attn,attn*attn));\n", index, index); } switch (chan.diffusefunc) @@ -538,13 +549,15 @@ char *GenerateLightShader(char *p, int index, const LitChannel& chan, const char case LIGHTDIF_SIGN: case LIGHTDIF_CLAMP: WRITE(p, "%s.%s += attn * %sdot(ldir, _norm0)) * "I_LIGHTS".lights[%d].col.%s;\n", - dest, swizzle, chan.diffusefunc != LIGHTDIF_SIGN ? "max(0.0f," :"(", index, swizzle); + dest, + swizzle, + chan.diffusefunc != LIGHTDIF_SIGN ? "max(0.0f," :"(", + index, + swizzle); break; default: _assert_(0); } } - WRITE(p, "\n"); - - setlocale(LC_NUMERIC, ""); // restore locale + WRITE(p, "\n"); return p; }