Transition: Liquid
Both images ripple as if under water while one fades into the other. `warpGrid` takes a mesh computed in JavaScript; the offsets come from two small `createNoise` images read with `getPixel`, and the field drifts with T so the distortion flows.
A
B
Animation
JavaScript
// Liquid — one transition between two photos, exported as a looping animated WebP.
//
// Everything specific sits in transition(from, to, T): it takes two images it may change and a
// progress T from 0 to 1, and returns one new frame. Video tools can call exactly that for each
// frame of a cut; the rest of this script only builds the animation.
//!INPUT: A, B
//!OUTPUT: OUT
//!PARAM: STEPS:integer=18,min=2,max=120
//!PARAM: DELAY_MS:integer=50,min=10,max=2000
//!PARAM: HOLD_MS:integer=700,min=0,max=5000
//!PARAM: AMOUNT:number=28,min=0,max=300,step=2
//!PARAM: SCALE:number=110,min=20,max=800,step=10
//!PARAM: SEED:integer=3,min=0,max=99999
function transition(from, to, T) {
if (T <= 0 || T >= 1) {
(T <= 0 ? to : from).free();
return T <= 0 ? from : to;
}
const w = to.width, h = to.height;
const envelope = Math.sin(Math.PI * T);
const STEP = 12; // mesh size: far smaller than the clouds
const cols = Math.ceil(w / STEP) + 1, rows = Math.ceil(h / STEP) + 1;
// One value per mesh point is enough, so the noise stays small.
const small = (seed) =>
Engine.createNoise(cols * 2, rows * 2, { scale: SCALE / STEP, octaves: 3, seed });
const nx = small(SEED), ny = small(SEED + 5);
const drift = Math.round(T * cols * 0.5); // the field moves: The distortion flows
const nodes = [];
for (let r = 0; r < rows; r++) {
const row = [];
for (let c = 0; c < cols; c++) {
const dx = (nx.getPixel(px(c + drift, r)).r - 0.5) * 2 * AMOUNT * envelope;
const dy = (ny.getPixel(px(c, r + drift)).r - 0.5) * 2 * AMOUNT * envelope;
row.push(((c / (cols - 1)) * w + dx) / w, ((r / (rows - 1)) * h + dy) / h);
}
nodes.push(row);
}
nx.free();
ny.free();
const grid = { rows, cols, nodes };
from.warpGrid(grid);
to.warpGrid(grid);
from.blend(to, T * T * (3 - 2 * T));
to.free();
return from;
}
const imgA = Engine.loadImage(A);
const imgB = Engine.loadImage(B);
if (imgB.width !== imgA.width || imgB.height !== imgA.height) {
imgB.resize(imgA.width, imgA.height);
}
const anim = Engine.animation(imgA.width, imgA.height, { loop: 0 });
const p = Engine.progress("Transition frames", { total: STEPS * 2 });
// There and back: the loop closes without a jump, and both directions show the effect.
for (const [first, second] of [[imgA, imgB], [imgB, imgA]]) {
for (let i = 0; i < STEPS; i++) {
const T = i / (STEPS - 1);
const frame = transition(first.clone(), second.clone(), T);
anim.addFrame(frame, { delay: i === STEPS - 1 ? HOLD_MS : DELAY_MS });
frame.free();
p.step(1, `frame ${i + 1}/${STEPS}`);
}
}
anim.saveWebP(OUT, { lossy: true, quality: 62 });
anim.free();
imgA.free();
imgB.free();
// © 2026 Michael Lechner · mlc OpticScript · https://mlcgo.eu · Elastic License 2.0