Selaa lähdekoodia

Merge pull request #2348 from jMonkeyEngine/yaRnMcDonuts-patch-3

Add tbnMat variable to PBRSurface.glsl
Ryan McDonough 7 kuukautta sitten
vanhempi
commit
7aad158b99

+ 2 - 1
jme3-core/src/main/resources/Common/ShaderLib/module/PBRSurface.glsl

@@ -10,6 +10,7 @@
         vec3 normal; // normals w/ normalmap
         bool frontFacing; //gl_FrontFacing
         float depth;
+        mat3 tbnMat;
 
         // from texture
         vec3 albedo;
@@ -36,4 +37,4 @@
     #endstruct
     #define PBRSurface StdPBRSurface    
 #endif
-#endif
+#endif

+ 3 - 2
jme3-core/src/main/resources/Common/ShaderLib/module/pbrlighting/PBRLightingUtils.glsllib

@@ -266,6 +266,7 @@
         #if defined(NORMALMAP) || defined(PARALLAXMAP)
             vec3 tan = normalize(wTangent.xyz);
             mat3 tbnMat = mat3(tan, wTangent.w * cross( surface.geometryNormal, tan), surface.geometryNormal);
+            surface.tbnMat = tbnMat;
         #endif
         
         vec2 newTexCoord;
@@ -338,7 +339,7 @@
             #endif
             surface.normal = normalize(tbnMat * normal);
         #else 
-            surface.normal = normal;
+            surface.normal = surface.geometryNormal;
         #endif
         
         //spec gloss tex reads:
@@ -589,4 +590,4 @@
 #endif
 
 
-#endif
+#endif