From 556aaa439680ab923cf80611d81785c39224f916 Mon Sep 17 00:00:00 2001 From: Nehon Date: Fri, 1 Apr 2016 22:08:20 +0200 Subject: [PATCH] Normalized the wNormal and wTangent before computing the TBN mat in the PBRLighting frag shader --- .../src/main/resources/Common/MatDefs/Light/PBRLighting.frag | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag index 5ef0be895..7377709bf 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag @@ -78,7 +78,9 @@ void main(){ vec3 viewDir = normalize(g_CameraPosition - wPosition); #if defined(NORMALMAP) || defined(PARALLAXMAP) - mat3 tbnMat = mat3(wTangent.xyz, wTangent.w * cross( (wNormal), (wTangent.xyz)), wNormal.xyz); + vec3 tan = normalize(wTangent.xyz); + vec3 norm = normalize(wNormal); + mat3 tbnMat = mat3(tan, wTangent.w * cross(norm, tan), norm.xyz); #endif #if (defined(PARALLAXMAP) || (defined(NORMALMAP_PARALLAX) && defined(NORMALMAP)))