Преглед изворни кода

WebGPU: Removed Blinn Phong Support (#22413)

* WebGPU: Removed Phong support

* cleanup
sunag пре 3 година
родитељ
комит
8fd508b25d

+ 5 - 6
examples/jsm/renderers/nodes/accessors/MaterialNode.js

@@ -8,7 +8,6 @@ class MaterialNode extends Node {
 	static COLOR = 'color';
 	static OPACITY = 'opacity';
 	static SPECULAR = 'specular';
-	static SHININESS = 'shininess';
 	static ROUGHNESS = 'roughness';
 	static METALNESS = 'metalness';
 
@@ -37,7 +36,7 @@ class MaterialNode extends Node {
 
 			return 'vec3';
 
-		} else if ( scope === MaterialNode.SHININESS || scope === MaterialNode.ROUGHNESS || scope === MaterialNode.METALNESS ) {
+		} else if ( scope === MaterialNode.ROUGHNESS || scope === MaterialNode.METALNESS ) {
 
 			return 'float';
 
@@ -86,15 +85,15 @@ class MaterialNode extends Node {
 
 		} else if ( scope === MaterialNode.SPECULAR ) {
 
-			const specularColorNode = new MaterialReferenceNode( 'specular', 'color' );
+			const specularTintNode = new MaterialReferenceNode( 'specularTint', 'color' );
 
-			if ( material.specularMap !== null && material.specularMap !== undefined && material.specularMap.isTexture === true ) {
+			if ( material.specularTintMap !== null && material.specularTintMap !== undefined && material.specularTintMap.isTexture === true ) {
 
-				node = new OperatorNode( '*', specularColorNode, new MaterialReferenceNode( 'specularMap', 'texture' ) );
+				node = new OperatorNode( '*', specularTintNode, new MaterialReferenceNode( 'specularTintMap', 'texture' ) );
 
 			} else {
 
-				node = specularColorNode;
+				node = specularTintNode;
 
 			}
 

+ 0 - 2
examples/jsm/renderers/nodes/core/ContextNode.js

@@ -36,8 +36,6 @@ class ContextNode extends Node {
 
 	generate( builder, output ) {
 
-		const type = this.getType( builder );
-	
 		const previousContext = builder.getContext();
 
 		builder.setContext( Object.assign( {}, builder.context, this.context ) );

+ 3 - 8
examples/jsm/renderers/nodes/core/NodeKeywords.js

@@ -35,10 +35,7 @@ class NodeKeywords {
 	// STANDARD
 	static MaterialRoughness = 'MaterialRoughness';
 	static MaterialMetalness = 'MaterialMetalness';
-
-	// PHONG
-	static MaterialSpecularShininess = 'MaterialSpecularShininess';
-	static MaterialSpecularColor = 'MaterialSpecularColor';
+	static MaterialSpecularTint = 'MaterialSpecularTint';
 
 	constructor() {
 
@@ -59,7 +56,6 @@ class NodeKeywords {
 			NodeKeywords.NormalWorld,
 			NodeKeywords.NormalView,
 			// vars -> float
-			NodeKeywords.MaterialSpecularShininess,
 			NodeKeywords.MaterialRoughness,
 			NodeKeywords.MaterialMetalness,
 			// vars -> vec3
@@ -68,7 +64,7 @@ class NodeKeywords {
 			NodeKeywords.ReflectedLightIndirectSpecular,
 			NodeKeywords.ReflectedLightDirectDiffuse,
 			NodeKeywords.ReflectedLightDirectSpecular,
-			NodeKeywords.MaterialSpecularColor,
+			NodeKeywords.MaterialSpecularTint,
 			// vars -> vec4
 			NodeKeywords.MaterialDiffuseColor
 		];
@@ -158,7 +154,6 @@ class NodeKeywords {
 					break;
 
 				// floats properties
-				case NodeKeywords.MaterialSpecularShininess:
 				case NodeKeywords.MaterialRoughness:
 				case NodeKeywords.MaterialMetalness:
 
@@ -172,7 +167,7 @@ class NodeKeywords {
 				case NodeKeywords.ReflectedLightIndirectSpecular:
 				case NodeKeywords.ReflectedLightDirectDiffuse:
 				case NodeKeywords.ReflectedLightDirectSpecular:
-				case NodeKeywords.MaterialSpecularColor:
+				case NodeKeywords.MaterialSpecularTint:
 
 					node = new PropertyNode( name, 'vec3' );
 

+ 0 - 2
examples/jsm/renderers/nodes/core/StructNode.js

@@ -39,8 +39,6 @@ class StructNode extends CodeNode {
 		const type = this.getType( builder );
 		const inputs = this.inputs;
 
-		const shaderStage = builder.getShaderStage();
-
 		let code = `struct ${type} {\n`;
 
 		for ( const inputName in inputs ) {

+ 2 - 1
examples/jsm/renderers/nodes/core/VaryNode.js

@@ -22,12 +22,13 @@ class VaryNode extends Node {
 	generate( builder, output ) {
 
 		const type = this.getType( builder );
+		const value = this.value;
 
 		const nodeVary = builder.getVaryFromNode( this, type );
 		const propertyName = builder.getPropertyName( nodeVary );
 
 		// force nodeVary.snippet work in vertex stage
-		const flowData = builder.flowNodeFromShaderStage( NodeShaderStage.Vertex, this.value, type, propertyName );
+		builder.flowNodeFromShaderStage( NodeShaderStage.Vertex, value, type, propertyName );
 
 		return builder.format( propertyName, type, output );
 

+ 1 - 55
examples/jsm/renderers/nodes/functions/BSDFs.js

@@ -66,60 +66,6 @@ float punctualLightIntensityToIrradianceFactor( float lightDistance, float cutof
 
 }` ).setIncludes( [ pow2 ] );
 
-//
-//	BLINN PHONG
-//
-
-export const D_BlinnPhong = new FunctionNode( `
-float D_BlinnPhong( const in float shininess, const in float dotNH ) {
-
-	return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
-
-}` ); // validated
-
-export const BRDF_BlinnPhong = new FunctionNode( `
-vec3 BRDF_BlinnPhong( vec3 lightDirection, vec3 specularColor, float shininess ) {
-
-	vec3 halfDir = normalize( lightDirection + PositionViewDirection );
-
-	float dotNH = saturate( dot( NormalView, halfDir ) );
-	float dotVH = saturate( dot( PositionViewDirection, halfDir ) );
-
-	vec3 F = F_Schlick( specularColor, 1.0, dotVH );
-
-	float G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );
-
-	float D = D_BlinnPhong( shininess, dotNH );
-
-	return F * ( G * D );
-
-}` ).setIncludes( [ F_Schlick, G_BlinnPhong_Implicit, D_BlinnPhong ] ); // validated
-
-export const RE_Direct_BlinnPhong = new FunctionNode( `
-void RE_Direct_BlinnPhong( inout ReflectedLight reflectedLight, vec3 lightDirection, vec3 lightColor ) {
-
-	float dotNL = saturate( dot( NormalView, lightDirection ) );
-	vec3 irradiance = dotNL * lightColor;
-
-#ifndef PHYSICALLY_CORRECT_LIGHTS
-
-		irradiance *= PI; // punctual light
-
-#endif
-
-	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( MaterialDiffuseColor.rgb );
-
-	reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( lightDirection, MaterialSpecularColor, MaterialSpecularShininess );
-
-}` ).setIncludes( [ BRDF_Lambert, BRDF_BlinnPhong ] );
-
-export const BlinnPhongLightingModel = new FunctionNode( `
-void ( inout ReflectedLight reflectedLight, vec3 lightDirection, vec3 lightColor ) {
-
-	RE_Direct_BlinnPhong( reflectedLight, lightDirection, lightColor );
-
-}` ).setIncludes( [ RE_Direct_BlinnPhong ] );
-
 //
 // STANDARD
 //
@@ -189,7 +135,7 @@ void RE_Direct_Physical( inout ReflectedLight reflectedLight, vec3 lightDirectio
 
 	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( MaterialDiffuseColor.rgb );
 
-	reflectedLight.directSpecular += irradiance * BRDF_Specular_GGX( lightDirection, MaterialSpecularColor, 1.0, MaterialRoughness );
+	reflectedLight.directSpecular += irradiance * BRDF_Specular_GGX( lightDirection, MaterialSpecularTint, 1.0, MaterialRoughness );
 
 }` ).setIncludes( [ BRDF_Lambert, BRDF_Specular_GGX ] );
 

+ 1 - 5
examples/jsm/renderers/nodes/lights/LightContextNode.js

@@ -1,6 +1,6 @@
 import ContextNode from '../core/ContextNode.js';
 import StructNode from '../core/StructNode.js';
-import { PhysicalLightingModel, BlinnPhongLightingModel } from '../functions/BSDFs.js';
+import { PhysicalLightingModel } from '../functions/BSDFs.js';
 
 const reflectedLightStruct = new StructNode( {
 	directDiffuse: 'vec3',
@@ -27,10 +27,6 @@ class LightContextNode extends ContextNode {
 
 			lightingModel = PhysicalLightingModel;
 
-		} else if ( material.isMeshPhongMaterial === true ) {
-
-			lightingModel = BlinnPhongLightingModel;
-
 		}
 
 		const reflectedLightNode = reflectedLightStruct.create();

+ 0 - 63
examples/jsm/renderers/webgpu/nodes/ShaderLib.js

@@ -65,69 +65,6 @@ const ShaderLib = {
 
 	},
 
-	phong: {
-
-		vertexShader:
-			`#version 450
-
-			void main(){
-
-				NODE_CODE
-
-				NODE_CODE_MVP
-				gl_Position = NODE_MVP;
-
-			}`,
-
-		fragmentShader:
-			`#version 450
-
-			layout(location = 0) out vec4 outColor;
-
-			void main() {
-
-				NODE_CODE
-
-				MaterialDiffuseColor = vec4( 1.0 );
-				MaterialSpecularColor = vec3( 1.0 );
-				MaterialSpecularShininess = 30.0;
-
-				NODE_CODE_COLOR
-				MaterialDiffuseColor = NODE_COLOR;
-
-				NODE_CODE_OPACITY
-				MaterialDiffuseColor.a *= NODE_OPACITY;
-
-				#ifdef NODE_ALPHA_TEST
-
-					NODE_CODE_ALPHA_TEST
-					if ( MaterialDiffuseColor.a < NODE_ALPHA_TEST ) discard;
-
-				#endif
-
-				NODE_CODE_SPECULAR
-				MaterialSpecularColor = NODE_SPECULAR;
-
-				NODE_CODE_SHININESS
-				MaterialSpecularShininess = NODE_SHININESS;
-
-				#ifdef NODE_LIGHT
-
-					NODE_CODE_LIGHT
-
-					outColor.rgb = NODE_LIGHT;
-					outColor.a = MaterialDiffuseColor.a;
-
-				#else
-
-					outColor = MaterialDiffuseColor;
-
-				#endif
-
-			}`
-
-	},
-
 	standard: {
 
 		vertexShader: