Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NodeMaterial: Added .castShadowNode and .receivedShadowNode #1400

Merged
merged 5 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions examples-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -14836,37 +14836,34 @@ index 06af5ab4..e543f68b 100644
postProcessing.outputNode = combinedPass;

diff --git a/examples-testing/examples/webgpu_postprocessing_ao.ts b/examples-testing/examples/webgpu_postprocessing_ao.ts
index f95a72ff..4cdd6f1a 100644
index 1957d7a9..34c14633 100644
--- a/examples-testing/examples/webgpu_postprocessing_ao.ts
+++ b/examples-testing/examples/webgpu_postprocessing_ao.ts
@@ -1,7 +1,7 @@
-import * as THREE from 'three';
-import { pass, mrt, output, transformedNormalView, texture } from 'three/tsl';
-import { pass, mrt, output, normalView } from 'three/tsl';
-import { ao } from 'three/addons/tsl/display/GTAONode.js';
-import { denoise } from 'three/addons/tsl/display/DenoiseNode.js';
+import * as THREE from 'three/webgpu';
+import { pass, mrt, output, transformedNormalView, texture, Node, ShaderNodeObject } from 'three/tsl';
+import { pass, mrt, output, normalView, Node, ShaderNodeObject } from 'three/tsl';
+import GTAONode, { ao } from 'three/addons/tsl/display/GTAONode.js';
+import DenoiseNode, { denoise } from 'three/addons/tsl/display/DenoiseNode.js';

import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';
@@ -12,9 +12,20 @@ import { SimplexNoise } from 'three/addons/math/SimplexNoise.js';
@@ -11,9 +11,18 @@ import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import Stats from 'three/addons/libs/stats.module.js';
import { GUI } from 'three/addons/libs/lil-gui.module.min.js';

-let camera, scene, renderer, postProcessing, controls, clock, stats, mixer;
-
-let aoPass, denoisePass, blendPassAO, blendPassDenoise, scenePassColor;
-let camera, scene, renderer, postProcessing, controls, stats;
+let camera: THREE.PerspectiveCamera,
+ scene: THREE.Scene,
+ renderer: THREE.WebGPURenderer,
+ postProcessing: THREE.PostProcessing,
+ controls: OrbitControls,
+ clock: THREE.Clock,
+ stats: Stats,
+ mixer: THREE.AnimationMixer;
+
+ stats: Stats;

-let aoPass, denoisePass, blendPassAO, blendPassDenoise, scenePassColor;
+let aoPass: ShaderNodeObject<GTAONode>,
+ denoisePass: ShaderNodeObject<DenoiseNode>,
+ blendPassAO: ShaderNodeObject<Node>,
Expand All @@ -14875,6 +14872,16 @@ index f95a72ff..4cdd6f1a 100644

const params = {
distanceExponent: 1,
@@ -118,7 +127,8 @@ async function init() {
// first place. Besides, normal estimation is computationally more expensive than just sampling a
// normal texture. So depending on your scene, consider to enable "depthWrite" for all transparent objects.

- if (o.material) o.material.depthWrite = true;
+ if ((o as THREE.Mesh<THREE.BufferGeometry, THREE.Material>).material)
+ (o as THREE.Mesh<THREE.BufferGeometry, THREE.Material>).material.depthWrite = true;
});

window.addEventListener('resize', onWindowResize);
diff --git a/examples-testing/examples/webgpu_postprocessing_bloom.ts b/examples-testing/examples/webgpu_postprocessing_bloom.ts
index ad2028b4..0d7d6e66 100644
--- a/examples-testing/examples/webgpu_postprocessing_bloom.ts
Expand Down
2 changes: 1 addition & 1 deletion types/three/examples/jsm/tsl/display/DenoiseNode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ declare class DenoiseNode extends TempNode {
textureNode: Node;
depthNode: Node;
normalNode: Node;

noiseNode: Node;

lumaPhi: UniformNode<number>;
Expand All @@ -22,6 +23,5 @@ export const denoise: (
node: NodeRepresentation,
depthNode: NodeRepresentation,
normalNode: NodeRepresentation,
noiseNode: NodeRepresentation,
camera: Camera,
) => ShaderNodeObject<DenoiseNode>;
3 changes: 2 additions & 1 deletion types/three/src/materials/nodes/NodeMaterial.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ declare class NodeMaterial extends Material {
geometryNode: Node | null;

depthNode: Node | null;
shadowNode: Node | null;
shadowPositionNode: Node | null;
receivedShadowNode: Node | null;
castShadowNode: Node | null;

outputNode: Node | null;
mrtNode: MRTNode | null;
Expand Down
Loading