From 507fdf95e642d8499f88453dfc6b02b78117e988 Mon Sep 17 00:00:00 2001 From: Emmett Lalish Date: Mon, 9 Dec 2019 16:14:59 -0800 Subject: [PATCH] flip normalScale without tangents --- examples/js/loaders/GLTFLoader.js | 8 ++++++++ examples/jsm/loaders/GLTFLoader.js | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/examples/js/loaders/GLTFLoader.js b/examples/js/loaders/GLTFLoader.js index 87d9750118..41884c120f 100644 --- a/examples/js/loaders/GLTFLoader.js +++ b/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; diff --git a/examples/jsm/loaders/GLTFLoader.js b/examples/jsm/loaders/GLTFLoader.js index 7d6ff2e28a..3507ac978a 100644 --- a/examples/jsm/loaders/GLTFLoader.js +++ b/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; -- GitLab