Sfoglia il codice sorgente

NodeMaterial: Added `.castShadowNode` and `.receivedShadowNode` (#29840)

* added `castShadowNode` and `receivedShadowNode`

* Update webgpu_tsl_angular_slicing.html
sunag 1 anno fa
parent
commit
8f55e4ba46

+ 1 - 1
examples/webgpu_shadowmap.html

@@ -104,7 +104,7 @@
 				} )();
 
 
-				materialCustomShadow.shadowNode = Fn( () => {
+				materialCustomShadow.castShadowNode = Fn( () => {
 
 					discardNode.discard();
 

+ 2 - 2
examples/webgpu_shadowmap_opacity.html

@@ -112,8 +112,8 @@
 				dragon.castShadow = dragon2.castShadow = true;
 				dragon.receiveShadow = dragon2.receiveShadow = true;
 
-				dragon.material.shadowNode = customShadow( dragon.material.attenuationColor );
-				dragon2.material.shadowNode = customShadow( dragon2.material.attenuationColor );
+				dragon.material.castShadowNode = customShadow( dragon.material.attenuationColor );
+				dragon2.material.castShadowNode = customShadow( dragon2.material.attenuationColor );
 
 				//
 

+ 1 - 1
examples/webgpu_tsl_angular_slicing.html

@@ -136,7 +136,7 @@
 
 				// shadow
 
-				slicedMaterial.shadowNode = Fn( () => {
+				slicedMaterial.castShadowNode = Fn( () => {
 
 					// discard
 

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

@@ -67,8 +67,9 @@ class NodeMaterial extends Material {
 		this.geometryNode = null;
 
 		this.depthNode = null;
-		this.shadowNode = null;
 		this.shadowPositionNode = null;
+		this.receivedShadowNode = null;
+		this.castShadowNode = null;
 
 		this.outputNode = null;
 		this.mrtNode = null;
@@ -692,8 +693,9 @@ class NodeMaterial extends Material {
 		this.geometryNode = source.geometryNode;
 
 		this.depthNode = source.depthNode;
-		this.shadowNode = source.shadowNode;
 		this.shadowPositionNode = source.shadowPositionNode;
+		this.receivedShadowNode = source.receivedShadowNode;
+		this.castShadowNode = source.castShadowNode;
 
 		this.outputNode = source.outputNode;
 		this.mrtNode = source.mrtNode;

+ 11 - 4
src/nodes/lighting/ShadowNode.js

@@ -365,7 +365,17 @@ class ShadowNode extends Node {
 
 		}
 
-		shadowsTotal.mulAssign( node );
+		if ( builder.material.shadowNode ) { // @deprecated, r171
+
+			console.warn( 'THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".receivedShadowNode" instead.' );
+
+		}
+
+		if ( builder.material.receivedShadowNode ) {
+
+			node = builder.material.receivedShadowNode( node );
+
+		}
 
 		return node;
 
@@ -492,7 +502,4 @@ class ShadowNode extends Node {
 
 export default ShadowNode;
 
-const shadowsTotal = /*@__PURE__*/ float( 1 ).toVar();
-
 export const shadow = ( light, shadow ) => nodeObject( new ShadowNode( light, shadow ) );
-export const shadows = /*@__PURE__*/ shadowsTotal.oneMinus().toVar( 'shadows' );

+ 2 - 2
src/renderers/common/Renderer.js

@@ -1637,10 +1637,10 @@ class Renderer {
 				}
 
 
-				if ( material.shadowNode && material.shadowNode.isNode ) {
+				if ( material.castShadowNode && material.castShadowNode.isNode ) {
 
 					overrideFragmentNode = overrideMaterial.fragmentNode;
-					overrideMaterial.fragmentNode = material.shadowNode;
+					overrideMaterial.fragmentNode = material.castShadowNode;
 
 				}
 

粤ICP备19079148号