Constant
Outputs a fixed value. Supports Scalar, Vec2, Vec3, and Color modes with corresponding output port types.
Category: Math Menu path: Math > Constant
Ports
| Port | Type | Direction | Description |
|---|---|---|---|
out | scalar / vec2 / vec3 / color | output | The constant value (port type changes with mode) |
Parameters
| Param | Type | Default | Description |
|---|---|---|---|
mode | enum | Scalar | Output type: Scalar, Vec2, Vec3, or Color |
scalarValue | scalar | 0 | Value when mode is Scalar |
vec2Value | vec2 | (0, 0) | Value when mode is Vec2 |
vec3Value | vec3 | (0, 0, 0) | Value when mode is Vec3 |
colorValue | color | gray (0.5, 0.5, 0.5, 1) | Value when mode is Color |
Only the param matching the current mode is visible in Properties.
How It Works
Constant is a simple value source node. Changing the mode param switches both the visible value param and the output port type. This is a mode-switching node -- when the mode changes, the port type updates and any incompatible downstream edges are automatically removed.
The value can be keyframed for animation, making Constant useful as a named, reusable animated value that drives multiple downstream parameters.
Usage Examples
Basic: Fixed parameter
Constant (Scalar, value: 0.5) -> connect to any scalar input (e.g., Transform2D rotation_in, Blur amount_in). Provides a named, visible value in the graph.
Animated color
Constant (Color, keyframed between red and blue) -> connect to SolidColor's color_in or DrawShape's fillColor.
Reusable value
One Constant -> multiple downstream connections. Change the value in one place and it propagates everywhere.
Tips
- Switching modes prunes edges that become incompatible with the new port type
- Constant values are evaluated in the pre-pass (before GPU work), so they are essentially free
- For a single scalar expression, consider Math with disconnected inputs instead -- it provides more operations inline
- Color type can connect to imageRgba16f inputs (engine auto-converts via
resolve_as_texture)
Related Nodes
- Time -- dynamic value source (frame, seconds, normalized)
- Math -- scalar operations on values
- MakeVector -- assemble scalars into vectors
- SolidColor -- color output node (similar to Constant in Color mode, but with channel decomposition)