Jelajahi Sumber

.specularRoughness -> .roughness (#22374)

WestLangley 3 tahun lalu
induk
melakukan
4346e81f02

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

@@ -1244,7 +1244,7 @@
 			const glossinessMapParsFragmentChunk = [ '#ifdef USE_GLOSSINESSMAP', '	uniform sampler2D glossinessMap;', '#endif' ].join( '\n' );
 			const glossinessMapParsFragmentChunk = [ '#ifdef USE_GLOSSINESSMAP', '	uniform sampler2D glossinessMap;', '#endif' ].join( '\n' );
 			const specularMapFragmentChunk = [ 'vec3 specularFactor = specular;', '#ifdef USE_SPECULARMAP', '	vec4 texelSpecular = texture2D( specularMap, vUv );', '	texelSpecular = sRGBToLinear( texelSpecular );', '	// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture', '	specularFactor *= texelSpecular.rgb;', '#endif' ].join( '\n' );
 			const specularMapFragmentChunk = [ 'vec3 specularFactor = specular;', '#ifdef USE_SPECULARMAP', '	vec4 texelSpecular = texture2D( specularMap, vUv );', '	texelSpecular = sRGBToLinear( texelSpecular );', '	// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture', '	specularFactor *= texelSpecular.rgb;', '#endif' ].join( '\n' );
 			const glossinessMapFragmentChunk = [ 'float glossinessFactor = glossiness;', '#ifdef USE_GLOSSINESSMAP', '	vec4 texelGlossiness = texture2D( glossinessMap, vUv );', '	// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture', '	glossinessFactor *= texelGlossiness.a;', '#endif' ].join( '\n' );
 			const glossinessMapFragmentChunk = [ 'float glossinessFactor = glossiness;', '#ifdef USE_GLOSSINESSMAP', '	vec4 texelGlossiness = texture2D( glossinessMap, vUv );', '	// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture', '	glossinessFactor *= texelGlossiness.a;', '#endif' ].join( '\n' );
-			const lightPhysicalFragmentChunk = [ 'PhysicalMaterial material;', 'material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );', 'vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );', '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 += geometryRoughness;', 'material.specularRoughness = min( material.specularRoughness, 1.0 );', 'material.specularColor = specularFactor;' ].join( '\n' );
+			const lightPhysicalFragmentChunk = [ 'PhysicalMaterial material;', 'material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );', 'vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );', 'float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );', 'material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.', 'material.roughness += geometryRoughness;', 'material.roughness = min( material.roughness, 1.0 );', 'material.specularColor = specularFactor;' ].join( '\n' );
 			const uniforms = {
 			const uniforms = {
 				specular: {
 				specular: {
 					value: new THREE.Color().setHex( 0xffffff )
 					value: new THREE.Color().setHex( 0xffffff )

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

@@ -1406,9 +1406,9 @@ class GLTFMeshStandardSGMaterial extends MeshStandardMaterial {
 			'material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );',
 			'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 += geometryRoughness;',
-			'material.specularRoughness = min( material.specularRoughness, 1.0 );',
+			'material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.',
+			'material.roughness += geometryRoughness;',
+			'material.roughness = min( material.roughness, 1.0 );',
 			'material.specularColor = specularFactor;',
 			'material.specularColor = specularFactor;',
 		].join( '\n' );
 		].join( '\n' );
 
 

+ 8 - 8
examples/jsm/nodes/materials/nodes/StandardNode.js

@@ -122,12 +122,12 @@ class StandardNode extends Node {
 
 
 		} else {
 		} else {
 
 
-			const specularRoughnessNode = new ExpressionNode( 'material.specularRoughness', 'f' );
+			const roughnessNode = new ExpressionNode( 'material.roughness', 'f' );
 			const clearcoatRoughnessNode = new ExpressionNode( 'material.clearcoatRoughness', 'f' );
 			const clearcoatRoughnessNode = new ExpressionNode( 'material.clearcoatRoughness', 'f' );
 
 
 			const contextEnvironment = {
 			const contextEnvironment = {
-				roughness: specularRoughnessNode,
-				bias: new SpecularMIPLevelNode( specularRoughnessNode ),
+				roughness: roughnessNode,
+				bias: new SpecularMIPLevelNode( roughnessNode ),
 				viewNormal: new ExpressionNode( 'normal', 'v3' ),
 				viewNormal: new ExpressionNode( 'normal', 'v3' ),
 				worldNormal: new ExpressionNode( 'inverseTransformDirection( geometry.normal, viewMatrix )', 'v3' ),
 				worldNormal: new ExpressionNode( 'inverseTransformDirection( geometry.normal, viewMatrix )', 'v3' ),
 				gamma: true
 				gamma: true
@@ -333,11 +333,11 @@ class StandardNode extends Node {
 			output.push(
 			output.push(
 				'material.diffuseColor = ' + ( light ? 'vec3( 1.0 )' : 'diffuseColor * ( 1.0 - metalnessFactor )' ) + ';',
 				'material.diffuseColor = ' + ( light ? 'vec3( 1.0 )' : 'diffuseColor * ( 1.0 - metalnessFactor )' ) + ';',
 
 
-				'material.specularRoughness = max( roughnessFactor, 0.0525 );',
-				'material.specularRoughness += geometryRoughness;',
-				'material.specularRoughness = min( material.specularRoughness, 1.0 );',
+				'material.roughness = max( roughnessFactor, 0.0525 );',
+				'material.roughness += geometryRoughness;',
+				'material.roughness = min( material.roughness, 1.0 );',
 
 
-				'material.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );'
+				'material.roughness = clamp( roughnessFactor, 0.04, 1.0 );'
 			);
 			);
 
 
 			if ( clearcoat ) {
 			if ( clearcoat ) {
@@ -417,7 +417,7 @@ class StandardNode extends Node {
 					ao.code,
 					ao.code,
 					'reflectedLight.indirectDiffuse *= ' + ao.result + ';',
 					'reflectedLight.indirectDiffuse *= ' + ao.result + ';',
 					'float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );',
 					'float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );',
-					'reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ' + ao.result + ', material.specularRoughness );'
+					'reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ' + ao.result + ', material.roughness );'
 				);
 				);
 
 
 			}
 			}

+ 1 - 1
src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js

@@ -10,7 +10,7 @@ export default /* glsl */`
 
 
 		float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
 		float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
 
 
-		reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );
+		reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
 
 
 	#endif
 	#endif
 
 

+ 1 - 1
src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js

@@ -26,7 +26,7 @@ export default /* glsl */`
 
 
 #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
 #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
 
 
-	radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.specularRoughness );
+	radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );
 
 
 	#ifdef CLEARCOAT
 	#ifdef CLEARCOAT
 
 

+ 3 - 3
src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js

@@ -5,9 +5,9 @@ material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
 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( roughnessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.
-material.specularRoughness += geometryRoughness;
-material.specularRoughness = min( material.specularRoughness, 1.0 );
+material.roughness = max( roughnessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.
+material.roughness += geometryRoughness;
+material.roughness = min( material.roughness, 1.0 );
 
 
 #ifdef IOR
 #ifdef IOR
 
 

+ 5 - 5
src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js

@@ -2,7 +2,7 @@ export default /* glsl */`
 struct PhysicalMaterial {
 struct PhysicalMaterial {
 
 
 	vec3 diffuseColor;
 	vec3 diffuseColor;
-	float specularRoughness;
+	float roughness;
 	vec3 specularColor;
 	vec3 specularColor;
 	float specularF90;
 	float specularF90;
 
 
@@ -86,7 +86,7 @@ void BRDF_Specular_Multiscattering_Environment( const in vec3 normal, const in v
 		vec3 halfWidth = rectAreaLight.halfWidth;
 		vec3 halfWidth = rectAreaLight.halfWidth;
 		vec3 halfHeight = rectAreaLight.halfHeight;
 		vec3 halfHeight = rectAreaLight.halfHeight;
 		vec3 lightColor = rectAreaLight.color;
 		vec3 lightColor = rectAreaLight.color;
-		float roughness = material.specularRoughness;
+		float roughness = material.roughness;
 
 
 		vec3 rectCoords[ 4 ];
 		vec3 rectCoords[ 4 ];
 		rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; // counterclockwise; light shines in local neg z direction
 		rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; // counterclockwise; light shines in local neg z direction
@@ -154,7 +154,7 @@ void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricC
 	#ifdef USE_SHEEN
 	#ifdef USE_SHEEN
 
 
 		reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(
 		reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(
-			material.specularRoughness,
+			material.roughness,
 			directLight.direction,
 			directLight.direction,
 			geometry,
 			geometry,
 			material.sheenColor
 			material.sheenColor
@@ -162,7 +162,7 @@ void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricC
 
 
 	#else
 	#else
 
 
-		reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.specularRoughness );
+		reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );
 
 
 	#endif
 	#endif
 
 
@@ -200,7 +200,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
 	vec3 multiScattering = vec3( 0.0 );
 	vec3 multiScattering = vec3( 0.0 );
 	vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
 	vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
 
 
-	BRDF_Specular_Multiscattering_Environment( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.specularRoughness, singleScattering, multiScattering );
+	BRDF_Specular_Multiscattering_Environment( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
 
 
 	vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );
 	vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );