step
Converts a continuous input value (x) into a binary result based on a threshold (edge). Returns 1.0 if x >= edge, otherwise returns 0.0.
Core Advantages
Provides a high-performance, branchless way to implement conditional logic on the GPU, making it one of the most efficient tools for procedurally generating hard-edged masks and shapes.
Common Uses
Creating hard-edged procedural shapes (like circles, stripes)
Implementing binarized lighting in toon shading
Creating region-selection masks based on height or distance
How to adjust
Adjusting the threshold (the first parameter) directly moves the position of the 'dividing line' where the output jumps from 0 to 1. Increasing the threshold shrinks the area that results in 1, and vice versa. This is used to control the size of procedural shapes or the trigger point of an effect without creating any smooth transitions.
Code Examples
1// Splits the screen at x = 0.5
2// If uv().x >= 0.5, the result is 1.0 (white)
3// Otherwise, the result is 0.0 (black)
4const result = step(0.5, uv().x);