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

Nodes: Add GTAONode. #1106

Merged
merged 5 commits into from
Jul 21, 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
26 changes: 26 additions & 0 deletions examples-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -14623,6 +14623,32 @@ index 4c3a1d66..4337b2c8 100644

postProcessing.outputNode = combinedPass;

diff --git a/examples-testing/examples/webgpu_postprocessing_ao.ts b/examples-testing/examples/webgpu_postprocessing_ao.ts
index 332e32ae..d5f8e24b 100644
--- a/examples-testing/examples/webgpu_postprocessing_ao.ts
+++ b/examples-testing/examples/webgpu_postprocessing_ao.ts
@@ -1,4 +1,4 @@
-import * as THREE from 'three';
+import * as THREE from 'three/webgpu';
import { pass, mrt, output, transformedNormalView } from 'three/tsl';

import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
@@ -8,7 +8,14 @@ import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';

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

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

init();

diff --git a/examples-testing/examples/webgpu_postprocessing_dof.ts b/examples-testing/examples/webgpu_postprocessing_dof.ts
index 3fb4046b..785a78f8 100644
--- a/examples-testing/examples/webgpu_postprocessing_dof.ts
Expand Down
1 change: 1 addition & 0 deletions types/three/src/nodes/Nodes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ export { default as DotScreenNode, dotScreen } from "./display/DotScreenNode.js"
export { default as FilmNode, film } from "./display/FilmNode.js";
export { default as FrontFacingNode, faceDirection, frontFacing } from "./display/FrontFacingNode.js";
export { default as GaussianBlurNode, gaussianBlur } from "./display/GaussianBlurNode.js";
export { ao, default as GTAONode } from "./display/GTAONode.js";
export { default as Lut3DNode, lut3D } from "./display/Lut3DNode.js";
export { default as NormalMapNode, normalMap } from "./display/NormalMapNode.js";
export { default as PosterizeNode, posterize } from "./display/PosterizeNode.js";
Expand Down
48 changes: 48 additions & 0 deletions types/three/src/nodes/display/GTAONode.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Camera } from "../../cameras/Camera.js";
import { Matrix4 } from "../../math/Matrix4.js";
import { Vector2 } from "../../math/Vector2.js";
import TextureNode from "../accessors/TextureNode.js";
import Node from "../core/Node.js";
import TempNode from "../core/TempNode.js";
import UniformNode from "../core/UniformNode.js";
import { NodeRepresentation, ShaderNodeObject } from "../shadernode/ShaderNode.js";

declare class GTAONode extends TempNode {
textureNode: Node;
depthNode: Node;
normalNode: Node;

radius: ShaderNodeObject<UniformNode<number>>;
resolution: ShaderNodeObject<UniformNode<Vector2>>;
thickness: ShaderNodeObject<UniformNode<number>>;
distanceExponent: ShaderNodeObject<UniformNode<number>>;
distanceFallOff: ShaderNodeObject<UniformNode<number>>;
scale: ShaderNodeObject<UniformNode<number>>;
noiseNode: ShaderNodeObject<TextureNode>;

cameraProjectionMatrix: ShaderNodeObject<UniformNode<Matrix4>>;
cameraProjectionMatrixInverse: ShaderNodeObject<UniformNode<Matrix4>>;

SAMPLES: ShaderNodeObject<UniformNode<number>>;

constructor(textureNode: Node, depthNode: Node, normalNode: Node, camera: Camera);

getTextureNode(): ShaderNodeObject<TextureNode>;

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

export const ao: (
node: NodeRepresentation,
depthNode: NodeRepresentation,
normalNode: NodeRepresentation,
camera: Camera,
) => ShaderNodeObject<GTAONode>;

declare module "../shadernode/ShaderNode.js" {
interface NodeElements {
ao: typeof ao;
}
}

export default GTAONode;
Loading