Math
Performs one of 28 scalar math operations on one or two inputs. Pure CPU value node.
Category: Math Menu path: Math > Math
Ports
| Port | Type | Direction | Description |
|---|---|---|---|
a | scalar | input | First operand |
b | scalar | input | Second operand (not used by unary operations) |
out | scalar | output | Result |
Parameters
| Param | Type | Default | Description |
|---|---|---|---|
operation | enum | Add | The math operation to perform (see table below) |
a | scalar | 0 | Fallback value for input A when not connected |
b | scalar | 0 | Fallback value for input B when not connected |
t | scalar | 0.5 | Interpolation factor (Lerp, Smoothstep) |
inMin | scalar | 0 | Input range minimum (Remap) |
inMax | scalar | 1 | Input range maximum (Remap) |
outMin | scalar | 0 | Output range minimum (Remap) |
outMax | scalar | 1 | Output range maximum (Remap) |
clamp | boolean | true | Clamp output to range (Remap, Clamp) |
min | scalar | 0 | Minimum bound (Clamp) |
max | scalar | 1 | Maximum bound (Clamp) |
step | scalar | 1 | Step size (Snap) |
The Properties panel automatically shows only the params relevant to the selected operation.
Operations
Binary (A, B)
| Operation | Formula |
|---|---|
| Add | A + B |
| Subtract | A - B |
| Multiply | A * B |
| Divide | A / B |
| Power | A ^ B |
| Modulo | A % B |
| Atan2 | atan2(A, B) |
Comparison
| Operation | Formula |
|---|---|
| Min | min(A, B) |
| Max | max(A, B) |
| Clamp | clamp(A, min, max) |
Rounding
| Operation | Formula |
|---|---|
| Floor | floor(A) |
| Ceil | ceil(A) |
| Round | round(A) |
| Snap | round(A / step) * step |
Unary (A only)
| Operation | Formula |
|---|---|
| Abs | ` |
| Negate | -A |
| Sign | sign(A) (returns -1, 0, or 1) |
| Sqrt | sqrt(A) |
Trigonometry
| Operation | Formula |
|---|---|
| Sin | sin(A) |
| Cos | cos(A) |
| Tan | tan(A) |
Interpolation
| Operation | Formula |
|---|---|
| Lerp | A + (B - A) * t |
| Step | A < B ? 0 : 1 |
| Smoothstep | smoothstep from A to B at t |
| Remap | maps A from [inMin, inMax] to [outMin, outMax] |
Looping
| Operation | Formula |
|---|---|
| Pingpong | bounces A between 0 and B |
| Wrap | wraps A into range [0, B) |
How It Works
Math is a lightweight CPU-only node that produces a scalar value. It does not allocate GPU textures. The operation is evaluated every frame, making it ideal for building expressions from Time, Constant, and other value nodes.
When an input port is not connected, the corresponding param value (a or b) is used as the operand. When a port is connected, the incoming value overrides the param.
Usage Examples
Basic: Oscillating value
Time.seconds -> Math (Sin). Produces a value oscillating between -1 and 1. Chain another Math (Remap, inMin: -1, inMax: 1, outMin: 0, outMax: 360) to get a 0-360 range for rotation.
Clamped speed
Time.normalized -> Math (Multiply, b: 2) -> Math (Clamp, min: 0, max: 1). Doubles the speed but caps at 1.0.
Stepped animation
Time.frame -> Math (Snap, step: 5). Frame number quantized to multiples of 5 for a hold-frame effect.
Looping value
Time.frame -> Math (Modulo, b: 60). Cycles 0-59 repeatedly for a 60-frame loop.
Tips
- Only the params relevant to the current operation are shown in Properties -- switching operations updates the panel
- Chain Math nodes for complex expressions (e.g.,
sin(time * 2) * 50 + 100) - Unary operations ignore input B and hide the
bparam - Math output is a scalar -- use MakeVector to combine into vec2/vec3 for spatial parameters
Related Nodes
- VectorMath -- same concept for vec2 operations
- Time -- common input source for animated expressions
- Constant -- fixed value source
- MakeVector -- combine scalar results into vectors
- Remap -- curve-based field remapping (more control than Math's Remap)