From f7739ccdc29fcdae669142b72efe9939b90c52f2 Mon Sep 17 00:00:00 2001 From: BeaR Date: Mon, 15 Apr 2013 19:09:26 +0200 Subject: [PATCH] Apply attenuation to ambient light --- GPU/GLES/TransformPipeline.cpp | 4 ++-- GPU/GLES/VertexShaderGenerator.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/GPU/GLES/TransformPipeline.cpp b/GPU/GLES/TransformPipeline.cpp index afe139ec46..f3aae9f272 100644 --- a/GPU/GLES/TransformPipeline.cpp +++ b/GPU/GLES/TransformPipeline.cpp @@ -325,7 +325,7 @@ void Lighter::Light(float colorOut0[4], float colorOut1[4], const float colorIn[ } Color4 lightDiff(gstate_c.lightColor[1][l], 0.0f); - Color4 diff = (lightDiff * *diffuse) * (dot * lightScale); + Color4 diff = (lightDiff * *diffuse) * dot; // Real PSP specular Vec3 toViewer(0,0,1); @@ -348,7 +348,7 @@ void Lighter::Light(float colorOut0[4], float colorOut1[4], const float colorIn[ if (gstate.lightEnable[l] & 1) { Color4 lightAmbient(gstate_c.lightColor[0][l], 0.0f); - lightSum0 += lightAmbient + diff; + lightSum0 += (lightAmbient + diff) * lightScale; } } diff --git a/GPU/GLES/VertexShaderGenerator.cpp b/GPU/GLES/VertexShaderGenerator.cpp index d2150e953b..e384112c62 100644 --- a/GPU/GLES/VertexShaderGenerator.cpp +++ b/GPU/GLES/VertexShaderGenerator.cpp @@ -361,14 +361,14 @@ void GenerateVertexShader(int prim, char *buffer) { break; } - WRITE(p, " vec3 diffuse%i = (u_lightdiffuse%i * %s) * (max(dot%i, 0.0) * lightScale%i);\n", i, i, diffuse, i, i); + WRITE(p, " vec3 diffuse%i = (u_lightdiffuse%i * %s) * max(dot%i, 0.0);\n", i, i, diffuse, i); if (doSpecular) { WRITE(p, " vec3 halfVec%i = normalize(normalize(toLight%i) + vec3(0.0, 0.0, 1.0));\n", i, i); WRITE(p, " dot%i = dot(halfVec%i, worldnormal);\n", i, i); WRITE(p, " if (dot%i > 0.0)\n", i); WRITE(p, " lightSum1 += u_lightspecular%i * %s * (pow(dot%i, u_matspecular.a) * (dot%i * lightScale%i));\n", i, specular, i, i, i); } - WRITE(p, " lightSum0 += vec4(u_lightambient%i + diffuse%i, 0.0);\n", i, i); + WRITE(p, " lightSum0 += vec4((u_lightambient%i + diffuse%i)*lightScale%i, 0.0);\n", i, i, i); } if (gstate.isLightingEnabled()) {