Browse Source

flip normalScale without tangents

Emmett Lalish 5 years ago
parent
commit
507fdf95e6
2 changed files with 16 additions and 0 deletions
  1. 8 0
      examples/js/loaders/GLTFLoader.js
  2. 8 0
      examples/jsm/loaders/GLTFLoader.js

+ 8 - 0
examples/js/loaders/GLTFLoader.js

@@ -2262,6 +2262,14 @@ THREE.GLTFLoader = ( function () {
 
 			if ( materialDef.name !== undefined ) material.name = materialDef.name;
 
+			// Normal map textures use OpenGL conventions:
+			// https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#materialnormaltexture
+			if ( material.normalScale && ! material.vertexTangents ) {
+
+				material.normalScale.y = - material.normalScale.y;
+
+			}
+
 			// baseColorTexture, emissiveTexture, and specularGlossinessTexture use sRGB encoding.
 			if ( material.map ) material.map.encoding = THREE.sRGBEncoding;
 			if ( material.emissiveMap ) material.emissiveMap.encoding = THREE.sRGBEncoding;

+ 8 - 0
examples/jsm/loaders/GLTFLoader.js

@@ -2329,6 +2329,14 @@ var GLTFLoader = ( function () {
 
 			if ( materialDef.name !== undefined ) material.name = materialDef.name;
 
+			// Normal map textures use OpenGL conventions:
+			// https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#materialnormaltexture
+			if ( material.normalScale && ! material.vertexTangents ) {
+
+				material.normalScale.y = - material.normalScale.y;
+
+			}
+
 			// baseColorTexture, emissiveTexture, and specularGlossinessTexture use sRGB encoding.
 			if ( material.map ) material.map.encoding = sRGBEncoding;
 			if ( material.emissiveMap ) material.emissiveMap.encoding = sRGBEncoding;