From a0e6917ee829233bff8afa4b5a17f37c6dd05213 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 4 May 2013 13:23:50 -0700 Subject: [PATCH] If unspecified, default normal to 0, 0, 1. Fixes Trails in the Sky buttons and improves Kingdom Hearts lighting. --- GPU/GLES/TransformPipeline.cpp | 2 +- GPU/GLES/VertexShaderGenerator.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/GPU/GLES/TransformPipeline.cpp b/GPU/GLES/TransformPipeline.cpp index aa2a054219..881ccfeb67 100644 --- a/GPU/GLES/TransformPipeline.cpp +++ b/GPU/GLES/TransformPipeline.cpp @@ -518,7 +518,7 @@ void TransformDrawEngine::SoftwareTransformAndDraw( // We do software T&L for now float out[3], norm[3]; float pos[3], nrm[3]; - Vec3 normal(0, 0, 0); + Vec3 normal(0, 0, 1); reader.ReadPos(pos); if (reader.hasNormal()) reader.ReadNrm(nrm); diff --git a/GPU/GLES/VertexShaderGenerator.cpp b/GPU/GLES/VertexShaderGenerator.cpp index 6712c62a91..14997df488 100644 --- a/GPU/GLES/VertexShaderGenerator.cpp +++ b/GPU/GLES/VertexShaderGenerator.cpp @@ -165,8 +165,6 @@ void GenerateVertexShader(int prim, char *buffer) { int shadeLight0 = gstate.getUVGenMode() == 2 ? gstate.getUVLS0() : -1; int shadeLight1 = gstate.getUVGenMode() == 2 ? gstate.getUVLS1() : -1; for (int i = 0; i < 4; i++) { - if (!hasNormal) - continue; if (i == shadeLight0 || i == shadeLight1) doLight[i] = LIGHT_SHADE; if ((gstate.lightingEnable & 1) && (gstate.lightEnable[i] & 1)) @@ -293,10 +291,14 @@ void GenerateVertexShader(int prim, char *buffer) { WRITE(p, " vec3 worldpos = (u_world * vec4(a_position.xyz, 1.0)).xyz;\n"); if (hasNormal) WRITE(p, " vec3 worldnormal = (u_world * vec4(a_normal, 0.0)).xyz;\n"); + else + WRITE(p, " vec3 worldnormal = vec3(0.0, 0.0, 1.0);\n"); } else { WRITE(p, " vec3 worldpos = vec3(0.0);\n"); if (hasNormal) WRITE(p, " vec3 worldnormal = vec3(0.0);\n"); + else + WRITE(p, " vec3 worldnormal = vec3(0.0, 0.0, 1.0);\n"); int numWeights = 1 + ((vertType & GE_VTYPE_WEIGHTCOUNT_MASK) >> GE_VTYPE_WEIGHTCOUNT_SHIFT); static const float rescale[4] = {0, 2*127.5f/128.f, 2*32767.5f/32768.f, 2.0f};