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: Add texture_depth_multisampled_2d for wgslFn #1445

Merged
merged 5 commits into from
Dec 15, 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
97 changes: 49 additions & 48 deletions src-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -458,17 +458,17 @@ index 4841d46c..d69010bc 100644
textureNode.levelNode = nodeObject(levelNode);
textureNode.referenceNode = this.getSelf();
diff --git a/src-testing/src/nodes/code/CodeNode.ts b/src-testing/src/nodes/code/CodeNode.ts
index 140e564d..c01f9349 100644
index 04762469..c62335d9 100644
--- a/src-testing/src/nodes/code/CodeNode.ts
+++ b/src-testing/src/nodes/code/CodeNode.ts
@@ -1,5 +1,6 @@
import Node from '../core/Node.js';
import { nodeProxy } from '../tsl/TSLBase.js';
+import NodeBuilder from '../core/NodeBuilder.js';

/**
* This class represents native code sections. It is the base
@@ -13,6 +14,11 @@ class CodeNode extends Node {
/** @module CodeNode **/

@@ -15,6 +16,11 @@ class CodeNode extends Node {
return 'CodeNode';
}

Expand All @@ -480,7 +480,7 @@ index 140e564d..c01f9349 100644
/**
* Constructs a new code node.
*
@@ -84,11 +90,11 @@ class CodeNode extends Node {
@@ -86,11 +92,11 @@ class CodeNode extends Node {
* @param {NodeBuilder} builder - The current node builder.
* @return {Array<Node>} The includes.
*/
Expand Down Expand Up @@ -559,7 +559,7 @@ index 75c17de0..dcea81cc 100644
+export const glslFn = (code: string, includes) => nativeFn(code, includes, 'glsl');
+export const wgslFn = (code: string, includes) => nativeFn(code, includes, 'wgsl');
diff --git a/src-testing/src/nodes/core/ContextNode.ts b/src-testing/src/nodes/core/ContextNode.ts
index dd4b5cba..5a997eef 100644
index c7f478be..9bc47f27 100644
--- a/src-testing/src/nodes/core/ContextNode.ts
+++ b/src-testing/src/nodes/core/ContextNode.ts
@@ -1,5 +1,6 @@
Expand All @@ -568,9 +568,9 @@ index dd4b5cba..5a997eef 100644
+import { addMethodChaining, nodeProxy, NodeRepresentation } from '../tsl/TSLCore.js';
+import NodeBuilder from './NodeBuilder.js';

/**
* This node can be used as a context management component for another node.
@@ -11,18 +12,23 @@ import { addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
/** @module ContextNode **/

@@ -13,18 +14,23 @@ import { addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
*```
* @augments Node
*/
Expand All @@ -596,7 +596,7 @@ index dd4b5cba..5a997eef 100644
super();

/**
@@ -65,15 +71,15 @@ class ContextNode extends Node {
@@ -67,15 +73,15 @@ class ContextNode extends Node {
* @param {NodeBuilder} builder - The current node builder.
* @return {String} The type of {@link ContextNode#node}.
*/
Expand All @@ -615,7 +615,7 @@ index dd4b5cba..5a997eef 100644
const previousContext = builder.getContext();

builder.setContext({ ...builder.context, ...this.value });
@@ -85,7 +91,7 @@ class ContextNode extends Node {
@@ -87,7 +93,7 @@ class ContextNode extends Node {
return node;
}

Expand All @@ -624,10 +624,10 @@ index dd4b5cba..5a997eef 100644
const previousContext = builder.getContext();

builder.setContext({ ...builder.context, ...this.value });
@@ -101,7 +107,7 @@ class ContextNode extends Node {
export default ContextNode;

export const context = /*@__PURE__*/ nodeProxy(ContextNode);
@@ -120,7 +126,7 @@ export const context = /*@__PURE__*/ nodeProxy(ContextNode);
* @param {String} name - The name/label to set.
* @returns {ContextNode}
*/
-export const label = (node, name) => context(node, { label: name });
+export const label = (node: NodeRepresentation, name: string) => context(node, { label: name });

Expand Down Expand Up @@ -2669,7 +2669,7 @@ index 8a291b92..39c864a4 100644

/**
diff --git a/src-testing/src/nodes/core/StackNode.ts b/src-testing/src/nodes/core/StackNode.ts
index e0c3d103..6152b031 100644
index 7da88417..01d12e80 100644
--- a/src-testing/src/nodes/core/StackNode.ts
+++ b/src-testing/src/nodes/core/StackNode.ts
@@ -1,6 +1,7 @@
Expand All @@ -2679,9 +2679,9 @@ index e0c3d103..6152b031 100644
+import { ShaderNode, nodeProxy, getCurrentStack, setCurrentStack, ShaderNodeObject } from '../tsl/TSLBase.js';
+import NodeBuilder from './NodeBuilder.js';

/**
* Stack is a helper for Nodes that need to produce stack-based code instead of continuous flow.
@@ -13,6 +14,15 @@ class StackNode extends Node {
/** @module StackNode **/

@@ -15,6 +16,15 @@ class StackNode extends Node {
return 'StackNode';
}

Expand All @@ -2697,7 +2697,7 @@ index e0c3d103..6152b031 100644
/**
* Constructs a new stack node.
*
@@ -63,7 +73,7 @@ class StackNode extends Node {
@@ -65,7 +75,7 @@ class StackNode extends Node {
this.isStackNode = true;
}

Expand All @@ -2706,7 +2706,7 @@ index e0c3d103..6152b031 100644
return this.outputNode ? this.outputNode.getNodeType(builder) : 'void';
}

@@ -73,7 +83,7 @@ class StackNode extends Node {
@@ -75,7 +85,7 @@ class StackNode extends Node {
* @param {Node} node - The node to add.
* @return {StackNode} A reference to this stack node.
*/
Expand All @@ -2715,7 +2715,7 @@ index e0c3d103..6152b031 100644
this.nodes.push(node);

return this;
@@ -86,7 +96,7 @@ class StackNode extends Node {
@@ -88,7 +98,7 @@ class StackNode extends Node {
* @param {Function} method - TSL code which is executed if the condition evaluates to `true`.
* @return {StackNode} A reference to this stack node.
*/
Expand All @@ -2724,7 +2724,7 @@ index e0c3d103..6152b031 100644
const methodNode = new ShaderNode(method);
this._currentCond = select(boolNode, methodNode);

@@ -100,7 +110,7 @@ class StackNode extends Node {
@@ -102,7 +112,7 @@ class StackNode extends Node {
* @param {Function} method - TSL code which is executed if the condition evaluates to `true`.
* @return {StackNode} A reference to this stack node.
*/
Expand All @@ -2733,7 +2733,7 @@ index e0c3d103..6152b031 100644
const methodNode = new ShaderNode(method);
const ifNode = select(boolNode, methodNode);

@@ -116,13 +126,13 @@ class StackNode extends Node {
@@ -118,13 +128,13 @@ class StackNode extends Node {
* @param {Function} method - TSL code which is executed in the `else` case.
* @return {StackNode} A reference to this stack node.
*/
Expand Down Expand Up @@ -2773,16 +2773,16 @@ index d698c2fb..90dc52b0 100644

/**
diff --git a/src-testing/src/nodes/core/UniformGroupNode.ts b/src-testing/src/nodes/core/UniformGroupNode.ts
index 3c7fc425..e6677c50 100644
index 2efc188e..8fe0929f 100644
--- a/src-testing/src/nodes/core/UniformGroupNode.ts
+++ b/src-testing/src/nodes/core/UniformGroupNode.ts
@@ -1,4 +1,4 @@
-import Node from './Node.js';
+import Node, { NodeJSONInputData, NodeJSONIntermediateOutputData } from './Node.js';

/**
* This node can be used to group single instances of {@link UniformNode}
@@ -18,6 +18,10 @@ class UniformGroupNode extends Node {
/** @module UniformGroupNode **/

@@ -20,6 +20,10 @@ class UniformGroupNode extends Node {
return 'UniformGroupNode';
}

Expand All @@ -2793,7 +2793,7 @@ index 3c7fc425..e6677c50 100644
/**
* Constructs a new uniform group node.
*
@@ -62,7 +66,7 @@ class UniformGroupNode extends Node {
@@ -64,7 +68,7 @@ class UniformGroupNode extends Node {
this.isUniformGroup = true;
}

Expand All @@ -2802,7 +2802,7 @@ index 3c7fc425..e6677c50 100644
super.serialize(data);

data.name = this.name;
@@ -70,7 +74,7 @@ class UniformGroupNode extends Node {
@@ -72,7 +76,7 @@ class UniformGroupNode extends Node {
data.shared = this.shared;
}

Expand All @@ -2812,10 +2812,10 @@ index 3c7fc425..e6677c50 100644

this.name = data.name;
diff --git a/src-testing/src/nodes/core/UniformNode.ts b/src-testing/src/nodes/core/UniformNode.ts
index c85b4aae..7f3d18cc 100644
index c086bae5..ce0f8a5c 100644
--- a/src-testing/src/nodes/core/UniformNode.ts
+++ b/src-testing/src/nodes/core/UniformNode.ts
@@ -1,24 +1,33 @@
@@ -1,6 +1,10 @@
import InputNode from './InputNode.js';
-import { objectGroup } from './UniformGroupNode.js';
+import UniformGroupNode, { objectGroup } from './UniformGroupNode.js';
Expand All @@ -2825,8 +2825,9 @@ index c85b4aae..7f3d18cc 100644
+import NodeFrame from './NodeFrame.js';
+import { NodeUpdateType } from './constants.js';

/**
* Class for representing a uniform.
/** @module UniformNode **/

@@ -9,18 +13,23 @@ import { nodeObject, getConstNodeType } from '../tsl/TSLCore.js';
*
* @augments InputNode
*/
Expand All @@ -2852,7 +2853,7 @@ index c85b4aae..7f3d18cc 100644
super(value, nodeType);

/**
@@ -54,7 +63,7 @@ class UniformNode extends InputNode {
@@ -56,7 +65,7 @@ class UniformNode extends InputNode {
* @param {String} name - The name of the uniform.
* @return {UniformNode} A reference to this node.
*/
Expand All @@ -2861,7 +2862,7 @@ index c85b4aae..7f3d18cc 100644
this.name = name;

return this;
@@ -66,7 +75,7 @@ class UniformNode extends InputNode {
@@ -68,7 +77,7 @@ class UniformNode extends InputNode {
* @param {UniformGroupNode} group - The uniform group.
* @return {UniformNode} A reference to this node.
*/
Expand All @@ -2870,7 +2871,7 @@ index c85b4aae..7f3d18cc 100644
this.groupNode = group;

return this;
@@ -88,11 +97,11 @@ class UniformNode extends InputNode {
@@ -90,11 +99,11 @@ class UniformNode extends InputNode {
* @param {NodeBuilder} builder - The current node builder.
* @return {String} The uniform hash.
*/
Expand All @@ -2884,7 +2885,7 @@ index c85b4aae..7f3d18cc 100644
const self = this.getSelf();

callback = callback.bind(self);
@@ -106,12 +115,12 @@ class UniformNode extends InputNode {
@@ -108,12 +117,12 @@ class UniformNode extends InputNode {
}, updateType);
}

Expand All @@ -2899,7 +2900,7 @@ index c85b4aae..7f3d18cc 100644

if (sharedNode === undefined) {
builder.setHashNode(this, hash);
@@ -124,7 +133,7 @@ class UniformNode extends InputNode {
@@ -126,7 +135,7 @@ class UniformNode extends InputNode {
const nodeUniform = builder.getUniformFromNode(
sharedNode,
sharedNodeType,
Expand All @@ -2908,10 +2909,10 @@ index c85b4aae..7f3d18cc 100644
this.name || builder.context.label,
);
const propertyName = builder.getPropertyName(nodeUniform);
@@ -137,11 +146,14 @@ class UniformNode extends InputNode {

export default UniformNode;

@@ -147,11 +156,14 @@ export default UniformNode;
* @param {String?} arg2 - The node type. If no explicit type is defined, the node tries to derive the type from its value.
* @returns {UniformNode}
*/
-export const uniform = (arg1, arg2) => {
+export const uniform = <TValue>(arg1: InputNode<TValue> | TValue, arg2?: Node | string) => {
const nodeType = getConstNodeType(arg2 || arg1);
Expand All @@ -2926,10 +2927,10 @@ index c85b4aae..7f3d18cc 100644
return nodeObject(new UniformNode(value, nodeType));
};
diff --git a/src-testing/src/nodes/core/constants.ts b/src-testing/src/nodes/core/constants.ts
index 1fe2dbbd..a431897f 100644
index 49c06f8f..eb4ac132 100644
--- a/src-testing/src/nodes/core/constants.ts
+++ b/src-testing/src/nodes/core/constants.ts
@@ -7,7 +7,7 @@
@@ -9,7 +9,7 @@
export const NodeShaderStage = {
VERTEX: 'vertex',
FRAGMENT: 'fragment',
Expand All @@ -2938,7 +2939,7 @@ index 1fe2dbbd..a431897f 100644

/**
* Update types of a node.
@@ -22,7 +22,7 @@ export const NodeUpdateType = {
@@ -24,7 +24,7 @@ export const NodeUpdateType = {
FRAME: 'frame',
RENDER: 'render',
OBJECT: 'object',
Expand All @@ -2947,7 +2948,7 @@ index 1fe2dbbd..a431897f 100644

/**
* Data types of a node.
@@ -47,7 +47,7 @@ export const NodeType = {
@@ -49,7 +49,7 @@ export const NodeType = {
MATRIX2: 'mat2',
MATRIX3: 'mat3',
MATRIX4: 'mat4',
Expand All @@ -2956,7 +2957,7 @@ index 1fe2dbbd..a431897f 100644

/**
* Access types of a node. These are relevant for compute and storage usage.
@@ -60,9 +60,13 @@ export const NodeAccess = {
@@ -62,9 +62,13 @@ export const NodeAccess = {
READ_ONLY: 'readOnly',
WRITE_ONLY: 'writeOnly',
READ_WRITE: 'readWrite',
Expand Down
2 changes: 1 addition & 1 deletion three.js
Submodule three.js updated 87 files
+0 −3 .eslintrc.json
+5 −5 editor/js/commands/AddObjectCommand.js
+6 −6 editor/js/commands/AddScriptCommand.js
+7 −7 editor/js/commands/MoveObjectCommand.js
+5 −5 editor/js/commands/MultiCmdsCommand.js
+5 −5 editor/js/commands/RemoveObjectCommand.js
+6 −6 editor/js/commands/RemoveScriptCommand.js
+7 −7 editor/js/commands/SetColorCommand.js
+6 −7 editor/js/commands/SetGeometryCommand.js
+7 −7 editor/js/commands/SetGeometryValueCommand.js
+8 −7 editor/js/commands/SetMaterialColorCommand.js
+7 −6 editor/js/commands/SetMaterialCommand.js
+8 −7 editor/js/commands/SetMaterialMapCommand.js
+9 −8 editor/js/commands/SetMaterialRangeCommand.js
+8 −7 editor/js/commands/SetMaterialValueCommand.js
+9 −0 editor/js/commands/SetMaterialVectorCommand.js
+7 −7 editor/js/commands/SetPositionCommand.js
+7 −7 editor/js/commands/SetRotationCommand.js
+7 −7 editor/js/commands/SetScaleCommand.js
+5 −5 editor/js/commands/SetSceneCommand.js
+8 −8 editor/js/commands/SetScriptValueCommand.js
+7 −7 editor/js/commands/SetShadowValueCommand.js
+6 −6 editor/js/commands/SetUuidCommand.js
+7 −7 editor/js/commands/SetValueCommand.js
+24 −15 examples/jsm/controls/ArcballControls.js
+11 −7 examples/jsm/exporters/GLTFExporter.js
+2 −0 examples/jsm/loaders/GLTFLoader.js
+4 −4 examples/jsm/loaders/KTXLoader.js
+1 −0 examples/jsm/loaders/MTLLoader.js
+19 −11 examples/jsm/misc/Volume.js
+2 −2 examples/jsm/misc/VolumeSlice.js
+3 −1 examples/jsm/modifiers/CurveModifier.js
+4 −2 examples/jsm/modifiers/CurveModifierGPU.js
+1 −1 examples/jsm/utils/BufferGeometryUtils.js
+4 −1 examples/jsm/utils/CameraUtils.js
+22 −19 examples/jsm/utils/GeometryUtils.js
+2 −2 examples/jsm/utils/SceneUtils.js
+1 −1 examples/jsm/webxr/XRControllerModelFactory.js
+3 −3 examples/webgl_loader_texture_dds.html
+49 −0 src/nodes/accessors/Camera.js
+26 −0 src/nodes/accessors/PointUVNode.js
+44 −0 src/nodes/accessors/Position.js
+199 −2 src/nodes/accessors/ReferenceNode.js
+54 −0 src/nodes/accessors/SceneNode.js
+1 −1 src/nodes/accessors/StorageBufferNode.js
+42 −0 src/nodes/accessors/TextureSizeNode.js
+9 −0 src/nodes/accessors/UV.js
+46 −0 src/nodes/accessors/UserDataNode.js
+82 −0 src/nodes/accessors/VelocityNode.js
+39 −2 src/nodes/accessors/VertexColorNode.js
+37 −0 src/nodes/code/CodeNode.js
+10 −0 src/nodes/code/ExpressionNode.js
+10 −0 src/nodes/core/AssignNode.js
+10 −0 src/nodes/core/AttributeNode.js
+10 −0 src/nodes/core/BypassNode.js
+11 −1 src/nodes/core/CacheNode.js
+19 −0 src/nodes/core/ContextNode.js
+37 −0 src/nodes/core/IndexNode.js
+9 −0 src/nodes/core/MRTNode.js
+9 −0 src/nodes/core/OutputStructNode.js
+7 −3 src/nodes/core/ParameterNode.js
+9 −0 src/nodes/core/StackNode.js
+35 −0 src/nodes/core/UniformGroupNode.js
+10 −0 src/nodes/core/UniformNode.js
+10 −0 src/nodes/core/VarNode.js
+10 −0 src/nodes/core/VaryingNode.js
+2 −0 src/nodes/core/constants.js
+43 −0 src/nodes/display/ColorSpaceNode.js
+14 −0 src/nodes/display/FrontFacingNode.js
+10 −0 src/nodes/display/NormalMapNode.js
+29 −2 src/nodes/display/PassNode.js
+10 −0 src/nodes/display/PosterizeNode.js
+11 −0 src/nodes/display/RenderOutputNode.js
+1 −1 src/nodes/display/ToonOutlinePassNode.js
+3 −1 src/nodes/fog/Fog.js
+1 −1 src/nodes/functions/PhongLightingModel.js
+10 −0 src/nodes/geometry/RangeNode.js
+4 −3 src/nodes/lighting/AnalyticLightNode.js
+111 −2 src/nodes/lighting/LightsNode.js
+53 −1 src/nodes/lighting/PointShadowNode.js
+50 −0 src/nodes/lighting/ShadowBaseNode.js
+203 −2 src/nodes/lighting/ShadowNode.js
+3 −3 src/nodes/math/MathUtils.js
+0 −2 src/nodes/math/TriNoise3D.js
+11 −0 src/nodes/pmrem/PMREMNode.js
+3 −3 src/nodes/utils/FunctionOverloadingNode.js
+1 −1 src/nodes/utils/ViewportUtils.js
9 changes: 9 additions & 0 deletions types/three/src/nodes/core/UniformNode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Node from "./Node.js";
import NodeBuilder from "./NodeBuilder.js";
import NodeFrame from "./NodeFrame.js";
import UniformGroupNode from "./UniformGroupNode.js";
/** @module UniformNode **/
/**
* Class for representing a uniform.
*
Expand Down Expand Up @@ -53,6 +54,14 @@ declare class UniformNode<TValue> extends InputNode<TValue> {
generate(builder: NodeBuilder, output: string | null): string;
}
export default UniformNode;
/**
* TSL function for creating a uniform node with the given paramters.
*
* @function
* @param {Any} arg1 - The value of this node. Usually a JS primitive or three.js object (vector, matrix, color, texture).
* @param {String?} arg2 - The node type. If no explicit type is defined, the node tries to derive the type from its value.
* @returns {UniformNode}
*/
export declare const uniform: <TValue>(
arg1: InputNode<TValue> | TValue,
arg2?: Node | string,
Expand Down
1 change: 1 addition & 0 deletions types/three/src/nodes/core/constants.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** @module NodeConstants **/
/**
* Possible shader stages.
*
Expand Down
2 changes: 1 addition & 1 deletion types/three/src/nodes/display/PassNode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ export default PassNode;

export const pass: (scene: Scene, camera: Camera, options?: RenderTargetOptions) => ShaderNodeObject<PassNode>;
export const passTexture: (pass: PassNode, texture: Texture) => ShaderNodeObject<PassTextureNode>;
export const depthPass: (scene: Scene, camera: Camera) => ShaderNodeObject<PassNode>;
export const depthPass: (scene: Scene, camera: Camera, options?: RenderTargetOptions) => ShaderNodeObject<PassNode>;
Loading