Wipes & transitions
Hide one picture and show another behind an animated edge, from a straight line, a shape or a pattern.
Cards
One live example to tweak, learn and copy.
How it works
A wipe replaces one picture with another behind a moving edge: a slide deck’s next slide pushing in from the left, a game’s loading screen closing in as a circle, a menu panel revealed from the top. Every wipe is the same two parts. A shape gives each pixel a number, its place in the order of reveal. A progress from 0 to 1 sweeps through those numbers, and every pixel whose number is behind the progress is shown.
The shape decides the look
The shape is any function of the pixel’s UVA 2D position on a surface or the screen, usually from 0 to 1 on both axes. Shaders draw shapes and patterns as functions of it. UV coordinates A 2D position on a surface or the screen, usually from 0 to 1 on both axes. Shaders draw shapes and patterns as functions of it. Signed distance field (SDF) A function that returns how far a point is from the edge of a shape, negative inside and positive outside. Zero is the outline itself. Noise A smooth pseudo-random function of position. Random values or gradients sit on a grid and are blended in between, so nearby points get similar values and the result has no visible pattern.uv = gl_FragCoord.xy / resolutionpolar fundamental) gives a clock wipe, and a
signed distanceA function that returns how far a point is from the edge of a shape, negative inside and positive outside. Zero is the outline itself.circle(p) = |p| − rfract first and running the shape in every tile gives the blinds and checker sweeps of old video editors.
The edge and the timing
Comparing the shape with the progress through Smoothstep A soft threshold. It is 0 below the first edge, 1 above the second, and follows an S-shaped curve with flat ends in between. Easing A curve that bends a 0–1 progress so motion speeds up or slows down instead of moving at a constant rate.step gives a hard edge, which aliases into stairs on a diagonal.
A smoothstepA soft threshold. It is 0 below the first edge, 1 above the second, and follows an S-shaped curve with flat ends in between.t = clamp((x − e0) / (e1 − e0), 0, 1); s = t² (3 − 2t)ease-in-out: e = p² (3 − 2p) curve makes the edge start gently and settle at the end, which is most of
what separates a polished transition from a mechanical one.
Where the result goes
The wipe’s result is a mask: 1 where the new picture shows, 0 where the old one still does. On a UI element or a
sprite, the mask is the element’s alpha. Between two whole scenes it is the blend factor between two images, which
means both scenes must exist as textures at the same time: the old frame saved to a
render targetA texture a draw writes into instead of the screen, so a later pass can read the result. Blur, bloom and every multi-pass effect use them. Render target A texture a draw writes into instead of the screen, so a later pass can read the result. Blur, bloom and every multi-pass effect use them. Post-process chain Full-screen passes run in order over the finished frame, each reading the image the previous one wrote. Bloom, tone mapping and color grading live here.
Further reading
- Easing Functions Cheat Sheet (opens in a new tab)Reference
- <easing-function> (opens in a new tab)Docs
- Useful little functions (opens in a new tab)Article
- atan (opens in a new tab)Reference
- Polar coordinate system (opens in a new tab)Reference
- Shapes (opens in a new tab)Book
- 2D distance functions (opens in a new tab)Article
- Signed distance function (opens in a new tab)Reference
- step (opens in a new tab)Reference
- smoothstep (opens in a new tab)Reference
- Shaping functions (opens in a new tab)Book
- Framebuffers (opens in a new tab)Article
- Bloom (opens in a new tab)Article
- Custom post-processing (opens in a new tab)Docs
- dot (opens in a new tab)Reference
- mix (opens in a new tab)Reference
- radians (opens in a new tab)Reference
- CanvasItem shaders (opens in a new tab)Docs