浏览代码

USDZLoader: Switch to MeshPhysicalMaterial and add clearcoat/clearcoatRoughness/ior support (#26713)

fix incorrect colorspace usage
hybridherbst 1 年之前
父节点
当前提交
5e37e4da21
共有 1 个文件被更改,包括 38 次插入2 次删除
  1. 38 2
      examples/jsm/loaders/USDZLoader.js

+ 38 - 2
examples/jsm/loaders/USDZLoader.js

@@ -7,7 +7,7 @@ import {
 	NoColorSpace,
 	Loader,
 	Mesh,
-	MeshStandardMaterial,
+	MeshPhysicalMaterial,
 	MirroredRepeatWrapping,
 	RepeatWrapping,
 	SRGBColorSpace,
@@ -491,7 +491,7 @@ class USDZLoader extends Loader {
 
 		function buildMaterial( data ) {
 
-			const material = new MeshStandardMaterial();
+			const material = new MeshPhysicalMaterial();
 
 			if ( data !== undefined ) {
 
@@ -570,6 +570,42 @@ class USDZLoader extends Loader {
 
 					}
 
+					if ( 'float inputs:clearcoat.connect' in surface ) {
+
+						const path = surface[ 'float inputs:clearcoat.connect' ];
+						const sampler = findTexture( root, /(\w+).output/.exec( path )[ 1 ] );
+
+						material.clearcoat = 1.0;
+						material.clearcoatMap = buildTexture( sampler );
+						material.clearcoatMap.colorSpace = NoColorSpace;
+
+					} else  if ( 'float inputs:clearcoat' in surface ) {
+
+						material.clearcoat = parseFloat( surface[ 'float inputs:clearcoat' ] );
+
+					}
+
+					if ( 'float inputs:clearcoatRoughness.connect' in surface ) {
+
+						const path = surface[ 'float inputs:clearcoatRoughness.connect' ];
+						const sampler = findTexture( root, /(\w+).output/.exec( path )[ 1 ] );
+
+						material.clearcoatRoughness = 1.0;
+						material.clearcoatRoughnessMap = buildTexture( sampler );
+						material.clearcoatRoughnessMap.colorSpace = NoColorSpace;
+
+					} else if ( 'float inputs:clearcoatRoughness' in surface ) {
+
+						material.clearcoatRoughness = parseFloat( surface[ 'float inputs:clearcoatRoughness' ] );
+
+					}
+
+					if ( 'float inputs:ior' in surface ) {
+
+						material.ior = parseFloat( surface[ 'float inputs:ior' ] );
+
+					}
+
 					if ( 'float inputs:occlusion.connect' in surface ) {
 
 						const path = surface[ 'float inputs:occlusion.connect' ];