---
title: "Add Transitions Between Video Clips | Rendley SDK Docs"
description: "Add GPU-accelerated transitions between clips using WebGL shaders. Built-in wipes, dissolves and slides plus custom GLSL transitions for your video editor."
url: https://docs.rendley.com/sdk/getting-started/transitions/
---

# Transitions

Using WebGL, we can create advanced transitions using GLSL shaders that are computed directly on the GPU, ensuring high performance. [Transitions](https://docs.rendley.com/sdk/api-reference/classes/Transition.html) are typically applied at the layer level, as they affect clips that reside on the same layer.

Example: Cross Fade Transition

```
vec4 transition(vec2 uv) {
  return mix(getFromColor(uv), getToColor(uv), progress);
}
```

## Adding a transition

Before applying a transition to clips, you must first load it into the Library:

```
import { Engine } from "@rendley/sdk";

const libraryTransitionId = await Engine.getInstance()
  .getLibrary()
  .addTransition({
    id: "randomId",
    name: "Random Transition",
    transitionSrc: shaderSrc, // GLSL code for the transition
    serializable: true,
    properties: {}, // A dictionary of uniforms that can be used in the fragment shader.
  });
```

Info

The `serializable` property determines whether the transition will be included in the serialized state of the project. If set to false, you’ll need to re-load the transition using the [`onSetupLibrary`](https://docs.rendley.com/sdk/getting-started/library/#handling-missing-assets) callback during project initialization.

Once the transition is added to the Library, you can apply it to a layer. The `addTransition` call returns the instance ID of the new transition, so you can reference it later:

Runnable exampleShow full code

Run

```
// 1. Register a simple fade transition in the Library.
const fadeShader = `
vec4 transition(vec2 uv) {
  return mix(getFromColor(uv), getToColor(uv), progress);
}
`;

const libraryTransitionId = await Engine.getInstance()
.getLibrary()
.addTransition({
    id: "fade",
    name: "Fade",
    transitionSrc: fadeShader,
    serializable: true,
  });

// 2. Put two adjacent clips on the same layer.
const first = await layer.addClip({
    type: "shape",
    shape: "rectangle",
    startTime: 0,
    duration: 3,
    style: { fillColor: "#6d6ff2", width: 1200, height: 700 },
  });
first.style.setPosition(960, 540);

const second = await layer.addClip({
    type: "shape",
    shape: "rectangle",
    startTime: 3,
    duration: 3,
    style: { fillColor: "#FF4D6D", width: 1200, height: 700 },
  });
second.style.setPosition(960, 540);

// 3. Insert a transition between them.
layer.addTransition({
    startClipId: first.getId(),
    endClipId: second.getId(),
    inDuration: 1.0, // how much of the first clip the transition takes
    outDuration: 1.0, // how much of the second clip the transition takes
    transitionId: libraryTransitionId,
  });
```

Info

The `inDuration` and `outDuration` are automatically clamped to the trimmed duration of each clip. Adding a transition between two clips where one is already involved in another transition will remove the conflicting transition.

## Updating transition properties

Transitions expose the same property interface as effects:

```
const transition = layer.getTransitionById(transitionInstanceId);

transition.setProperty("uRadius", 8.0);
transition.getProperty("uRadius");
```

Changes emit `transition:property_changed` events and, if undo/redo is enabled, are recorded in the [UndoManager](https://docs.rendley.com/sdk/getting-started/undo-redo/).

## Removing a transition

To remove a transition, call the `removeTransition` method with the instance ID returned by `addTransition`:

```
layer.removeTransition(transitionInstanceId);
```

To remove every transition that uses a specific library entry (for example, when the user deletes a transition from the Library):

```
layer.removeAllTransitionsByTransitionId(libraryTransitionId);
```

## What to read next

- **[Timeline](https://docs.rendley.com/sdk/getting-started/timeline/)** arranges layers and clips in time.
- **[Animation](https://docs.rendley.com/sdk/getting-started/animation/)** moves clip properties over time.
- **[Clips](https://docs.rendley.com/sdk/getting-started/clips/)** is the common API every clip type shares.

[Previous pageEffects](https://docs.rendley.com/sdk/getting-started/effects/) [Next pageAnimation](https://docs.rendley.com/sdk/getting-started/animation/)
