Просмотр исходного кода

Modified SG shader to match glTF spec

WestLangley 4 лет назад
Родитель
Сommit
d39ac2f694
2 измененных файлов с 2 добавлено и 2 удалено
  1. 1 1
      examples/js/loaders/GLTFLoader.js
  2. 1 1
      examples/jsm/loaders/GLTFLoader.js

+ 1 - 1
examples/js/loaders/GLTFLoader.js

@@ -893,7 +893,7 @@ THREE.GLTFLoader = ( function () {
 
 
 		var lightPhysicalFragmentChunk = [
 		var lightPhysicalFragmentChunk = [
 			'PhysicalMaterial material;',
 			'PhysicalMaterial material;',
-			'material.diffuseColor = diffuseColor.rgb;',
+			'material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );',
 			'vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );',
 			'vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );',
 			'float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );',
 			'float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );',
 			'material.specularRoughness = max( 1.0 - glossinessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.',
 			'material.specularRoughness = max( 1.0 - glossinessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.',

+ 1 - 1
examples/jsm/loaders/GLTFLoader.js

@@ -956,7 +956,7 @@ var GLTFLoader = ( function () {
 
 
 		var lightPhysicalFragmentChunk = [
 		var lightPhysicalFragmentChunk = [
 			'PhysicalMaterial material;',
 			'PhysicalMaterial material;',
-			'material.diffuseColor = diffuseColor.rgb;',
+			'material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );',
 			'vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );',
 			'vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );',
 			'float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );',
 			'float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );',
 			'material.specularRoughness = max( 1.0 - glossinessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.',
 			'material.specularRoughness = max( 1.0 - glossinessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.',