Skip to content

Commit 89680a5

Browse files
authored
WebGPURenderer: Revisions for release (#30803)
1 parent 16dae58 commit 89680a5

12 files changed

+31
-31
lines changed

examples/jsm/tsl/display/AfterImageNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class AfterImageNode extends TempNode {
4141
*
4242
* @type {TextureNode}
4343
*/
44-
this.textureNodeOld = texture();
44+
this.textureNodeOld = texture( null );
4545

4646
/**
4747
* How quickly the after-image fades. A higher value means the after-image

examples/jsm/tsl/lighting/TiledLightsNode.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class TiledLightsNode extends LightsNode {
197197
const tileOffset = element.div( stride );
198198
const tileIndex = this._screenTileIndex.mul( int( 2 ) ).add( tileOffset );
199199

200-
return this._lightIndexes.element( tileIndex ).element( element.modInt( stride ) );
200+
return this._lightIndexes.element( tileIndex ).element( element.mod( stride ) );
201201

202202
}
203203

@@ -341,7 +341,7 @@ class TiledLightsNode extends LightsNode {
341341
const tileOffset = elementIndex.div( stride );
342342
const tileIndex = instanceIndex.mul( int( 2 ) ).add( tileOffset );
343343

344-
return lightIndexes.element( tileIndex ).element( elementIndex.modInt( stride ) );
344+
return lightIndexes.element( tileIndex ).element( elementIndex.mod( stride ) );
345345

346346
};
347347

@@ -352,7 +352,7 @@ class TiledLightsNode extends LightsNode {
352352
const tiledBufferSize = bufferSize.clone().divideScalar( tileSize ).floor();
353353

354354
const tileScreen = vec2(
355-
instanceIndex.modInt( tiledBufferSize.width ),
355+
instanceIndex.mod( tiledBufferSize.width ),
356356
instanceIndex.div( tiledBufferSize.width )
357357
).mul( tileSize ).div( screenSize );
358358

examples/webgpu_compute_birds.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@
176176
renderer.toneMapping = THREE.NeutralToneMapping;
177177
container.appendChild( renderer.domElement );
178178

179-
const controls = new OrbitControls( camera, renderer.domElement );
180-
controls.connect( /* renderer.domElement */ );
179+
const controls = new OrbitControls( camera );
180+
controls.connect( renderer.domElement );
181181

182182
// Initialize position, velocity, and phase values
183183

examples/webgpu_compute_sort_bitonic.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@
200200
const blockOffset = ( index.mul( 2 ).div( blockHeight ) ).mul( blockHeight );
201201
const halfHeight = blockHeight.div( 2 );
202202
const idx = uvec2(
203-
index.modInt( halfHeight ),
204-
blockHeight.sub( index.modInt( halfHeight ) ).sub( 1 )
203+
index.mod( halfHeight ),
204+
blockHeight.sub( index.mod( halfHeight ) ).sub( 1 )
205205
);
206206
idx.x.addAssign( blockOffset );
207207
idx.y.addAssign( blockOffset );
@@ -215,8 +215,8 @@
215215
const blockOffset = ( ( index.mul( 2 ) ).div( blockHeight ) ).mul( blockHeight );
216216
const halfHeight = blockHeight.div( 2 );
217217
const idx = uvec2(
218-
index.modInt( halfHeight ),
219-
( index.modInt( halfHeight ) ).add( halfHeight )
218+
index.mod( halfHeight ),
219+
( index.mod( halfHeight ) ).add( halfHeight )
220220
);
221221

222222
idx.x.addAssign( blockOffset );
@@ -447,7 +447,7 @@
447447

448448
If( highlight.equal( 1 ).and( not( nextAlgoStorage.element( 0 ).equal( StepType.NONE ) ) ), () => {
449449

450-
const boolCheck = int( elementIndex.modInt( nextBlockHeightRead.element( 0 ) ).lessThan( nextBlockHeightRead.element( 0 ).div( 2 ) ) );
450+
const boolCheck = int( elementIndex.mod( nextBlockHeightRead.element( 0 ) ).lessThan( nextBlockHeightRead.element( 0 ).div( 2 ) ) );
451451
color.z.assign( nextAlgoStorage.element( 0 ).lessThanEqual( StepType.DISPERSE_LOCAL ) );
452452
color.x.mulAssign( boolCheck );
453453
color.y.mulAssign( abs( boolCheck.sub( 1 ) ) );

examples/webgpu_compute_texture.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161

6262
const computeTexture = Fn( ( { storageTexture } ) => {
6363

64-
const posX = instanceIndex.modInt( width );
64+
const posX = instanceIndex.mod( width );
6565
const posY = instanceIndex.div( width );
6666
const indexUV = uvec2( posX, posY );
6767

examples/webgpu_compute_water.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
// context, instanceIndex is a 1-dimensional value derived from the workgroup dimensions.
141141

142142
// Cast to int to prevent unintended index overflow upon subtraction.
143-
const x = int( index.modInt( WIDTH ) );
143+
const x = int( index.mod( WIDTH ) );
144144
const y = int( index.div( WIDTH ) );
145145

146146
// The original shader accesses height via texture uvs. However, unlike with textures, we can't
@@ -205,7 +205,7 @@
205205
const newHeight = neighborHeight.mul( viscosity );
206206

207207
// Get 2-D compute coordinate from one-dimensional instanceIndex.
208-
const x = float( instanceIndex.modInt( WIDTH ) ).mul( 1 / WIDTH );
208+
const x = float( instanceIndex.mod( WIDTH ) ).mul( 1 / WIDTH );
209209
const y = float( instanceIndex.div( WIDTH ) ).mul( 1 / WIDTH );
210210

211211
// Mouse influence

src/nodes/accessors/StorageTextureNode.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,11 @@ export default StorageTextureNode;
203203
* @tsl
204204
* @function
205205
* @param {StorageTexture} value - The storage texture.
206-
* @param {Node<vec2|vec3>} uvNode - The uv node.
206+
* @param {?Node<vec2|vec3>} uvNode - The uv node.
207207
* @param {?Node} [storeNode=null] - The value node that should be stored in the texture.
208208
* @returns {StorageTextureNode}
209209
*/
210-
export const storageTexture = /*@__PURE__*/ nodeProxy( StorageTextureNode ).setParameterLength( 2, 3 );
210+
export const storageTexture = /*@__PURE__*/ nodeProxy( StorageTextureNode ).setParameterLength( 1, 3 );
211211

212212

213213
/**

src/nodes/functions/material/getParallaxCorrectNormal.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ import { float, Fn, min, normalize, sub, vec3 } from '../../tsl/TSLBase.js';
2020
*/
2121
const getParallaxCorrectNormal = /*@__PURE__*/ Fn( ( [ normal, cubeSize, cubePos ] ) => {
2222

23-
const nDir = normalize( normal ).toVar( 'nDir' );
24-
const rbmax = sub( float( 0.5 ).mul( cubeSize.sub( cubePos ) ), positionWorld ).div( nDir ).toVar( 'rbmax' );
25-
const rbmin = sub( float( - 0.5 ).mul( cubeSize.sub( cubePos ) ), positionWorld ).div( nDir ).toVar( 'rbmin' );
26-
const rbminmax = vec3().toVar( 'rbminmax' );
23+
const nDir = normalize( normal ).toVar();
24+
const rbmax = sub( float( 0.5 ).mul( cubeSize.sub( cubePos ) ), positionWorld ).div( nDir ).toVar();
25+
const rbmin = sub( float( - 0.5 ).mul( cubeSize.sub( cubePos ) ), positionWorld ).div( nDir ).toVar();
26+
const rbminmax = vec3().toVar();
2727
rbminmax.x = nDir.x.greaterThan( float( 0 ) ).select( rbmax.x, rbmin.x );
2828
rbminmax.y = nDir.y.greaterThan( float( 0 ) ).select( rbmax.y, rbmin.y );
2929
rbminmax.z = nDir.z.greaterThan( float( 0 ) ).select( rbmax.z, rbmin.z );
3030

31-
const correction = min( min( rbminmax.x, rbminmax.y ), rbminmax.z ).toVar( 'correction' );
32-
const boxIntersection = positionWorld.add( nDir.mul( correction ) ).toVar( 'boxIntersection' );
31+
const correction = min( min( rbminmax.x, rbminmax.y ), rbminmax.z ).toVar();
32+
const boxIntersection = positionWorld.add( nDir.mul( correction ) ).toVar();
3333
return boxIntersection.sub( cubePos );
3434

3535
} );

src/nodes/lighting/LightsNode.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,21 @@ class LightsNode extends Node {
5353
*
5454
* @type {Node<vec3>}
5555
*/
56-
this.totalDiffuseNode = vec3().toVar( 'totalDiffuse' );
56+
this.totalDiffuseNode = vec3().toVar();
5757

5858
/**
5959
* A node representing the total specular light.
6060
*
6161
* @type {Node<vec3>}
6262
*/
63-
this.totalSpecularNode = vec3().toVar( 'totalSpecular' );
63+
this.totalSpecularNode = vec3().toVar();
6464

6565
/**
6666
* A node representing the outgoing light.
6767
*
6868
* @type {Node<vec3>}
6969
*/
70-
this.outgoingLightNode = vec3().toVar( 'outgoingLight' );
70+
this.outgoingLightNode = vec3().toVar();
7171

7272
/**
7373
* An array representing the lights in the scene.

src/nodes/math/OperatorNode.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ class OperatorNode extends TempNode {
365365

366366
} else {
367367

368-
return builder.format( `${ builder.getMethod( 'mod', output ) }( ${ a }, ${ b } )`, type, output );
368+
return builder.format( `${ builder.getMethod( 'mod', type ) }( ${ a }, ${ b } )`, type, output );
369369

370370
}
371371

@@ -723,7 +723,7 @@ export const remainder = ( a, b ) => { // @deprecated, r168
723723
export const modInt = ( a, b ) => { // @deprecated, r175
724724

725725
console.warn( 'THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.' );
726-
return mod( a, int( b ) );
726+
return mod( int( a ), int( b ) );
727727

728728
};
729729

src/nodes/tsl/TSLCore.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ const ShaderNodeProxy = function ( NodeClass, scope = null, factor = null, setti
220220
let tslName;
221221

222222
if ( name ) tslName = /[a-z]/i.test( name ) ? name + '()' : name;
223-
else name = NodeClass.type;
223+
else tslName = NodeClass.type;
224224

225225
if ( minParams !== undefined && params.length < minParams ) {
226226

src/renderers/webgpu/nodes/WGSLNodeBuilder.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ class WGSLNodeBuilder extends NodeBuilder {
321321
*/
322322
generateWrapFunction( texture ) {
323323

324-
const functionName = `tsl_coord_${ wrapNames[ texture.wrapS ] }S_${ wrapNames[ texture.wrapT ] }_${texture.isData3DTexture ? '3d' : '2d'}T`;
324+
const functionName = `tsl_coord_${ wrapNames[ texture.wrapS ] }S_${ wrapNames[ texture.wrapT ] }_${ texture.isData3DTexture ? '3d' : '2d' }T`;
325325

326326
let nodeCode = wgslCodeCache[ functionName ];
327327

@@ -331,7 +331,7 @@ class WGSLNodeBuilder extends NodeBuilder {
331331

332332
// For 3D textures, use vec3f; for texture arrays, keep vec2f since array index is separate
333333
const coordType = texture.isData3DTexture ? 'vec3f' : 'vec2f';
334-
let code = `fn ${functionName}( coord : ${coordType} ) -> ${coordType} {\n\n\treturn ${coordType}(\n`;
334+
let code = `fn ${ functionName }( coord : ${ coordType } ) -> ${ coordType } {\n\n\treturn ${ coordType }(\n`;
335335

336336
const addWrapSnippet = ( wrap, axis ) => {
337337

@@ -516,7 +516,7 @@ class WGSLNodeBuilder extends NodeBuilder {
516516
const textureDimension = this.generateTextureDimension( texture, textureProperty, levelSnippet );
517517

518518
const vecType = texture.isData3DTexture ? 'vec3' : 'vec2';
519-
const coordSnippet = `${vecType}<u32>(${wrapFunction}(${uvSnippet}) * ${vecType}<f32>(${textureDimension}))`;
519+
const coordSnippet = `${ vecType }<u32>(${ wrapFunction }(${ uvSnippet }) * ${ vecType }<f32>(${ textureDimension }))`;
520520

521521
return this.generateTextureLoad( texture, textureProperty, coordSnippet, depthSnippet, levelSnippet );
522522

0 commit comments

Comments
 (0)