فهرست منبع

NodeMaterial: Add `setupOutgoingLight()`. (#28941)

* NodeMaterial: Add `setupOutgoingLight()`.

* NodeMaterial: Set `lights` to `false` by default.

* Examples: Fix lighting.

* E2E: Update screenshots.

* add builder as parameter for optional usage

---------

Co-authored-by: sunag <sunagbrasil@gmail.com>
Michael Herzog 1 سال پیش
والد
کامیت
5e4214dc7b

BIN
examples/screenshots/webgpu_backdrop_area.jpg


BIN
examples/screenshots/webgpu_instance_uniform.jpg


+ 7 - 0
examples/webgpu_backdrop_area.html

@@ -49,6 +49,13 @@
 
 				clock = new THREE.Clock();
 
+				const light = new THREE.PointLight( 0xffffff, 50 );
+				camera.add( light );
+				scene.add( camera );
+
+				const ambient = new THREE.AmbientLight( 0x4466ff, 1 );
+				scene.add( ambient );
+			
 				// model
 
 				const loader = new GLTFLoader();

+ 1 - 1
examples/webgpu_instance_uniform.html

@@ -105,7 +105,7 @@
 				const instanceUniform = nodeObject( new InstanceUniformNode() );
 				const cubeTextureNode = cubeTexture( cTexture );
 
-				const material = new THREE.MeshStandardNodeMaterial();
+				const material = new THREE.MeshBasicNodeMaterial();
 				material.colorNode = instanceUniform.add( cubeTextureNode );
 				material.emissiveNode = instanceUniform.mul( cubeTextureNode );
 

+ 7 - 0
src/nodes/materials/MeshBasicNodeMaterial.js

@@ -5,6 +5,7 @@ import BasicEnvironmentNode from '../lighting/BasicEnvironmentNode.js';
 import BasicLightMapNode from '../lighting/BasicLightMapNode.js';
 import BasicLightingModel from '../functions/BasicLightingModel.js';
 import { transformedNormalView, normalView } from '../accessors/NormalNode.js';
+import { diffuseColor } from '../core/PropertyNode.js';
 
 const _defaultValues = /*@__PURE__*/ new MeshBasicMaterial();
 
@@ -53,6 +54,12 @@ class MeshBasicNodeMaterial extends NodeMaterial {
 
 	}
 
+	setupOutgoingLight() {
+
+		return diffuseColor.rgb;
+
+	}
+
 	setupLightingModel() {
 
 		return new BasicLightingModel();

+ 2 - 0
src/nodes/materials/MeshStandardNodeMaterial.js

@@ -19,6 +19,8 @@ class MeshStandardNodeMaterial extends NodeMaterial {
 
 		this.isMeshStandardNodeMaterial = true;
 
+		this.lights = true;
+
 		this.emissiveNode = null;
 
 		this.metalnessNode = null;

+ 9 - 2
src/nodes/materials/NodeMaterial.js

@@ -41,7 +41,7 @@ class NodeMaterial extends Material {
 		this.forceSinglePass = false;
 
 		this.fog = true;
-		this.lights = true;
+		this.lights = false;
 		this.normals = true;
 
 		this.lightsNode = null;
@@ -337,6 +337,13 @@ class NodeMaterial extends Material {
 
 	}
 
+
+	setupOutgoingLight() {
+
+		return ( this.lights === true ) ? vec3( 0 ) : diffuseColor.rgb;
+
+	}
+
 	setupNormal() {
 
 		// NORMAL VIEW
@@ -452,7 +459,7 @@ class NodeMaterial extends Material {
 
 		const lightsNode = lights ? this.setupLights( builder ) : null;
 
-		let outgoingLightNode = diffuseColor.rgb;
+		let outgoingLightNode = this.setupOutgoingLight( builder );
 
 		if ( lightsNode && lightsNode.hasLight !== false ) {
 

粤ICP备19079148号