Przeglądaj źródła

Fix math in bumpVertex shader

Gary Hsu 8 lat temu
rodzic
commit
a4074fb0c1
1 zmienionych plików z 4 dodań i 4 usunięć
  1. 4 4
      src/Shaders/ShadersInclude/bumpVertex.fx

+ 4 - 4
src/Shaders/ShadersInclude/bumpVertex.fx

@@ -1,8 +1,8 @@
 #if defined(BUMP) || defined(PARALLAX)
 	#if defined(TANGENT) && defined(NORMAL)
-		vec3 normalW = normalize(vec3(finalWorld * vec4(normalUpdated, 0.0)));
-		vec3 tangentW = normalize(vec3(finalWorld * vec4(tangentUpdated.xyz, 0.0)));
-		vec3 bitangentW = cross(normalW, tangentW) * tangentUpdated.w;
-		vTBN = mat3(tangentW, bitangentW, normalW);
+		vec3 tbnNormal = normalize(normalUpdated);
+		vec3 tbnTangent = normalize(tangentUpdated.xyz);
+		vec3 tbnBitangent = cross(tbnNormal, tbnTangent) * tangentUpdated.w;
+		vTBN = mat3(finalWorld) * mat3(tbnTangent, tbnBitangent, tbnNormal);
 	#endif
 #endif