Skip to content

Vector Math

Performs one of 17 vec2 math operations. Outputs a vec2 result and a scalar for length/distance/dot operations.

Category: Math Menu path: Math > Vector Math

Ports

PortTypeDirectionDescription
avec2inputFirst vector operand
bvec2inputSecond vector operand (not used by unary operations)
outvec2outputVector result
scalarscalaroutputScalar result (populated by Length, Distance, and Dot operations)

Parameters

ParamTypeDefaultDescription
operationenumAddThe vector operation to perform (see table below)
avec2(0, 0)Fallback value for input A when not connected
bvec2(0, 0)Fallback value for input B when not connected
tscalar0.5Interpolation factor (Lerp only)

The Properties panel automatically shows only the params relevant to the selected operation.

Operations

Binary (A, B)

OperationResult (vec2)Scalar output
AddA + B--
SubtractA - B--
MultiplyA * B (component-wise)--
DivideA / B (component-wise)--
ScaleA * B.x (uniform scale by B's x component)--
Min(min(Ax, Bx), min(Ay, By))--
Max(max(Ax, Bx), max(Ay, By))--

Unary (A only)

OperationResult (vec2)Scalar output
LengthA (unchanged)length(A)
NormalizeA / length(A)--
Negate-A--
Abs`(Ax
Floor(floor(Ax), floor(Ay))--
Ceil(ceil(Ax), ceil(Ay))--

Two-operand with scalar output

OperationResult (vec2)Scalar output
DistanceA (unchanged)distance(A, B)
DotA (unchanged)dot(A, B)
Rotaterotate(A, B.x radians)--

Interpolation

OperationResult (vec2)Scalar output
LerpA + (B - A) * t--

How It Works

VectorMath is a lightweight CPU-only node that operates on vec2 values. No GPU textures are allocated. Operations that produce both a vector and scalar result (Length, Distance, Dot) populate both output ports simultaneously.

When an input port is not connected, the corresponding param value is used. When connected, the incoming value overrides the param.

Usage Examples

Basic: Offset position

Time.seconds -> Math (Sin) -> MakeVector (x driven, y: 0) -> VectorMath (Add, b from Constant vec2). Creates a sinusoidal horizontal oscillation added to a base position.

Distance-based effect

VectorMath (Distance, a: point position, b: center) -> Math (Remap) -> drives another param. Creates a radial falloff from a center point.

Normalized direction

VectorMath (Subtract, a: target, b: source) -> VectorMath (Normalize). Gets the unit direction vector between two points.

Tips

  • The scalar output port is only meaningful for Length, Distance, and Dot -- for other operations it may not carry useful data
  • Unary operations ignore input B and hide the b param in Properties
  • Lerp shows the t param; all other operations hide it
  • Use BreakVector to extract individual components from the vec2 result