Overview
Evaluates a short formula written as text and outputs one number. It can consolidate
a calculation that would require several math_op or math_func nodes into one,
such as floor(x*4)/4. Use it to tidy a graph when numeric wiring becomes hard to
read.
Usage tips
- A single expression is usually clearer for calculations that would need three or
more numeric nodes. For one simple operation,
math_opmakes the intent more visible in the graph. - You can use
time/framedirectly in an expression without connectingtime_source. For example,sin(time * pi * 2)produces one sine-wave cycle. if(condition, a, b)replaces the numeric equivalent ofcompare+switchwith one expression.- The go-to pixel snap expression is
floor(x * number_of_steps) / number_of_steps.
Related nodes
math_op/math_func— node-based equivalentslist_map— transform every list item with the same expression enginecompare/switch— propagate a Bool condition to other typesfloat_input— supply variables
Read this first
- The
x,y,z,w,vec, andflagused here are not variables created in the variable panel. - They are input pin names belonging to the Expression node itself.
- You can also enter
x,y,z,w,vec_x,vec_y, andflagdirectly in the Inspector. - To use a variable created in the variable panel, retrieve it with
Variable Refor a similar node and connect it to the corresponding input pin. - When a value is connected to an input pin, that value takes priority over the Inspector value.
- Unconnected inputs are treated as follows:
x,y,z,w=0vec=[vec_x, vec_y]flag=false
Available items
- Variables:
x,y,z,w,vec,vx,vy,flag,time,frame,total_frames - Operators:
+ - * / %,== != < <= > >=,&& || ! - Functions:
min,max,clamp,abs,floor,ceil,round,sign,sin,cos,tan,sqrt,pow,lerp,vec2,x,y,length,if
Common expressions
x + y * 2sin(time * pi * 2)if(flag, x, y)length(vec) * 0.5
Detailed examples
Example 1: Simple addition
- Set
xto0.5. - Set
yto2. - Set
expression = x + y * 2.
value = 4.5
Example 2: Leaving inputs unconnected
- Do not connect any inputs.
- Set
expression = x + 1.
In this case, x is treated as 0.
value = 1
Example 3: Using time
- Set
expression = sin(time * pi * 2).
As time changes from 0.0 to 1.0, the result completes one sine-wave cycle.
When to use it
- To write a small formula that does not justify arranging several numeric nodes
- To test an expression on its own before putting it in
ListMap
Notes
&&/||skip the right side once the result is known, andif(condition, A, B)evaluates only the selected branch.- Reversed
clampbounds are swapped,sign(0) = 0, and%is the Euclidean remainder in0 <= result < |right operand|. As with the Math nodes, division or modulo by zero andsqrtof a negative value produce an error. - This is not intended for long logic or operations with side effects.
- Version 1 is a lightweight escape hatch.
- While editing an expression, even an incomplete intermediate string is evaluated immediately, so an error may appear temporarily.