motionlab/effects/liquid.glsl
0xrsydn 6591138bbf Python/OpenCV proof of concept plus first native Swift port
Snapshot before the Python POC is removed. The POC (main.py, effects.py,
panel.py, shaders.py, effects/*.glsl, flake.nix) is the reference for the
native app under native/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 20:26:47 +07:00

13 lines
550 B
GLSL

// Liquid trails: the previous output is dragged along the motion, swirled a little,
// and slowly fades back to the live camera.
uniform float persistence; // 0.0 .. 0.99 = 0.92
uniform float drag; // 0.0 .. 6.0 = 2.5
uniform float swirl; // 0.0 .. 0.01 = 0.002
void main() {
vec2 centred = uv - 0.5;
vec2 from = uv - texture(flow, uv).xy * drag + vec2(-centred.y, centred.x) * swirl;
vec3 trail = texture(prev, from).rgb;
vec3 live = texture(camera, uv).rgb;
color = vec4(mix(live, trail, persistence), 1.0);
}