sin
A powerful math function that converts any linear input (like time or coordinates) into a smooth, periodic waveform (-1 to 1), fundamental for creating oscillations, waves, and organic patterns.
Core Advantages
As a high-performance function natively supported by the GPU, it can efficiently generate smooth, predictable programmatic dynamic effects (like waves, breathing animations) in real-time within the shader, saving significant resources by eliminating the need for external animation data.
Common Uses
Programmatic water or wave effects
Smooth looping animations (e.g., breathing, pulsing)
Generating organic patterns like stripes and grids
How to adjust
Adjust by performing math operations on the `sin` input. Multiplying by a constant (frequency) controls the density of the waves; adding a time-varying value (like `timerLocal()`) animates the pattern (phase shift).
Code Examples
1// Create a wave based on UV.x, animated over time
2const wave = sin( uv().x.mul(10).add( timerLocal(2) ) );
3
4// Map the [-1, 1] result to [0, 1] for color or displacement
5const value = wave.mul(0.5).add(0.5);