Browse Source

Nodes: Rename `remainder()` to `modInt()`. (#29092)

* fix remainder operator when forceWebGL is set to true

* rename remainder to modInt and mod to modFloat

* remove % code in operatorNode

* fix MathNode

* revert modFloat back to mod

* cleanup

* add nodes export

* added deprecated version

---------

Co-authored-by: sunag <sunagbrasil@gmail.com>
Christian Helgeson 1 year ago
parent
commit
6114fcc3fc

+ 1 - 1
examples/webgpu_compute_texture.html

@@ -60,7 +60,7 @@
 
 				const computeTexture = Fn( ( { storageTexture } ) => {
 
-					const posX = instanceIndex.remainder( width );
+					const posX = instanceIndex.modInt( width );
 					const posY = instanceIndex.div( width );
 					const indexUV = uvec2( posX, posY );
 

+ 1 - 1
src/nodes/Nodes.js

@@ -41,7 +41,7 @@ export { NodeUtils };
 // math
 export { default as MathNode, PI, PI2, EPSILON, INFINITY, radians, degrees, exp, exp2, log, log2, sqrt, inverseSqrt, floor, ceil, normalize, fract, sin, cos, tan, asin, acos, atan, abs, sign, length, lengthSq, negate, oneMinus, dFdx, dFdy, round, reciprocal, trunc, fwidth, bitcast, atan2, min, max, mod, step, reflect, distance, difference, dot, cross, pow, pow2, pow3, pow4, transformDirection, mix, clamp, saturate, refract, smoothstep, faceForward, cbrt, transpose, all, any, equals, rand } from './math/MathNode.js';
 
-export { default as OperatorNode, add, sub, mul, div, remainder, equal, lessThan, greaterThan, lessThanEqual, greaterThanEqual, and, or, not, xor, bitAnd, bitNot, bitOr, bitXor, shiftLeft, shiftRight } from './math/OperatorNode.js';
+export { default as OperatorNode, add, sub, mul, div, modInt, equal, lessThan, greaterThan, lessThanEqual, greaterThanEqual, and, or, not, xor, bitAnd, bitNot, bitOr, bitXor, shiftLeft, shiftRight, remainder } from './math/OperatorNode.js';
 export { default as CondNode, select, cond } from './math/CondNode.js';
 export { default as HashNode, hash } from './math/HashNode.js';
 

+ 1 - 1
src/nodes/accessors/BatchNode.js

@@ -43,7 +43,7 @@ class BatchNode extends Node {
 		const getIndirectIndex = Fn( ( [ id ] ) => {
 
 			const size = textureSize( textureLoad( this.batchMesh._indirectTexture ), 0 );
-			const x = int( id ).remainder( int( size ) );
+			const x = int( id ).modInt( int( size ) );
 			const y = int( id ).div( int( size ) );
 			return textureLoad( this.batchMesh._indirectTexture, ivec2( x, y ) ).x;
 

+ 12 - 2
src/nodes/math/OperatorNode.js

@@ -263,7 +263,7 @@ export const add = nodeProxy( OperatorNode, '+' );
 export const sub = nodeProxy( OperatorNode, '-' );
 export const mul = nodeProxy( OperatorNode, '*' );
 export const div = nodeProxy( OperatorNode, '/' );
-export const remainder = nodeProxy( OperatorNode, '%' );
+export const modInt = nodeProxy( OperatorNode, '%' );
 export const equal = nodeProxy( OperatorNode, '==' );
 export const notEqual = nodeProxy( OperatorNode, '!=' );
 export const lessThan = nodeProxy( OperatorNode, '<' );
@@ -285,7 +285,7 @@ addNodeElement( 'add', add );
 addNodeElement( 'sub', sub );
 addNodeElement( 'mul', mul );
 addNodeElement( 'div', div );
-addNodeElement( 'remainder', remainder );
+addNodeElement( 'modInt', modInt );
 addNodeElement( 'equal', equal );
 addNodeElement( 'notEqual', notEqual );
 addNodeElement( 'lessThan', lessThan );
@@ -303,4 +303,14 @@ addNodeElement( 'bitXor', bitXor );
 addNodeElement( 'shiftLeft', shiftLeft );
 addNodeElement( 'shiftRight', shiftRight );
 
+
+export const remainder = ( ...params ) => { // @deprecated, r168
+
+	console.warn( 'TSL.OperatorNode: .remainder() has been renamed to .modInt().' );
+	return modInt( ...params );
+
+};
+
+addNodeElement( 'remainder', remainder );
+
 addNodeClass( 'OperatorNode', OperatorNode );

粤ICP备19079148号