diff --git a/shaders/bumpdiffuse.vp b/shaders/bumpdiffuse.vp index 0892e7cc5..2f26bb6be 100644 --- a/shaders/bumpdiffuse.vp +++ b/shaders/bumpdiffuse.vp @@ -34,7 +34,7 @@ MAD R3, R1.yzxw, R2.zxyw, -R3; # Transform the light direction from object space into surface space DP3 R0.x, R2, c[16]; -DP3 R0.y, R3, c[16]; +DP3 R0.y, -R3, c[16]; DP3 R0.z, R1, c[16]; # Compress the light direction to fit in the primary color and output it MOV R5, c[40]; diff --git a/shaders/bumpdiffuse_arb.vp b/shaders/bumpdiffuse_arb.vp index b49f04178..b94827073 100644 --- a/shaders/bumpdiffuse_arb.vp +++ b/shaders/bumpdiffuse_arb.vp @@ -37,7 +37,7 @@ MAD binormal, iNormal.yzxw, t.zxyw, -binormal; # Transform the light direction from object space into surface space DP3 light_surf.x, iTangent, lightDir; -DP3 light_surf.y, binormal, lightDir; +DP3 light_surf.y, -binormal, lightDir; DP3 light_surf.z, iNormal, lightDir; # Compress the light direction to fit in the primary color and output it diff --git a/shaders/bumphaze.vp b/shaders/bumphaze.vp index e2b155314..6214dbd3b 100644 --- a/shaders/bumphaze.vp +++ b/shaders/bumphaze.vp @@ -52,7 +52,7 @@ MAD R3, R1.yzxw, R2.zxyw, -R3; # Transform the light direction from object space into surface space DP3 R0.x, R2, c[16]; -DP3 R0.y, R3, c[16]; +DP3 R0.y, -R3, c[16]; DP3 R0.z, R1, c[16]; # Compress the light direction to fit in the primary color and output it MOV R5, c[40]; diff --git a/shaders/bumphaze_arb.vp b/shaders/bumphaze_arb.vp index b6774c137..30457ef03 100644 --- a/shaders/bumphaze_arb.vp +++ b/shaders/bumphaze_arb.vp @@ -65,7 +65,7 @@ MAD binormal, iNormal.yzxw, t.zxyw, -binormal; # Transform the light direction from object space into surface space DP3 light_surf.x, iTangent, lightDir; -DP3 light_surf.y, binormal, lightDir; +DP3 light_surf.y, -binormal, lightDir; DP3 light_surf.z, iNormal, lightDir; # Compress the light direction to fit in the primary color and output it diff --git a/src/celengine/lodspheremesh.cpp b/src/celengine/lodspheremesh.cpp index 3e0ecc208..43bbe3d6a 100644 --- a/src/celengine/lodspheremesh.cpp +++ b/src/celengine/lodspheremesh.cpp @@ -574,7 +574,7 @@ void LODSphereMesh::renderSection(int phi0, int theta0, // Compute the tangent--required for bump mapping tangents[n3] = stheta; tangents[n3 + 1] = 0.0f; - tangents[n3 + 2] = ctheta; + tangents[n3 + 2] = -ctheta; n2 += 2; n3 += 3; diff --git a/src/celengine/render.cpp b/src/celengine/render.cpp index 02a904b30..3cbb47832 100644 --- a/src/celengine/render.cpp +++ b/src/celengine/render.cpp @@ -1572,6 +1572,7 @@ static void renderBumpMappedMesh(const GLContext& context, // Set up the texture transformation--the light direction and the // viewer orientation both need to be considered. glMatrixMode(GL_TEXTURE); + glScalef(-1.0f, 1.0f, 1.0f); glRotate(lightOrientation * ~orientation); glMatrixMode(GL_MODELVIEW); glx::glActiveTextureARB(GL_TEXTURE0_ARB); diff --git a/src/celengine/texture.cpp b/src/celengine/texture.cpp index 5f411aad1..f7294a1ed 100644 --- a/src/celengine/texture.cpp +++ b/src/celengine/texture.cpp @@ -741,14 +741,14 @@ void Texture::normalMap(float scale, bool wrap) int h01 = (int) pixels[(i1 * width + j0) * components]; float dx = (float) (h10 - h00) * (1.0f / 255.0f) * scale; - float dy = (float) (h00 - h01) * (1.0f / 255.0f) * scale; + float dy = (float) (h01 - h00) * (1.0f / 255.0f) * scale; float mag = (float) sqrt(dx * dx + dy * dy + 1.0f); float rmag = 1.0f / mag; int n = (i * width + j) * 4; npixels[n] = (unsigned char) (128 + 127 * dx * rmag); - npixels[n + 1] = (unsigned char) (128 - 127 * dy * rmag); + npixels[n + 1] = (unsigned char) (128 + 127 * dy * rmag); // npixels[n] = (unsigned char) (128 + 127 * dy * rmag); // npixels[n + 1] = (unsigned char) (128 - 127 * dx * rmag); // npixels[n] = (unsigned char) (128 - 127 * dx * rmag);