range
`range` is an auxiliary utility node that bundles a minimum and a maximum value into a single, semantically clear unit. It performs no calculation itself but is passed as a parameter to other nodes that operate on an interval (like `remap`), improving code readability and organization.
Core Advantages
Greatly improves the readability of shader node graphs and the clarity of API design. By encapsulating `min` and `max` values into a single `range` object, it makes the intent of other nodes (like `remap`) self-evident and simplifies their parameter lists.
Common Uses
Defining Value Remapping Ranges
Setting Random Number Boundaries
Configuring Material Property Ranges
How to adjust
Adjusting the `min` and `max` values of a `range` node has no direct effect. Its impact is indirect, by altering the behavior of the node that consumes it (e.g., `remap`). For example, widening the target range for a `remap` will increase the output value's contrast; widening the range for a `random` node will increase the intensity of the random effect.
Code Examples
1// Define a source range, e.g., the output of a sin() function [-1, 1]
2const sourceRange = range(-1, 1);
3
4// Define a target range, e.g., [0.2, 0.8]
5const targetRange = range(0.2, 0.8);
6
7// Linearly map a value from the source range to the target range
8const remappedValue = remap(inputValue, sourceRange, targetRange);