From e8660903ef1e9e7b629a237fd4d7ede9a6bb7528 Mon Sep 17 00:00:00 2001 From: sunag Date: Fri, 8 Nov 2024 01:02:00 -0300 Subject: [PATCH 1/2] added `castShadowNode` and `receivedShadowNode` --- examples/webgpu_shadowmap.html | 2 +- examples/webgpu_shadowmap_opacity.html | 4 ++-- src/materials/nodes/NodeMaterial.js | 6 ++++-- src/nodes/lighting/ShadowNode.js | 15 +++++++++++---- src/renderers/common/Renderer.js | 4 ++-- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/examples/webgpu_shadowmap.html b/examples/webgpu_shadowmap.html index 5af56d6a053c31..8bd38c3852e582 100644 --- a/examples/webgpu_shadowmap.html +++ b/examples/webgpu_shadowmap.html @@ -104,7 +104,7 @@ } )(); - materialCustomShadow.shadowNode = Fn( () => { + materialCustomShadow.castShadowNode = Fn( () => { discardNode.discard(); diff --git a/examples/webgpu_shadowmap_opacity.html b/examples/webgpu_shadowmap_opacity.html index 16ee16caff64f5..8c72b76f33acb3 100644 --- a/examples/webgpu_shadowmap_opacity.html +++ b/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 ); // diff --git a/src/materials/nodes/NodeMaterial.js b/src/materials/nodes/NodeMaterial.js index 554bb3f912c62f..1ecb1e6064aa6e 100644 --- a/src/materials/nodes/NodeMaterial.js +++ b/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; diff --git a/src/nodes/lighting/ShadowNode.js b/src/nodes/lighting/ShadowNode.js index 8f13c15c6fa7ab..4ea36eddd0c433 100644 --- a/src/nodes/lighting/ShadowNode.js +++ b/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' ); diff --git a/src/renderers/common/Renderer.js b/src/renderers/common/Renderer.js index b84496f87cb2ae..d7036316ba7e84 100644 --- a/src/renderers/common/Renderer.js +++ b/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; } From fa91a0834284c493d71e07d3305cc8f9dbb16c7b Mon Sep 17 00:00:00 2001 From: sunag Date: Fri, 8 Nov 2024 01:23:06 -0300 Subject: [PATCH 2/2] Update webgpu_tsl_angular_slicing.html --- examples/webgpu_tsl_angular_slicing.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/webgpu_tsl_angular_slicing.html b/examples/webgpu_tsl_angular_slicing.html index 2edb52b47acd6f..c627dfb3dcd655 100644 --- a/examples/webgpu_tsl_angular_slicing.html +++ b/examples/webgpu_tsl_angular_slicing.html @@ -136,7 +136,7 @@ // shadow - slicedMaterial.shadowNode = Fn( () => { + slicedMaterial.castShadowNode = Fn( () => { // discard