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

Addons: Add SSRNode. #1326

Merged
merged 4 commits into from
Nov 3, 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
38 changes: 38 additions & 0 deletions examples-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -15272,6 +15272,44 @@ index 4aeb6e43..738b6580 100644

postProcessing.render();

diff --git a/examples-testing/examples/webgpu_postprocessing_ssr.ts b/examples-testing/examples/webgpu_postprocessing_ssr.ts
index a6536f79..a7388db4 100644
--- a/examples-testing/examples/webgpu_postprocessing_ssr.ts
+++ b/examples-testing/examples/webgpu_postprocessing_ssr.ts
@@ -1,6 +1,6 @@
-import * as THREE from 'three';
-import { pass, mrt, output, transformedNormalView, metalness, vec4 } from 'three/tsl';
-import { ssr } from 'three/addons/tsl/display/SSRNode.js';
+import * as THREE from 'three/webgpu';
+import { pass, mrt, output, transformedNormalView, metalness, vec4, ShaderNodeObject } from 'three/tsl';
+import SSRNode, { ssr } from 'three/addons/tsl/display/SSRNode.js';

import Stats from 'three/addons/libs/stats.module.js';

@@ -18,8 +18,12 @@ const params = {
autoRotate: false,
};

-let camera, scene, renderer, postProcessing, ssrPass;
-let gui, stats, controls;
+let camera: THREE.PerspectiveCamera,
+ scene: THREE.Scene,
+ renderer: THREE.WebGPURenderer,
+ postProcessing: THREE.PostProcessing,
+ ssrPass: ShaderNodeObject<SSRNode>;
+let gui: GUI, stats: Stats, controls: OrbitControls;

// Configure and create Draco decoder.
const dracoLoader = new DRACOLoader();
@@ -64,7 +68,7 @@ function init() {
dracoLoader.dispose();
});

- let geometry, material, mesh;
+ let geometry: THREE.BufferGeometry, material: THREE.Material, mesh: THREE.Mesh;

geometry = new THREE.BoxGeometry(0.05, 0.05, 0.05);
material = new THREE.MeshStandardMaterial({ color: 'green', metalness: 0.01 });
diff --git a/examples-testing/examples/webgpu_postprocessing_transition.ts b/examples-testing/examples/webgpu_postprocessing_transition.ts
index dc70b8e9..8c9da56f 100644
--- a/examples-testing/examples/webgpu_postprocessing_transition.ts
Expand Down
38 changes: 38 additions & 0 deletions types/three/examples/jsm/tsl/display/SSRNode.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Node, NodeRepresentation, ShaderNodeObject, TempNode, TextureNode, UniformNode } from "three/tsl";
import { Camera } from "three/webgpu";

declare class SSRNode extends TempNode {
colorNode: ShaderNodeObject<Node>;
depthNode: ShaderNodeObject<Node>;
normalNode: ShaderNodeObject<Node>;
metalnessNode: ShaderNodeObject<Node>;
camera: Camera;

resolutionScale: number;

maxDistance: UniformNode<number>;
thickness: UniformNode<number>;
opacity: UniformNode<number>;

constructor(
colorNode: ShaderNodeObject<Node>,
depthNode: ShaderNodeObject<Node>,
normalNode: ShaderNodeObject<Node>,
metalnessNode: ShaderNodeObject<Node>,
camera: Camera,
);

getTextureNode(): ShaderNodeObject<TextureNode>;

setSize(width: number, height: number): void;
}

export default SSRNode;

export const ssr: (
colorNode: NodeRepresentation,
depthNode: NodeRepresentation,
normalNode: NodeRepresentation,
metalnessNode: NodeRepresentation,
camera: Camera,
) => ShaderNodeObject<SSRNode>;
Loading