oscSquare
oscSquare
Generates a periodic square wave signal that instantly switches between 0 and 1. It's ideal for creating hard-edged animations like 'blinking' or 'switching,' or for generating procedural patterns with sharp edges.
Core Advantages
Provides a discrete output of strictly 0 or 1, enabling the creation of clear 'on/off' animations (like blinking) and high-contrast, hard-edged patterns (like stripes and checkerboards) without textures.
Common Uses
Blinking and strobing effects
Procedural checkerboard and stripes
Digital glitch and screen tearing effects
How to adjust
Control the frequency by multiplying the input (e.g., `timerLocal()`). A larger multiplier increases blinking speed or pattern density. Combine multiple square waves (e.g., with `xor`) to create 2D patterns like checkerboards.
Code Examples
1// Creates 20 hard-edged, vertical black and white stripes
2const squarePattern = oscSquare( uv().x.mul( 20 ) );