mod
A function node that performs a modulo (remainder) operation, primarily used to create repeating, looping, or tiling effects by wrapping a continuously changing value within a specific range.
Core Advantages
It abstracts the underlying shader language's `mod` function, enabling developers to easily create complex repeating patterns and animations within a readable, type-safe, and cross-platform node-based system, avoiding raw GLSL/WGSL string manipulation.
Common Uses
Procedural Patterns: Creating repeating patterns like stripes or grids by applying `mod` to UV coordinates.
Scrolling Textures: Animating textures for effects like water or clouds by adding time to UVs before the `mod` operation.
Periodic Animation: Generating sawtooth-like motion for objects by applying `mod` to a time value.
Infinite Space Tiling: Creating the illusion of an infinite repeating world by applying `mod` to vertex positions.
How to adjust
The effect is controlled by its inputs. Multiplying the input value (e.g., `uv().x`) by a number controls the repetition frequency (more stripes, denser grid). Adding a dynamic value (like `time`) to the input before the `mod` operation creates a scrolling or animated effect.
Code Examples
1// Create 10 vertical stripes by scaling the UV.x coordinate
2const frequency = 10.0;
3const stripes = TSL.mod( uv().x.mul( frequency ), 1.0 );