Skip to content
VIDEOMONTAZHERDAVINCI RESOLVE · VIDEO · AI

FUSION · Expressions

Loops, ping-pong and stepped animation

Remainder, triangle waves, discrete changes and correct loop boundaries.

Fusion / DaVinci Resolve 20–21

After this lesson

  • Build repetition with remainder.
  • Distinguish sawtooth, triangle and smooth waves.
  • Avoid confusing steps with a frame-rate change.

Before you start

Composition
A separate Fusion Composition. 1920×1080, square pixels, 25 fps.
Parameter
Merge1 → Blend
Range
Start at comp.RenderStart. Reference frames are local unless stated otherwise.

Repetition is not limited to sine waves. Counters, scanning indicators and back-and-forth motion need different signal shapes. Decide whether the cycle boundary should be continuous.

Sawtooth cycles

(time-start)%60 returns a repeating local count. Dividing by 60 gives a range from 0 to just below 1. The next cycle jumps back to zero.

This suits scanning and looping progress. The jump is visible on opacity; for a full-turn rotation, the beginning and end can look identical.

There and back

A triangle wave rises from 0 to 1 over 60 frames and returns over the next 60. Position is continuous, but velocity changes sign abruptly at the turning points.

SIMPLE EXPRESSION · FUSION
1 - math.abs(((time - comp.RenderStart) % 120) / 60 - 1)

Steps without changing fps

math.floor((time-start)/6) changes once every six frames. It controls the input value, not the video frame rate. Add %4 for four repeating states.

Check the export join between its last and first frames. For period 60, use 60 consecutive samples such as 0…59; frame 60 already repeats the next cycle start.

Choose the signal shape for the motion

A sawtooth ramp rises uniformly and jumps back to zero. It works for a cyclic phase, but directly driving position creates a visible jump. A triangle wave travels out and back: its value is continuous, but direction changes abruptly at each peak, producing a mechanical reversal.

Sine motion slows near its extremes. Replacing one formula with another changes the character of the animation, not merely the smoothness of a graph. Use sawtooth for a scanning indicator, sine for swaying and steps for discrete states.

How many frames should repeat?

A 120-frame triangle period splits into 60 rising and 60 falling intervals. Use 0…119 in a looping clip; frame 120 is the new zero. With a non-integer period, the boundary can fall between frames, so integer-frame renders need not contain the exact maximum.

A stepped formula changes only at its chosen boundaries, while the project remains at, for example, 25 fps. Several consecutive frames may have the same value. This discretizes the control without changing the time grid of the video.

SIMPLE EXPRESSION · FUSION
math.floor((time - comp.RenderStart) / 10) % 4

Parameters and ranges

ParameterWhat it changesExample / check
120The complete ping-pong period.60 intervals out and 60 back.
%Wraps the phase into the period.Times before the start may produce a different phase; clamp local time if needed.
floor(t/10)%4Four states of 10 frames each.A 0…3 result cannot directly drive Blend.

USE IN A COMPOSITION

Build it in Fusion

Merge1 → Blend

FUSION / FLOWNodes and parameter control
100%
ImageControl in the InspectorScroll or drag the graph. Choose “Fit” to see all of it.
Solid lines are node connections in the Flow. A dashed line is a parameter dependency configured in the Inspector. A solid arrow's color matches its destination input. Modifiers are shown separately from the Flow.Background1.Output → Merge1.BackgroundMerge1.Output → MediaOut1.InputText1.Output → Merge1.Foregroundcontrol.Value → Merge1.BlendText1 · Image node · FlowT+Text1Text+Background1 · Image node · Flow▧Background1BackgroundMerge1 · Image node · Flow⊕Merge1MergeBlendBlend · an Inspector parameter, not an image portMediaOut1 · Image node · Flow↗MediaOut1MediaOutPing-pong · Expression · InspectorEXPRESSIONPing-pongSimple Expression
BackgroundImageForegroundParameter · Inspector
Select a node or a colored arrow

Solid lines are node connections in the Flow. A dashed line is a parameter dependency configured in the Inspector.

Connections by port and parameter4

Color is determined by the destination input. Dashed connections are configured in the Inspector; they do not add an RGBA wire to the Flow.

Assembly steps

  1. Connect Background1 to the yellow input of Merge1, Text1 to the green input, and Merge1 to MediaOut1. Enable Expression on Blend.
  2. Paste the triangle wave.
  3. Check local frames 0, 30, 60, 90 and 120.
  4. Compare with a sine wave: their turning points behave differently.
SIMPLE EXPRESSION · FUSION
1 - math.abs(((time - comp.RenderStart) % 120) / 60 - 1)

Expected result. Values are 0, 0.5, 1, 0.5 and 0. The turning points are sharper than a sine wave.

Checkpoints

When / what to checkExpectedWhy check it
00Start of the rise.
300.5Halfway up.
601Turning point.
900.5Halfway down.
1200Start of the next cycle.

INTERACTIVE EXAMPLE

Change a parameter. Compare the result.

EXPRESSION · INTERACTIVE EXAMPLE

One cycle: appear and disappear

CONTROLLED PARAMETERMerge1 → Blend
0 f← → one frame at a time25 fps
VALUE GRAPH
Blend
-0.120.51.120 f120 f240 f
Select a point on the graph to go to that frame. Values are checked throughout the range.

A triangle wave travels 0 → 1 → 0. The period includes both halves of the movement. Velocity changes abruptly at the turning point.

OUTPUT VALUE0.5
CHECK THE ORIGINAL EXAMPLE

With period 120, frames 0, 30, 60, 90 and 120 give 0, 0.5, 1, 0.5 and 0.

Formula for the current settings +
Merge1 → Blend
1 - math.abs(((time - comp.RenderStart) % 120) / 60 - 1)

This is a ping-pong Blend formula, not an fps change or a smooth sine wave. With an even period, the peak falls on a whole frame.

Errors and troubleshooting

A jump at the sawtooth boundary

That is a property of a sawtooth, not a render error. Choose triangle or sine if the jump is unwanted.

Steps look like dropped frames

Reduce the step size or apply steps to an indicator rather than smooth camera movement.

Independent exercise

Create four states 0, 1, 2 and 3, each lasting eight frames.

Show the solution and explanation

math.floor((time-comp.RenderStart)/8)%4. RenderStart…RenderStart+31 contains one cycle.

Continue learning

Official sources

Blackmagic Design · Fusion Reference ManualThe chapter “Using Modifiers, Expressions, and Custom Controls”. Page numbers depend on the PDF edition.
Blackmagic Design · Modifiers referenceThe Modifiers section. Available commands depend on the input type and Fusion version.

An original educational walkthrough. The browser model explains the principle but does not run Fusion. Control placement depends on the version; save the original composition before replacing a parameter's control source.