diff --git a/engine/src/core-data/Common/MatDefs/Light/Lighting.frag b/engine/src/core-data/Common/MatDefs/Light/Lighting.frag index eac42df22..e4773c8cf 100644 --- a/engine/src/core-data/Common/MatDefs/Light/Lighting.frag +++ b/engine/src/core-data/Common/MatDefs/Light/Lighting.frag @@ -211,11 +211,14 @@ void main(){ // *********************** #if defined(NORMALMAP) && !defined(VERTEX_LIGHTING) vec4 normalHeight = texture2D(m_NormalMap, newTexCoord); - vec3 normal = normalize((normalHeight.xyz * vec3(2.0) - vec3(1.0))); + //Note the -2.0 and -1.0. We invert the green channel of the normal map, + //as it's complient with normal maps generated with blender. + //see http://hub.jmonkeyengine.org/forum/topic/parallax-mapping-fundamental-bug/#post-256898 + //for more explanation. + vec3 normal = normalize((normalHeight.xyz * vec3(2.0,-2.0,2.0) - vec3(1.0,-1.0,1.0))); #ifdef LATC normal.z = sqrt(1.0 - (normal.x * normal.x) - (normal.y * normal.y)); - #endif - //normal.y = -normal.y; + #endif #elif !defined(VERTEX_LIGHTING) vec3 normal = vNormal; #if !defined(LOW_QUALITY) && !defined(V_TANGENT) diff --git a/engine/src/core-data/Common/MatDefs/Light/Lighting.vert b/engine/src/core-data/Common/MatDefs/Light/Lighting.vert index 72323cbae..c7cb3e5db 100644 --- a/engine/src/core-data/Common/MatDefs/Light/Lighting.vert +++ b/engine/src/core-data/Common/MatDefs/Light/Lighting.vert @@ -171,7 +171,7 @@ void main(){ vec3 wvTangent = normalize(g_NormalMatrix * modelSpaceTan); vec3 wvBinormal = cross(wvNormal, wvTangent); - mat3 tbnMat = mat3(wvTangent, wvBinormal * -inTangent.w,wvNormal); + mat3 tbnMat = mat3(wvTangent, wvBinormal * inTangent.w,wvNormal); //vPosition = wvPosition * tbnMat; //vViewDir = viewDir * tbnMat;