Skip to content

Commit b6942a6

Browse files
authored
TSL: Introduce boolean for uniform() (#1752)
* Update three.js * Add src * Update patch and delete src * Update declarations
1 parent 38b199b commit b6942a6

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

src-testing/changes.patch

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3124,7 +3124,7 @@ index 94299fca..125e9ad4 100644
31243124

31253125
this.name = data.name;
31263126
diff --git a/src-testing/src/nodes/core/UniformNode.ts b/src-testing/src/nodes/core/UniformNode.ts
3127-
index e32c25a3..80150b8b 100644
3127+
index 105882cc..93e816df 100644
31283128
--- a/src-testing/src/nodes/core/UniformNode.ts
31293129
+++ b/src-testing/src/nodes/core/UniformNode.ts
31303130
@@ -1,24 +1,33 @@
@@ -3205,10 +3205,19 @@ index e32c25a3..80150b8b 100644
32053205
const self = this.getSelf();
32063206

32073207
callback = callback.bind(self);
3208-
@@ -119,12 +128,12 @@ class UniformNode extends InputNode {
3208+
@@ -119,7 +128,7 @@ class UniformNode extends InputNode {
32093209
}, updateType);
32103210
}
32113211

3212+
- getInputType(builder) {
3213+
+ getInputType(builder: NodeBuilder) {
3214+
let type = super.getInputType(builder);
3215+
3216+
if (type === 'bool') {
3217+
@@ -129,12 +138,12 @@ class UniformNode extends InputNode {
3218+
return type;
3219+
}
3220+
32123221
- generate(builder, output) {
32133222
+ generate(builder: NodeBuilder, output: string | null) {
32143223
const type = this.getNodeType(builder);
@@ -3220,16 +3229,16 @@ index e32c25a3..80150b8b 100644
32203229

32213230
if (sharedNode === undefined) {
32223231
builder.setHashNode(this, hash);
3223-
@@ -137,7 +146,7 @@ class UniformNode extends InputNode {
3232+
@@ -147,7 +156,7 @@ class UniformNode extends InputNode {
32243233
const nodeUniform = builder.getUniformFromNode(
32253234
sharedNode,
32263235
sharedNodeType,
32273236
- builder.shaderStage,
32283237
+ builder.shaderStage!,
32293238
this.name || builder.context.label,
32303239
);
3231-
const propertyName = builder.getPropertyName(nodeUniform);
3232-
@@ -159,11 +168,14 @@ export default UniformNode;
3240+
const uniformName = builder.getPropertyName(nodeUniform);
3241+
@@ -194,11 +203,14 @@ export default UniformNode;
32333242
* @param {string} [arg2] - The node type. If no explicit type is defined, the node tries to derive the type from its value.
32343243
* @returns {UniformNode}
32353244
*/
@@ -10266,7 +10275,7 @@ index 37784a05..7b08961a 100644
1026610275
+
1026710276
export default StandardNodeLibrary;
1026810277
diff --git a/src-testing/src/renderers/webgpu/nodes/WGSLNodeBuilder.ts b/src-testing/src/renderers/webgpu/nodes/WGSLNodeBuilder.ts
10269-
index d6666b28..78ad6547 100644
10278+
index 3f95a66c..7bea84c7 100644
1027010279
--- a/src-testing/src/renderers/webgpu/nodes/WGSLNodeBuilder.ts
1027110280
+++ b/src-testing/src/renderers/webgpu/nodes/WGSLNodeBuilder.ts
1027210281
@@ -10,7 +10,7 @@ import {
@@ -10409,7 +10418,7 @@ index d6666b28..78ad6547 100644
1040910418
if (node.isNodeVarying === true && node.needsInterpolation === true) {
1041010419
if (shaderStage === 'vertex') {
1041110420
return `varyings.${node.name}`;
10412-
@@ -747,7 +772,12 @@ class WGSLNodeBuilder extends NodeBuilder {
10421+
@@ -755,7 +780,12 @@ class WGSLNodeBuilder extends NodeBuilder {
1041310422
* @param {?string} [name=null] - An optional uniform name.
1041410423
* @return {NodeUniform} The node uniform object.
1041510424
*/
@@ -10423,7 +10432,7 @@ index d6666b28..78ad6547 100644
1042310432
const uniformNode = super.getUniformFromNode(node, type, shaderStage, name);
1042410433
const nodeData = this.getDataFromNode(node, shaderStage, this.globalCache);
1042510434

10426-
@@ -882,7 +912,7 @@ class WGSLNodeBuilder extends NodeBuilder {
10435+
@@ -890,7 +920,7 @@ class WGSLNodeBuilder extends NodeBuilder {
1042710436
* @param {ShaderNodeInternal} shaderNode - The shader node.
1042810437
* @return {string} The WGSL function code.
1042910438
*/
@@ -10432,7 +10441,7 @@ index d6666b28..78ad6547 100644
1043210441
const layout = shaderNode.layout;
1043310442
const flowData = this.flowShaderNode(shaderNode);
1043410443

10435-
@@ -1166,8 +1196,8 @@ ${flowData.code}
10444+
@@ -1174,8 +1204,8 @@ ${flowData.code}
1043610445
* @param {string} shaderStage - The shader stage.
1043710446
* @return {string} The WGSL snippet that defines the shader attributes.
1043810447
*/
@@ -10443,7 +10452,7 @@ index d6666b28..78ad6547 100644
1044310452

1044410453
if (shaderStage === 'compute') {
1044510454
this.getBuiltin('global_invocation_id', 'globalId', 'vec3<u32>', 'attribute');
10446-
@@ -1301,8 +1331,8 @@ ${flowData.code}
10455+
@@ -1309,8 +1339,8 @@ ${flowData.code}
1044710456
* @param {string} shaderStage - The shader stage.
1044810457
* @return {string} The WGSL snippet that defines the varyings.
1044910458
*/
@@ -10454,7 +10463,7 @@ index d6666b28..78ad6547 100644
1045410463

1045510464
if (shaderStage === 'vertex') {
1045610465
this.getBuiltin('position', 'Vertex', 'vec4<f32>', 'vertex');
10457-
@@ -1367,7 +1397,7 @@ ${flowData.code}
10466+
@@ -1375,7 +1405,7 @@ ${flowData.code}
1045810467
* @param {string} shaderStage - The shader stage.
1045910468
* @return {string} The WGSL snippet that defines the uniforms.
1046010469
*/

types/three/src/nodes/core/UniformNode.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ declare class UniformNode<TValue> extends InputNode<TValue> {
5858
*/
5959
getUniformHash(builder: NodeBuilder): string;
6060
onUpdate(callback: (frame: NodeFrame, self: this) => TValue | undefined, updateType: NodeUpdateType): this;
61+
getInputType(builder: NodeBuilder): string | null;
6162
generate(builder: NodeBuilder, output: string | null): string;
6263
}
6364
export default UniformNode;

0 commit comments

Comments
 (0)