remapClamp
Linearly remaps a numeric value from an input range to an output range, ensuring the result is strictly clamped within the output range.
Core Advantages
Provides safe range remapping by automatically clamping the output, preventing visual artifacts from value overflow. It's a convenient shortcut for `remap(...).clamp(...)`, making code more robust and concise.
Common Uses
Controlling strictly-ranged material properties (e.g., opacity, roughness)
Creating visual effects with hard boundaries (e.g., halos, stripes)
Visualizing UI element states (e.g., progress bars)
How to adjust
Adjust the input range (`inLow`, `inHigh`) to define the gradient transition area and the clamped plateaus on either side. For example, narrowing the input range creates a steeper transition. Inverting the output range (e.g., `1, 0`) can create inverse falloff effects like halos or apertures.
Code Examples
1// Define the input range of interest, e.g., the middle 20% of the screen
2const inLow = float( 0.4 );
3const inHigh = float( 0.6 );
4
5// When uv.x is outside [0.4, 0.6], the result is clamped to 0 or 1
6const clampedGradient = remapClamp( uv().x, inLow, inHigh );