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: Vertex shader revision #1446

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
24 changes: 12 additions & 12 deletions src-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ 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 04762469..c62335d9 100644
index ba31bcab..f564d2c4 100644
--- a/src-testing/src/nodes/code/CodeNode.ts
+++ b/src-testing/src/nodes/code/CodeNode.ts
@@ -1,5 +1,6 @@
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 c7f478be..9bc47f27 100644
index c8f9e293..1bb9e4c4 100644
--- a/src-testing/src/nodes/core/ContextNode.ts
+++ b/src-testing/src/nodes/core/ContextNode.ts
@@ -1,5 +1,6 @@
Expand Down Expand Up @@ -598,7 +598,7 @@ index c7f478be..9bc47f27 100644
/**
@@ -67,15 +73,15 @@ class ContextNode extends Node {
* @param {NodeBuilder} builder - The current node builder.
* @return {String} The type of {@link ContextNode#node}.
* @return {String} The node type.
*/
- getNodeType(builder) {
+ getNodeType(builder: NodeBuilder) {
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 7da88417..01d12e80 100644
index eb1dadc7..36ade03e 100644
--- a/src-testing/src/nodes/core/StackNode.ts
+++ b/src-testing/src/nodes/core/StackNode.ts
@@ -1,6 +1,7 @@
Expand Down Expand Up @@ -2812,7 +2812,7 @@ index 2efc188e..8fe0929f 100644

this.name = data.name;
diff --git a/src-testing/src/nodes/core/UniformNode.ts b/src-testing/src/nodes/core/UniformNode.ts
index c086bae5..ce0f8a5c 100644
index ed22aef6..35e8ae47 100644
--- a/src-testing/src/nodes/core/UniformNode.ts
+++ b/src-testing/src/nodes/core/UniformNode.ts
@@ -1,6 +1,10 @@
Expand Down Expand Up @@ -2975,7 +2975,7 @@ index 49c06f8f..eb4ac132 100644
+export const shaderStages: NodeShaderStage[] = [...defaultShaderStages, 'compute'];
export const vectorComponents = ['x', 'y', 'z', 'w'];
diff --git a/src-testing/src/nodes/lighting/LightingContextNode.ts b/src-testing/src/nodes/lighting/LightingContextNode.ts
index 65534abd..d6fc481f 100644
index 1aa67531..25a4bd72 100644
--- a/src-testing/src/nodes/lighting/LightingContextNode.ts
+++ b/src-testing/src/nodes/lighting/LightingContextNode.ts
@@ -1,5 +1,23 @@
Expand All @@ -3002,7 +3002,7 @@ index 65534abd..d6fc481f 100644
+}

/**
* `LightingContextNode` represents an extension of the {@link ContextNode} module
* `LightingContextNode` represents an extension of the {@link module:ContextNode~ContextNode} module
@@ -8,11 +26,17 @@ import { nodeProxy, float, vec3 } from '../tsl/TSLBase.js';
*
* @augments ContextNode
Expand All @@ -3023,8 +3023,8 @@ index 65534abd..d6fc481f 100644
* Constructs a new lighting context node.
*
@@ -21,7 +45,12 @@ class LightingContextNode extends ContextNode {
* @param {Node<vec3>} [backdropNode=null] - A backdrop node.
* @param {Node<float>} [backdropAlphaNode=null] - A backdrop alpha node.
* @param {Node<vec3>?} [backdropNode=null] - A backdrop node.
* @param {Node<float>?} [backdropAlphaNode=null] - A backdrop alpha node.
*/
- constructor(node, lightingModel = null, backdropNode = null, backdropAlphaNode = null) {
+ constructor(
Expand Down Expand Up @@ -3599,7 +3599,7 @@ index 2297154c..130b71de 100644
}

diff --git a/src-testing/src/renderers/common/Background.ts b/src-testing/src/renderers/common/Background.ts
index 8d112d45..513560a7 100644
index ab1f8b70..2ce6dfae 100644
--- a/src-testing/src/renderers/common/Background.ts
+++ b/src-testing/src/renderers/common/Background.ts
@@ -14,18 +14,33 @@ import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
Expand Down Expand Up @@ -8505,10 +8505,10 @@ index 7fd09a8c..88989e12 100644

const bindingSnippets = [];
diff --git a/src-testing/src/renderers/webgpu/nodes/WGSLNodeFunction.ts b/src-testing/src/renderers/webgpu/nodes/WGSLNodeFunction.ts
index cfee02b6..f4de8500 100644
index bf309808..fbd5a26a 100644
--- a/src-testing/src/renderers/webgpu/nodes/WGSLNodeFunction.ts
+++ b/src-testing/src/renderers/webgpu/nodes/WGSLNodeFunction.ts
@@ -134,7 +134,7 @@ class WGSLNodeFunction extends NodeFunction {
@@ -135,7 +135,7 @@ class WGSLNodeFunction extends NodeFunction {
*
* @param {String} source - The WGSL source.
*/
Expand Down
2 changes: 1 addition & 1 deletion three.js
Submodule three.js updated 82 files
+1 −1 examples/jsm/materials/LDrawConditionalLineNodeMaterial.js
+1 −1 examples/jsm/objects/SkyMesh.js
+3 −3 examples/jsm/tsl/display/SMAANode.js
+ examples/screenshots/webgpu_instance_sprites.jpg
+ examples/screenshots/webgpu_tsl_galaxy.jpg
+3 −2 src/Three.TSL.js
+2 −2 src/cameras/PerspectiveCamera.js
+2 −2 src/materials/nodes/Line2NodeMaterial.js
+24 −12 src/materials/nodes/NodeMaterial.js
+9 −15 src/materials/nodes/SpriteNodeMaterial.js
+0 −1 src/nodes/Nodes.js
+63 −0 src/nodes/accessors/BufferNode.js
+16 −5 src/nodes/accessors/ModelNode.js
+2 −40 src/nodes/accessors/ModelViewProjectionNode.js
+58 −1 src/nodes/accessors/Normal.js
+10 −5 src/nodes/accessors/Position.js
+7 −7 src/nodes/accessors/ReferenceNode.js
+36 −0 src/nodes/accessors/Tangent.js
+1 −1 src/nodes/accessors/TextureSizeNode.js
+2 −2 src/nodes/accessors/UV.js
+126 −5 src/nodes/accessors/UniformArrayNode.js
+4 −4 src/nodes/accessors/UserDataNode.js
+2 −2 src/nodes/accessors/VertexColorNode.js
+4 −4 src/nodes/code/CodeNode.js
+1 −1 src/nodes/code/ExpressionNode.js
+1 −1 src/nodes/core/AssignNode.js
+1 −1 src/nodes/core/AttributeNode.js
+1 −1 src/nodes/core/BypassNode.js
+1 −1 src/nodes/core/CacheNode.js
+5 −5 src/nodes/core/ContextNode.js
+1 −1 src/nodes/core/MRTNode.js
+1 −1 src/nodes/core/OutputStructNode.js
+1 −1 src/nodes/core/ParameterNode.js
+1 −1 src/nodes/core/StackNode.js
+1 −1 src/nodes/core/UniformNode.js
+1 −1 src/nodes/core/VarNode.js
+15 −2 src/nodes/core/VaryingNode.js
+10 −0 src/nodes/display/BumpMapNode.js
+2 −2 src/nodes/display/ColorSpaceNode.js
+1 −1 src/nodes/display/NormalMapNode.js
+12 −11 src/nodes/display/PassNode.js
+1 −1 src/nodes/display/PosterizeNode.js
+3 −3 src/nodes/display/RenderOutputNode.js
+44 −2 src/nodes/display/ScreenNode.js
+18 −1 src/nodes/display/ToneMappingNode.js
+13 −0 src/nodes/display/ToonOutlinePassNode.js
+85 −9 src/nodes/display/ViewportDepthNode.js
+12 −2 src/nodes/display/ViewportDepthTextureNode.js
+11 −1 src/nodes/display/ViewportSharedTextureNode.js
+22 −1 src/nodes/display/ViewportTextureNode.js
+1 −1 src/nodes/functions/PhongLightingModel.js
+1 −1 src/nodes/geometry/RangeNode.js
+3 −2 src/nodes/lighting/AONode.js
+7 −4 src/nodes/lighting/AnalyticLightNode.js
+2 −2 src/nodes/lighting/BasicLightMapNode.js
+1 −1 src/nodes/lighting/EnvironmentNode.js
+7 −7 src/nodes/lighting/LightingContextNode.js
+2 −1 src/nodes/lighting/PointShadowNode.js
+1 −1 src/nodes/lighting/ShadowBaseNode.js
+1 −1 src/nodes/lighting/ShadowNode.js
+14 −2 src/nodes/math/ConditionalNode.js
+2 −4 src/nodes/math/MathNode.js
+1 −1 src/nodes/math/MathUtils.js
+194 −0 src/nodes/math/OperatorNode.js
+1 −1 src/nodes/pmrem/PMREMNode.js
+1 −1 src/nodes/procedural/Checker.js
+1 −1 src/nodes/utils/ArrayElementNode.js
+9 −0 src/nodes/utils/CubeMapNode.js
+10 −1 src/nodes/utils/EquirectUVNode.js
+9 −0 src/nodes/utils/FunctionOverloadingNode.js
+24 −1 src/nodes/utils/LoopNode.js
+8 −0 src/nodes/utils/MatcapUVNode.js
+10 −1 src/nodes/utils/MaxMipLevelNode.js
+23 −1 src/nodes/utils/RTTNode.js
+23 −5 src/nodes/utils/ReflectorNode.js
+25 −0 src/nodes/utils/RemapNode.js
+11 −0 src/nodes/utils/RotateNode.js
+11 −0 src/nodes/utils/SpriteSheetUVNode.js
+10 −0 src/nodes/utils/StorageArrayElementNode.js
+27 −0 src/nodes/utils/TriplanarTexturesNode.js
+1 −1 src/renderers/common/Background.js
+1 −0 src/renderers/webgpu/nodes/WGSLNodeFunction.js
5 changes: 3 additions & 2 deletions types/three/src/Three.TSL.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ export const grayscale: typeof TSL.grayscale;
export const greaterThan: typeof TSL.greaterThan;
export const greaterThanEqual: typeof TSL.greaterThanEqual;
export const hash: typeof TSL.hash;
export const highPrecisionModelNormalViewMatrix: typeof TSL.highPrecisionModelNormalViewMatrix;
export const highPrecisionModelViewMatrix: typeof TSL.highPrecisionModelViewMatrix;
export const highpModelNormalViewMatrix: typeof TSL.highpModelNormalViewMatrix;
export const highPrecisionModelViewMatrix: typeof TSL.highpModelViewMatrix;
export const hue: typeof TSL.hue;
export const instance: typeof TSL.instance;
export const instanceIndex: typeof TSL.instanceIndex;
Expand Down Expand Up @@ -223,6 +223,7 @@ export const log2: typeof TSL.log2;
export const logarithmicDepthToViewZ: typeof TSL.logarithmicDepthToViewZ;
export const loop: typeof TSL.loop;
export const luminance: typeof TSL.luminance;
export const mediumpModelViewMatrix: typeof TSL.mediumpModelViewMatrix;
export const mat2: typeof TSL.mat2;
export const mat3: typeof TSL.mat3;
export const mat4: typeof TSL.mat4;
Expand Down
2 changes: 2 additions & 0 deletions types/three/src/materials/nodes/NodeMaterial.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ declare class NodeMaterial extends Material {
setupClipping(builder: NodeBuilder): ClippingNode | null;
setupHardwareClipping(builder: NodeBuilder): void;
setupDepth(builder: NodeBuilder): void;
setupPositionView(): Node;
setupVertex(builder: NodeBuilder): Node;
setupPosition(builder: NodeBuilder): Node;
setupDiffuseColor(builder: NodeBuilder): void;
setupVariants(builder: NodeBuilder): void;
Expand Down
1 change: 0 additions & 1 deletion types/three/src/nodes/Nodes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export { default as InstanceNode } from "./accessors/InstanceNode.js";
export { default as MaterialNode, MaterialNodeScope } from "./accessors/MaterialNode.js";
export { default as MaterialReferenceNode } from "./accessors/MaterialReferenceNode.js";
export { default as ModelNode } from "./accessors/ModelNode.js";
export { default as ModelViewProjectionNode } from "./accessors/ModelViewProjectionNode.js";
export { default as MorphNode } from "./accessors/MorphNode.js";
export { default as Object3DNode } from "./accessors/Object3DNode.js";
export { default as PointUVNode } from "./accessors/PointUVNode.js";
Expand Down
12 changes: 10 additions & 2 deletions types/three/src/nodes/accessors/ModelNode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ export const modelScale: ShaderNodeObject<ModelNode>;
export const modelViewPosition: ShaderNodeObject<ModelNode>;
export const modelNormalMatrix: ShaderNodeObject<Node>;
export const modelWorldMatrixInverse: ShaderNodeObject<UniformNode<Matrix4>>;

export const modelViewMatrix: ShaderNodeObject<ModelNode>;

export const highPrecisionModelViewMatrix: ShaderNodeObject<Node>;
export const highPrecisionModelNormalViewMatrix: ShaderNodeObject<Node>;
// GPU Precision

export const mediumpModelViewMatrix: ShaderNodeObject<Node>;

// CPU Precision

export const highpModelViewMatrix: ShaderNodeObject<Node>;

export const highpModelNormalViewMatrix: ShaderNodeObject<Node>;
8 changes: 2 additions & 6 deletions types/three/src/nodes/accessors/ModelViewProjectionNode.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import Node from "../core/Node.js";
import { NodeRepresentation, ShaderNodeObject } from "../tsl/TSLCore.js";
import { ShaderNodeObject } from "../tsl/TSLCore.js";

export default class ModelViewProjectionNode extends Node {
constructor(positionNode?: Node);
}

export const modelViewProjection: (position?: NodeRepresentation) => ShaderNodeObject<ModelViewProjectionNode>;
export const modelViewProjection: ShaderNodeObject<Node>;
2 changes: 1 addition & 1 deletion types/three/src/nodes/core/UniformNode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ declare class UniformNode<TValue> extends InputNode<TValue> {
}
export default UniformNode;
/**
* TSL function for creating a uniform node with the given paramters.
* TSL function for creating a uniform node.
*
* @function
* @param {Any} arg1 - The value of this node. Usually a JS primitive or three.js object (vector, matrix, color, texture).
Expand Down
Loading