-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
|
Yes that fixed it. I did also try an arbitrary modulus with WebGL and that worked fine. I'm not sure why so much documentation seems to indicate that % is not allowed in GLSL at all? If it's okay, can I just change this pull request to implement the suggested name change. |
Sounds great! |
Ok cool, I'll also make sure there's a deprecation option per the new standards. |
Could you keep |
a6d32d0
to
e32cc14
Compare
src/nodes/math/OperatorNode.js
Outdated
@@ -303,4 +303,14 @@ addNodeElement( 'bitXor', bitXor ); | |||
addNodeElement( 'shiftLeft', shiftLeft ); | |||
addNodeElement( 'shiftRight', shiftRight ); | |||
|
|||
|
|||
export const remainder = ( ...params ) => { |
There was a problem hiding this comment.
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
remainder()
to modInt()
.
Description
Between WGSL and GLSL, there are differences in how the commonly used modulus operation is handled. GLSL has a function mod() that computes x modulo y. It does not permit the use of the % operator to perform the same operation. Meanwhile, WGSL does allows the use of the % operator to compute the modulus of two numbers, and therefore has no equivalent function mod. Therefore, when the % operator is used in a TSL shader via the remainder() function, that shader will be valid for the renderer's WebGPUBackend, but invalid for its WebGLBackend. While a user could simply write their shader to use remainder or mod depending on what graphics API they are targeting, this solution negates the inherent portability of TSL shaders across shader languages.Modified to simply rename remainder and mod to make their usage more clear.