Math node
Range
Clamps a float value to a specified minimum/maximum range and outputs both the clamped result and the excess amount that was clipped. The Range node is essential for constraining values within bounds while preserving information about how far the original value exceeded the range.
Inputs
| Port | Type | Default |
|---|---|---|
| ValueThe value to fence in. Whatever spills past the range is not lost — it comes out of the rolled-over output instead. Also accepts an ARRAY — both outputs become arrays. | float | 0 |
| Range MinLower edge of the allowed band. If it ends up above Range Max the two swap automatically, so the range is never inverted. | float | 0 |
| Range MaxUpper edge of the allowed band. Equal to Range Min it pins the result to that single value and sends everything else to the rolled-over output. | float | 1 |
Outputs
| Port | Type |
|---|---|
| Clipped Value | float |
| Rolled-Over Value | float |
Overview
The Range node takes an input value and constrains it to lie within the interval defined by Range Min and Range Max. If the value is already within the range, it passes through unchanged and the rolled-over output is zero. If the value exceeds either end of the range, the Clipped Value output contains the nearest boundary value, and the Rolled-Over Value output contains the signed excess (positive if the value was above the maximum, negative if below the minimum).
The node automatically handles inverted ranges. If you set Range Min higher than Range Max, the node internally swaps them so the clamp always operates on a valid interval. This means you never need to worry about which value is larger when connecting dynamic range sources.
How It Works
The node computes two values in a single step:
- Clipped Value = clamp(Value, lo, hi), where lo = min(Range Min, Range Max) and hi = max(Range Min, Range Max).
- Rolled-Over Value = Value - Clipped Value.
Examples
| Value | Range Min | Range Max | Clipped Value | Rolled-Over Value |
|---|---|---|---|---|
| 0.5 | 0 | 1 | 0.5 | 0 |
| 1.7 | 0 | 1 | 1.0 | 0.7 |
| -0.3 | 0 | 1 | 0.0 | -0.3 |
| 5.0 | 2 | 4 | 4.0 | 1.0 |
| 0.5 | 1 | 0 | 0.5 | 0 |
| 3.0 | 5 | 2 | 3.0 | 0 |
Notice in the last two rows: when Range Min and Range Max are swapped, the node still works correctly because it internally normalizes the range.
Use Cases
- Constraining parameter values: Prevent a slider or sensor value from exceeding safe bounds. For example, clamp a brightness value to [0, 1] before sending it to a renderer.
- Overflow detection: Use the Rolled-Over Value to detect and measure how much a signal exceeds its expected range. Connect it to a Compare node to trigger alerts when overflow occurs.
- Wrapping behavior: Feed the Rolled-Over Value back through another Range node or add it to a base value to create wrapping or modular arithmetic behavior.
- Soft limiting with feedback: Use the Rolled-Over Value as a feedback signal to apply back-pressure or adjustment to the source of the value.
- Safe MIDI/DMX output: Clamp computed values to [0, 127] for MIDI or [0, 255] for DMX before sending them to hardware output nodes, using the Rolled-Over Value to log any clipping.
- Data normalization preprocessing: Clamp raw sensor readings to a known valid range before feeding them into a Remap node for scaling.
Practical Tips
- The Rolled-Over Value is signed: positive means the value was above the max, negative means it was below the min. You can use a Math node with the Abs operation to get the unsigned magnitude of the excess.
- When both outputs are summed together, they always equal the original input value: Clipped Value + Rolled-Over Value = Value. This identity can be useful for splitting a signal into its "in-range" and "out-of-range" components.
- If you only need simple clamping without the rolled-over output, you can still use this node and ignore the second output. There is no performance penalty for unused output ports.
- For creating a wrapping range (like a circular angle that wraps from 360 back to 0), use a Math node with the Modulo operation instead, as it provides true cyclic wrapping behavior.
- Connect a Time node to the Value input and set Range Min/Max to create a repeating time window. The Clipped Value will plateau at the bounds while the Rolled-Over Value shows how far past the window you are.
Open Range in the interactive catalog →
Range is one of 381 nodes in Grafit Pro.
Free download. Every feature for 7 days, no card. Then €99.99 once — or keep playing your projects as a Player.