Ver Fonte

fixed glTF Mask and Opaque

Emmett Lalish há 5 anos atrás
pai
commit
33452b6260

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

@@ -2107,6 +2107,12 @@ THREE.GLTFLoader = ( function () {
 
 				materialParams.alphaTest = materialDef.alphaCutoff !== undefined ? materialDef.alphaCutoff : 0.5;
 
+			} else {
+
+				// for ALPHA_MODES.OPAQUE, we use a negative alphaTest value to enable alphaTesting,
+				// causing the test to always be passed, but also replacing any alpha value with 1.0.
+				materialParams.alphaTest = - 0.5;
+
 			}
 
 		}

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

@@ -2172,6 +2172,12 @@ var GLTFLoader = ( function () {
 
 				materialParams.alphaTest = materialDef.alphaCutoff !== undefined ? materialDef.alphaCutoff : 0.5;
 
+			} else {
+
+				// for ALPHA_MODES.OPAQUE, we use a negative alphaTest value to enable alphaTesting,
+				// causing the test to always be passed, but also replacing any alpha value with 1.0.
+				materialParams.alphaTest = - 0.5;
+
 			}
 
 		}

+ 2 - 1
src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js

@@ -1,7 +1,8 @@
 export default /* glsl */`
 #ifdef USE_ALPHAMAP
 
-	diffuseColor.a *= texture2D( alphaMap, vUv ).g;
+  diffuseColor.a *= texture2D( alphaMap, vUv ).g;
+  diffuseColor.a = 1.0;
 
 #endif
 `;