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

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

Merged
merged 8 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion examples/webgpu_compute_texture.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
2 changes: 1 addition & 1 deletion src/nodes/Nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/nodes/accessors/BatchNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
14 changes: 12 additions & 2 deletions src/nodes/math/OperatorNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '<' );
Expand All @@ -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 );
Expand All @@ -303,4 +303,14 @@ addNodeElement( 'bitXor', bitXor );
addNodeElement( 'shiftLeft', shiftLeft );
addNodeElement( 'shiftRight', shiftRight );


export const remainder = ( ...params ) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think could be good add what release it was deprecated

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 );