Skip to content
VIDEOMONTAZHERDAVINCI RESOLVE · VIDEO · AI

FUSION · Expressions

Conditions, ranges and timed switching

iif, comparisons and safe boundaries for reveals, switching and parameter limits.

Fusion / DaVinci Resolve 20–21

After this lesson

  • Separate delay, transition and hold.
  • Avoid using a condition to guard an unsafe function call.
  • Check frames immediately around the boundary.

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.

A condition selects a result; a ramp defines a transition. Switching Blend instantly from 0 to 1 and revealing it over 20 frames are different tasks even though both depend on time.

Instant switching

In Simple Expression, use iif(condition, valueIfTrue, valueIfFalse). For example, iif(time - comp.RenderStart < 30, 0, 1) hides the foreground until local frame 30.

Check the comparison: < 30 enables the object on frame 30, while <= 30 does so on the next frame. Lua uses ~= for not equal, not !=.

Delay and gradual rise

To start on frame 30 and finish on frame 50, subtract 30, divide by 20, then clamp to 0…1. The result is 0 before the start and 1 after the end.

SIMPLE EXPRESSION · FUSION
math.min(1, math.max(0, (time - comp.RenderStart - 30) / 20))

Do not hide an error in the unselected branch

A function call does not guarantee lazy argument evaluation. Do not expect iif to protect division by zero in one branch. Make the denominator valid or restructure the dependency.

min/max is not a universal repair. Clamping a negative angle to 0…1 destroys the intended animation. Choose limits appropriate to the controlled parameter.

A condition does not always prevent branch evaluation

iif looks like a short if statement, but it is a function call. Arguments are prepared before the result is selected; iif(d==0, 0, 1/d) is not reliable division-by-zero protection. Make the denominator safe first when that fits the task. For a positive duration, a minimum of one is reasonable.

Lua and/or short-circuit, but condition and valueA or valueB depends on the truthiness of valueA. If valueA is false or nil, valueB is selected. For numeric animation, avoid such tricks when a clamped ramp or separate controls will suffice.

Check both sides of the boundary

With a delay of 30 and a 20-frame transition, motion starts at local frame 30 and the title is fully visible at 50. It remains hidden at 29. Testing only 0 and 60 would also pass with an incorrect delay of 20. Check the frame before the start, the start, the middle and the end.

Instant switching is useful for states but does not create a smooth reveal. On brightness it may look like a flash; on position, a teleport. Choose the behavior first: the condition defines when to switch, while the transition function defines how to change.

Parameters and ranges

ParameterWhat it changesExample / check
30Delay before the rise starts.The result is 0 beforehand.
20Transition duration.Halfway is reached after 10 intervals.
min/maxHolds the limits at 0…1.The value stops increasing after 50.

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↗MediaOut1MediaOutA delayed ramp · Expression · InspectorEXPRESSIONA delayed rampSimple 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. Create Background1 and Text1; connect them to the yellow Background and green Foreground inputs of Merge1 respectively. Connect Merge1 to MediaOut1.
  2. Enable Expression on Blend.
  3. Paste the delayed ramp.
  4. Check local frames 29, 30, 40, 50 and 60.
SIMPLE EXPRESSION · FUSION
math.min(1, math.max(0, (time - comp.RenderStart - 30) / 20))

Expected result. Values: 0, 0, 0.5, 1, 1. The first visible increase occurs after the ramp starts.

Checkpoints

When / what to checkExpectedWhy check it
29 and 300Checks the start boundary.
400.5Middle of the transition.
50 and 601Final hold.

INTERACTIVE EXAMPLE

Change a parameter. Compare the result.

EXPRESSION · INTERACTIVE EXAMPLE

The reveal starts at the specified frame

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

The delay shifts the ramp's start. Before it, the value is zero; after the transition ends, it is one.

OUTPUT VALUE0.5
CHECK THE ORIGINAL EXAMPLE

Delay 30, transition 20: frames 29 and 30 → 0; frame 40 → 0.5; frames 50 and 60 → 1.

Formula for the current settings +
Merge1 → Blend
math.min(1, math.max(0, ((time - comp.RenderStart) - 30) / 20))

This shows a gradual, delayed reveal. Instant switching with iif is covered separately in the article.

Errors and troubleshooting

The title appears one frame early

Compare strict and inclusive boundaries.

The error remains inside iif

Protect the unsafe operation directly; do not rely on lazy function arguments.

Independent exercise

Move the reveal to frame 60 and extend its duration to 40 frames.

Show the solution and explanation

Subtract 60 instead of 30; divide by 40 instead of 20. Blend should be 0.5 at local frame 80.

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.