remap
Linearly transforms a numeric value from a known input range to a different output range, commonly used for data normalization or adjusting effect intensity.
Core Advantages
Encapsulates a common linear interpolation formula into a single, highly readable function, greatly simplifying mathematical transformations and allowing developers to focus on achieving artistic effects.
Common Uses
Procedural terrain generation (mapping noise to height)
Controlling visual effect intensity (e.g., Fresnel effect)
Driving periodic animations (mapping a sine wave to a scale range)
How to adjust
Control the effect by adjusting the input and output ranges. For example, inverting the output range (e.g., `1, 0`) reverses a gradient's direction. Narrowing the input range (e.g., `0.4, 0.6`) creates a high-contrast, hard transition. Set `.doClamp = true` to clip out-of-range outputs to the target range.
Code Examples
1// timerLocal().sin() produces a smooth oscillating value in the [-1, 1] range
2const oscillatingValue = timerLocal().sin();
3
4// Use remap to map its original range [-1, 1] to the default target range [0, 1]
5const normalizedPulse = remap( oscillatingValue, float( -1 ), float( 1 ) );