Aller au contenu

Expression Modifier

By Kriss Norde

The Expression modifier drives a parameter with a free-form Lua formula. More powerful than Calculation: you can use any math expression, conditions, trigonometric functions and references to other parameters. It is the main parametric scripting tool in Fusion.

Overview

Expression evaluates a formula on every frame and feeds the target parameter with the result. It enables sophisticated automation: sine oscillations, conditions, complex cross-parameter references.

Difference from a simple "=..." expression on a parameter: the modifier exposes a dedicated UI with a preview, history and error handling; and it becomes a node in the graph that you can reuse to drive several parameters.

Where to find this modifier

  • Right-click a parameter → Modify With → Expression.
  • Creates an Expression node in the graph, linked to the target parameter.

Syntax and functions

Available variables
time = current frame, value = current value of the parameter, references to other nodes by name (e.g. Transform1.Size.X).
Trigonometric functions
sin(x), cos(x), tan(x) in radians. Multiply by math.pi/180 for input in degrees.
Math functions
math.sqrt(x), math.abs(x), math.floor(x), math.ceil(x), math.exp(x), math.log(x).
Random
math.random() returns 0-1. For a reproducible seed: math.randomseed(time); math.random().
Conditions
if condition then x else y end for branching. Saves you from needing a ternary.

Setup

Sine oscillation:
Transform.Center.X → Expression:
   0.5 + math.sin(time * 0.1) * 0.2
   = oscillates between 0.3 and 0.7

Condition:
Visibility → Expression:
   if time > 30 then 1 else 0 end
   = becomes visible after frame 30

Cross-parameter reference:
Blur.Size → Expression:
   Transform1.Size * 5
   = blur 5x the transform scale

Random shake:
Position.X → Expression:
   math.randomseed(time);
   100 + (math.random() - 0.5) * 10
   = position centered on 100 with ±5 of shake

Time + reference combined:
Rotation → Expression:
   Slider1 * math.sin(time * 0.05)
   = oscillating rotation with an amplitude driven
   by Slider1

Controls tab

Expression
Multi-line text field where you type the formula. Validated in real time. Syntax errors are displayed.
n1, n2, n3... (extra inputs)
Additional input variables you can link to other parameters. Referenced as n1, n2 in the formula.
p1, p2, p3... (point inputs)
For Point-type parameters (2D position). Accessed as p1.X, p1.Y.

Use cases

  • Procedural animation - oscillations, waves, pulses without keyframes to animate by hand.
  • Linking complex parameters - non-linear relationships between parameters (e.g. blur as a quadratic function of scale).
  • Time-based conditions - turn effects on / off depending on the frame, without animating an opacity.
  • Reproducible random / shake - procedural camera shake with a time-based seed = the same result on every playback.
  • Synchronized multi-parameters - drive scale, rotation and position at the same time from a single expression.
  • Transformation formulas - complex unit conversions, interpolations, custom easing curves.
  • Pipeline logic - switch to an alternative composite depending on a metadata field by referencing Has Metadata.

Tips

  • Strict Lua syntax - no mandatory semicolons, but then and end for conditions. No curly braces {}.
  • time vs Time - time is lowercase in expressions. Casing matters.
  • Performance - evaluated on every frame. For heavy formulas or image sampling, the cost can add up.
  • Random without a seed - random without a seed changes on every evaluation = constant flicker. If you do not want that, set the seed with time.
  • Reference syntax - NodeName.ParamName. For nested params: Transform1.Center.X.
  • Inputs n1, n2 for clarity - for complex formulas, reference values through linked inputs rather than by name directly = a more readable expression.
  • Test in the console - open the Fusion Console (print(...)) to debug complex formulas before copying them into the modifier.
  • For very sophisticated animation (multi-segment, custom easing), consider Fusion Macros or Fuses for reusability.