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

TSL: Introduce node.toTexture() and rtt() #1087

Merged
merged 8 commits into from
Jul 20, 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
18 changes: 17 additions & 1 deletion examples-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -14352,7 +14352,7 @@ index c11a18ed..bfcafe6d 100644
init();

diff --git a/examples-testing/examples/webgpu_postprocessing.ts b/examples-testing/examples/webgpu_postprocessing.ts
index 35945f71..57ca54a4 100644
index d83642f2..96b1bc0e 100644
--- a/examples-testing/examples/webgpu_postprocessing.ts
+++ b/examples-testing/examples/webgpu_postprocessing.ts
@@ -1,8 +1,8 @@
Expand Down Expand Up @@ -14456,6 +14456,22 @@ index cbc5a96b..66ec682e 100644

const params = {
enable: true,
diff --git a/examples-testing/examples/webgpu_procedural_texture.ts b/examples-testing/examples/webgpu_procedural_texture.ts
index d4228f90..191b58f2 100644
--- a/examples-testing/examples/webgpu_procedural_texture.ts
+++ b/examples-testing/examples/webgpu_procedural_texture.ts
@@ -1,9 +1,9 @@
-import * as THREE from 'three';
+import * as THREE from 'three/webgpu';
import { checker, uv, uniform } from 'three/tsl';

import { GUI } from 'three/addons/libs/lil-gui.module.min.js';

-let camera, scene, renderer;
+let camera: THREE.OrthographicCamera, scene: THREE.Scene, renderer: THREE.WebGPURenderer;

init();
render();
diff --git a/examples-testing/examples/webgpu_refraction.ts b/examples-testing/examples/webgpu_refraction.ts
index dc018c6d..6c7faf4d 100644
--- a/examples-testing/examples/webgpu_refraction.ts
Expand Down
16 changes: 8 additions & 8 deletions src-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ index e4a040de..c52771e6 100644
addNodeElement('toAttribute', bufferNode => bufferAttribute(bufferNode.value));

diff --git a/src-testing/src/nodes/accessors/TextureNode.ts b/src-testing/src/nodes/accessors/TextureNode.ts
index 15422533..66c4e5bc 100644
index 870ae096..6d2f1b05 100644
--- a/src-testing/src/nodes/accessors/TextureNode.ts
+++ b/src-testing/src/nodes/accessors/TextureNode.ts
@@ -3,15 +3,37 @@ import { uv } from './UVNode.js';
Expand Down Expand Up @@ -254,9 +254,9 @@ index 15422533..66c4e5bc 100644
- setup(builder) {
+ setup(builder: NodeBuilder) {
const properties = builder.getNodeProperties(this);
properties.referenceNode = this.referenceNode;

//
@@ -137,11 +159,19 @@ class TextureNode extends UniformNode {
@@ -138,11 +160,19 @@ class TextureNode extends UniformNode {
properties.depthNode = this.depthNode;
}

Expand All @@ -278,7 +278,7 @@ index 15422533..66c4e5bc 100644
const texture = this.value;

let snippet;
@@ -161,7 +191,7 @@ class TextureNode extends UniformNode {
@@ -162,7 +192,7 @@ class TextureNode extends UniformNode {
return snippet;
}

Expand All @@ -287,7 +287,7 @@ index 15422533..66c4e5bc 100644
const properties = builder.getNodeProperties(this);

const texture = this.value;
@@ -225,7 +255,7 @@ class TextureNode extends UniformNode {
@@ -226,7 +256,7 @@ class TextureNode extends UniformNode {
}
}

Expand All @@ -296,7 +296,7 @@ index 15422533..66c4e5bc 100644
this.sampler = value;

return this;
@@ -237,7 +267,7 @@ class TextureNode extends UniformNode {
@@ -238,7 +268,7 @@ class TextureNode extends UniformNode {

// @TODO: Move to TSL

Expand All @@ -305,7 +305,7 @@ index 15422533..66c4e5bc 100644
const textureNode = this.clone();
textureNode.uvNode = uvNode;
textureNode.referenceNode = this;
@@ -245,7 +275,7 @@ class TextureNode extends UniformNode {
@@ -246,7 +276,7 @@ class TextureNode extends UniformNode {
return nodeObject(textureNode);
}

Expand All @@ -314,7 +314,7 @@ index 15422533..66c4e5bc 100644
const textureNode = this.clone();
textureNode.levelNode = levelNode.mul(maxMipLevel(textureNode));
textureNode.referenceNode = this;
@@ -253,7 +283,7 @@ class TextureNode extends UniformNode {
@@ -254,7 +284,7 @@ class TextureNode extends UniformNode {
return nodeObject(textureNode);
}

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 @@ -176,6 +176,7 @@ export { default as ReflectorNode, reflector, ReflectorNodeParameters } from "./
export { default as RemapNode, remap, remapClamp } from "./utils/RemapNode.js";
export { default as RotateNode, rotate } from "./utils/RotateNode.js";
export { default as RotateUVNode, rotateUV } from "./utils/RotateUVNode.js";
export { default as RTTNode, rtt, RTTNodeOptions } from "./utils/RTTNode.js";
export { default as SplitNode } from "./utils/SplitNode.js";
export { default as SpriteSheetUVNode, spritesheetUV } from "./utils/SpriteSheetUVNode.js";
export { default as StorageArrayElementNode } from "./utils/SpriteSheetUVNode.js";
Expand Down
11 changes: 7 additions & 4 deletions types/three/src/nodes/display/GaussianBlurNode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,23 @@ import { NodeRepresentation, ShaderNodeObject } from "../shadernode/ShaderNode.j

export default class GaussianBlurNode extends TempNode {
textureNode: TextureNode;
directionNode: Node | null;
sigma: number;

directionNode: Node;

resolution: Vector2;

constructor(textureNode: TextureNode, sigma?: number);
constructor(textureNode: TextureNode, directionNode?: Node | null, sigma?: number);

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

getTextureNode(): TextureNode;
}

export const gaussianBlur: (node: NodeRepresentation, sigma?: number) => ShaderNodeObject<GaussianBlurNode>;
export const gaussianBlur: (
node: NodeRepresentation,
directionNode?: NodeRepresentation | null,
sigma?: number,
) => ShaderNodeObject<GaussianBlurNode>;

declare module "../shadernode/ShaderNode.js" {
interface NodeElements {
Expand Down
41 changes: 41 additions & 0 deletions types/three/src/nodes/utils/RTTNode.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { TextureDataType } from "../../constants.js";
import { RenderTarget } from "../../core/RenderTarget.js";
import TextureNode from "../accessors/TextureNode.js";
import Node from "../core/Node.js";
import { NodeRepresentation, ShaderNodeObject } from "../shadernode/ShaderNode.js";

export interface RTTNodeOptions {
type: TextureDataType;
}

declare class RTTNode extends TextureNode {
node: Node;
width: number | null;
height: number | null;

renderTarget: RenderTarget | null;

textureNeedsUpdate: boolean;
autoUpdate: boolean;

constructor(node: Node, width?: number | null, height?: number | null, options?: RTTNodeOptions);

get autoSize(): boolean;

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

export default RTTNode;

export const rtt: (
node: NodeRepresentation,
width?: number | null,
height?: number | null,
options?: RTTNodeOptions,
) => ShaderNodeObject<RTTNode>;

declare module "../shadernode/ShaderNode.js" {
interface NodeElements {
toTexture: typeof rtt;
}
}
2 changes: 1 addition & 1 deletion update-three.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cd ../three.js
cd three.js
git fetch
git checkout $1
cd ..
Expand Down
Loading