Ink Drip
Glossy black liquid hangs along the top of the frame and runs down in heavy drips that stretch, breathe, swell into rounded bulbs and let go of droplets that stretch as they fall and wobble from the release, sending a recoil ripple back across the pool. It looks like wet lacquer: long strip-light gleams roll across slow swells, a bright wet rim traces every edge, and an oil-slick sheen of violet, teal and gold lives in the highlights, lifted by a real bloom. Drag across the pool and it ripples behind your cursor while nearby drips swell and lean toward you, a click splashes a ring and starts a new drip right there, and scrolling stretches the drips and sets them swinging.
Tweak
LIVELIVEColour
Liquid
Motion
Interactive
The liquid leans toward the cursor, clicks start a drip
Usage
Follows your tweaks.
import { InkDrip } from "@/components/inreact/ink-drip";
export function Hero() {
return (
<InkDrip
className="h-screen w-full"
>
{/* optional: your hero content, drawn above the liquid */}
</InkDrip>
);
}Install with the CLI
npx shadcn@latest add https://inreact.vercel.app/r/ink-drip.jsonOr copy the source
Install the dependencies, then save this as components/inreact/ink-drip.tsx.
npm install gsap"use client";
import { gsap } from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
import { useEffect, useRef, type ReactNode } from "react";
gsap.registerPlugin(ScrollTrigger);
/**
* Ink Drip: glossy black liquid pooling along the top and dripping down the frame.
*
* A pool of black liquid, glossy as wet lacquer, hangs along the top edge and
* runs down in heavy drips: each one stretches, swells into a rounded bulb at
* its tip and lets go of a droplet that falls away. The liquid is a real
* surface with a soft rounded profile, so it reflects a dark studio in long
* soft gleams, and where it curves away a thin oil-slick sheen of colour
* (violet, teal, gold) slides across it. A real bloom pass lets the brightest
* gleams glow; the blacks stay black.
*
* It is always alive: drips grow, breathe, stretch and let go of drops that pull
* long as they fall and wobble from the release, while the recoil ripples back
* across the pool. It reacts: dragging over the pool leaves a trail of ripples,
* drips near the cursor swell and lean toward it and the reflections follow; a
* click splashes a ring and starts a new drip right there; scrolling stretches
* the drips and sets them swinging. On load the liquid pours down from the top.
*
* <InkDrip className="h-screen w-full">
* <YourHero />
* </InkDrip>
*
* WebGL: one shader (a smooth-union distance field of the pool, drips and drops,
* a rounded meniscus height profile with swells and expanding ripple rings, strip
* light studio reflections, a Fresnel wet rim and thin-film colour), then bloom
* at 1/4 and 1/16 size; the drips, drops and ripples are simulated in JS. GSAP
* drives every motion.
* Pauses off-screen; reduced motion shows a still frame; a CSS gradient without
* WebGL.
*/
export interface InkDripProps {
/** Colour of the reflections. */
light?: string;
/** Tint of the liquid. */
ink?: string;
/** Background colour. */
background?: string;
/** Strength of the oil-slick colour. */
sheen?: number;
/** How many drips. */
drips?: number;
/** Strength of the bloom. */
glow?: number;
/** Speed of the dripping. */
speed?: number;
/** Cursor pull, click drip. */
interactive?: boolean;
/** Scroll container if the page does not scroll the window. */
scroller?: Element | null;
/** Foreground content, drawn above the liquid. */
children?: ReactNode;
className?: string;
}
const MAXD = 14;
const MAXF = 10;
const MAXR = 10;
const QUAD = `attribute vec2 aQ; varying vec2 vUv; void main(){ vUv = aQ * 0.5 + 0.5; gl_Position = vec4(aQ, 0.0, 1.0); }`;
const SCENE = `
precision highp float;
uniform vec2 uRes, uMouse, uEnv;
uniform float uTime, uClock, uIn, uSheen, uHover, uPour;
uniform vec3 uLight, uInk, uBg;
// drips: x, length, bulb radius, stem width; falling drops: x, y, radius, stretch
uniform vec4 uD[${MAXD}];
uniform vec4 uF[${MAXF}];
// how ripe each drip is (0 just started, 1 about to let go)
uniform float uRipe[${MAXD}];
// how far each drip's tip has swung sideways
uniform float uSway[${MAXD}];
// ripples on the surface: x, y, start time, strength
uniform vec4 uR[${MAXR}];
varying vec2 vUv;
float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
float smin(float a, float b, float k) {
float h = clamp(0.5 + 0.5 * (b - a) / k, 0.0, 1.0);
return mix(b, a, h) - k * h * (1.0 - h);
}
float smax(float a, float b, float k) { return -smin(-a, -b, k); }
float sdSeg(vec2 p, vec2 a, vec2 b) {
vec2 pa = p - a, ba = b - a;
float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);
return length(pa - ba * h);
}
// the edge of the pool: a slow, organic wavering line some way down from the top
float poolEdge(float x) {
float w = 0.05 * sin(x * 3.7 + uTime * 0.28) + 0.026 * sin(x * 8.3 - uTime * 0.21) + 0.012 * sin(x * 17.0 + uTime * 0.4);
return 1.0 - (0.34 + w) * uPour;
}
float field(vec2 p) {
// the liquid leans toward the cursor
vec2 dm = p - uMouse;
p -= dm * 0.12 * exp(-dot(dm, dm) / 0.016) * uHover;
float d = poolEdge(p.x) - p.y;
for (int i = 0; i < ${MAXD}; i++) {
vec4 D = uD[i];
if (D.y <= 0.0) continue;
float top = poolEdge(D.x) + 0.01;
vec2 tip = vec2(D.x + uSway[i], top - D.y);
// a stem tapering down from the pool, and a rounded bulb gathering at the tip
float t = clamp((top - p.y) / max(D.y, 1e-3), 0.0, 1.0);
// a ripe drip pinches into a thin neck just above its bulb before it lets go
float neck = 1.0 - 0.45 * pow(uRipe[i], 3.0) * exp(-pow((t - 0.86) / 0.09, 2.0));
// the stem bows with its swing, like a real hanging thread of liquid
vec2 a = vec2(D.x, top);
vec2 mid = mix(a, tip, 0.55) + vec2(uSway[i] * 0.35, 0.0);
float stem = smin(sdSeg(p, a, mid), sdSeg(p, mid, tip), 0.03) - D.w * mix(1.6, 0.55, t) * neck;
// softly clipped at the pool edge, so its cap never bumps the pool and the join stays a smooth fillet
stem = smax(stem, p.y - poolEdge(p.x), 0.02);
float bulb = length(p - tip - vec2(0.0, D.z * 0.3)) - D.z;
d = smin(d, smin(stem, bulb, 0.045), 0.06);
}
for (int i = 0; i < ${MAXF}; i++) {
vec4 F = uF[i];
if (F.w <= 0.0) continue;
// a falling drop, pulled long by its fall and still wobbling from letting go
vec2 q = p - F.xy;
q.y /= F.w;
q.x *= sqrt(F.w);
d = smin(d, (length(q) - F.z) * min(1.0, F.w), 0.035);
}
return d;
}
// a rounded, glossy profile: rises from the edge like a meniscus, never a flat plateau
float height(vec2 p, out float depth) {
float d = field(p);
depth = max(-d, 0.0);
float h = 0.05 * (1.0 - exp(-depth / 0.016));
// slow, broad swells roll across the pool
float poolD = max(p.y - poolEdge(p.x), 0.0);
float sw = sin(p.x * 2.3 + p.y * 1.7 + uTime * 0.22) * 0.5
+ sin(p.x * 4.1 - p.y * 3.3 - uTime * 0.17) * 0.35
+ sin(p.x * 7.7 + p.y * 0.9 + uTime * 0.31) * 0.15;
h += sw * 0.02 * smoothstep(0.02, 0.22, poolD);
// ripples: rings that run outward and fade, only on the pool (drips stay smooth)
float wet = smoothstep(0.01, 0.06, poolD);
for (int i = 0; i < ${MAXR}; i++) {
vec4 R = uR[i];
if (R.w <= 0.0) continue;
float age = uClock - R.z;
if (age < 0.0 || age > 3.5) continue;
float r = length(p - R.xy);
float front = age * 0.32;
float band = exp(-pow((r - front) / (0.025 + age * 0.03), 2.0));
h += sin((r - front) * 80.0) * band * exp(-age * 1.15) * R.w * 0.0034 * wet;
}
return h;
}
// the studio: near black, two long strip lights, a small rounded soft box and a hard glint
float env(vec3 r) {
vec2 e = r.xy - uEnv;
// strip lights: long, crisp, finite bars
vec2 a1 = vec2(0.94, 0.34);
float s1 = exp(-pow((dot(e, vec2(-a1.y, a1.x)) - 0.42) / 0.032, 2.0)) * smoothstep(0.75, 0.2, abs(dot(e, a1) - 0.1));
vec2 a2 = vec2(0.42, -0.91);
float s2 = exp(-pow((dot(e, vec2(-a2.y, a2.x)) + 0.48) / 0.022, 2.0)) * smoothstep(0.6, 0.15, abs(dot(e, a2) + 0.05)) * 0.55;
// a small rounded soft box up and to the left
vec2 b = e - vec2(-0.42, 0.5);
float box = 1.0 - smoothstep(0.08, 0.2, length(b * vec2(1.0, 1.7)));
// the hard glint: a tiny bright light that sits on every bulb and curve
vec2 g = e - vec2(0.5, 0.58);
float glint = exp(-dot(g, g) / 0.0028) * 1.9;
// a broad soft band overhead: the slow swells roll long gleams across the pool
float band = exp(-pow((dot(e, vec2(-0.45, 0.89)) + 0.03) / 0.075, 2.0)) * 0.3
+ exp(-pow((dot(e, vec2(0.8, 0.6)) - 0.12) / 0.05, 2.0)) * 0.12;
// a faint gradient sky so the curves never go dead flat
float sky = 0.02 + 0.05 * smoothstep(-0.3, 1.0, r.y) * r.z;
return s1 * 0.95 + s2 + box * 0.45 + glint + band + sky;
}
void main() {
float H = uRes.y;
vec2 p = gl_FragCoord.xy / H;
float d = field(p);
vec3 col = uBg;
if (d < 0.004) {
// a moderate step rounds off the faint crease along each drip's spine
float e = 2.2 / H;
float dep, tmp;
float h0 = height(p, dep);
float hx = height(p + vec2(e, 0.0), tmp);
float hy = height(p + vec2(0.0, e), tmp);
vec3 n = normalize(vec3(-(hx - h0) / e, -(hy - h0) / e, 1.0));
vec3 r = reflect(vec3(0.0, 0.0, -1.0), n);
// Schlick fresnel: glossy lacquer reflects more as the surface turns away
float fr = 0.04 + 0.96 * pow(1.0 - max(n.z, 0.0), 5.0);
float refl = env(r);
// deep black body with the faintest tint of the ink colour
vec3 liquid = uInk * (0.025 + 0.03 * n.z);
liquid += uLight * refl * mix(0.42, 1.0, fr);
// a wet rim right at the edge of the liquid
float rim = exp(-dep / 0.0035) * smoothstep(0.0, 0.0015, dep);
liquid += uLight * rim * 0.22;
// oil-slick thin film: thickness from the surface height, seen mostly in the light it reflects
float film = h0 * 26.0 + fr * 1.6 + dot(n.xy, vec2(0.7, 0.5)) * 1.3 + uTime * 0.04;
vec3 irid = 0.5 + 0.5 * cos(6.2832 * (film + vec3(0.0, 0.33, 0.67)));
float graze = smoothstep(0.06, 0.6, 1.0 - n.z);
float streak = 0.55 + 0.45 * sin(film * 2.7 + p.x * 3.0);
liquid += irid * graze * streak * uSheen * (0.12 + refl * 0.55);
float cover = 1.0 - smoothstep(-1.2 / H, 1.2 / H, d);
col = mix(col, liquid, cover);
}
col += (hash(gl_FragCoord.xy + fract(uTime) * 91.0) - 0.5) / 255.0;
gl_FragColor = vec4(col * uIn, 1.0);
}`;
const BLUR = `
precision mediump float;
uniform sampler2D uTex;
uniform vec2 uStep;
varying vec2 vUv;
void main() {
vec4 c = texture2D(uTex, vUv) * 0.2270;
c += (texture2D(uTex, vUv + uStep * 1.3846) + texture2D(uTex, vUv - uStep * 1.3846)) * 0.3162;
c += (texture2D(uTex, vUv + uStep * 3.2308) + texture2D(uTex, vUv - uStep * 3.2308)) * 0.0703;
gl_FragColor = c;
}`;
const BRIGHT = `
precision mediump float;
uniform sampler2D uTex;
varying vec2 vUv;
void main() {
vec3 c = texture2D(uTex, vUv).rgb;
float l = max(c.r, max(c.g, c.b));
gl_FragColor = vec4(c * smoothstep(0.6, 1.0, l), 1.0);
}`;
const COMPOSITE = `
precision mediump float;
uniform sampler2D uScene, uBloom, uWide;
uniform float uGlow, uTime;
varying vec2 vUv;
float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
void main() {
vec3 sc = texture2D(uScene, vUv).rgb;
vec3 bl = texture2D(uBloom, vUv).rgb * 0.6 + texture2D(uWide, vUv).rgb * 0.5;
vec3 x = sc + bl * uGlow;
vec3 col = x / (1.0 + max(x - 0.85, 0.0) * 1.3);
col = min(col, vec3(1.0));
col += (hash(gl_FragCoord.xy + fract(uTime * 7.0) * 91.0) - 0.5) / 255.0;
gl_FragColor = vec4(col, 1.0);
}`;
const isReducedMotion = () =>
typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
function rgb(hex: string): [number, number, number] {
let h = hex.replace("#", "");
if (h.length === 3) h = h.replace(/./g, (c) => c + c);
const n = parseInt(h, 16) || 0;
return [((n >> 16) & 255) / 255, ((n >> 8) & 255) / 255, (n & 255) / 255];
}
export function InkDrip({
light = "#f2f2ee",
ink = "#8a8f99",
background = "#000000",
sheen = 1,
drips = 9,
glow = 0.6,
speed = 1,
interactive = true,
scroller,
children,
className,
}: InkDripProps) {
const hostRef = useRef<HTMLDivElement>(null);
const props = useRef({ light, ink, background, sheen, drips, glow, speed, interactive });
const redraw = useRef<(() => void) | null>(null);
useEffect(() => {
props.current = { light, ink, background, sheen, drips, glow, speed, interactive };
redraw.current?.();
}, [light, ink, background, sheen, drips, glow, speed, interactive]);
useEffect(() => {
const host = hostRef.current;
if (!host) return;
if (getComputedStyle(host).position === "static") host.style.position = "relative";
const still = isReducedMotion();
const canvas = document.createElement("canvas");
canvas.setAttribute("aria-hidden", "true");
canvas.style.cssText = "position:absolute;inset:0;width:100%;height:100%;display:block;touch-action:pan-y;";
host.prepend(canvas);
const gl = canvas.getContext("webgl", { alpha: false, antialias: false, powerPreference: "high-performance" });
if (!gl) {
const p = props.current;
host.style.background = `linear-gradient(${p.ink}55, ${p.background} 25%), ${p.background}`;
canvas.remove();
return;
}
const build = (fs: string) => {
const pr = gl.createProgram()!;
for (const [type, src] of [
[gl.VERTEX_SHADER, QUAD],
[gl.FRAGMENT_SHADER, fs],
] as const) {
const sh = gl.createShader(type)!;
gl.shaderSource(sh, src);
gl.compileShader(sh);
if (!gl.getShaderParameter(sh, gl.COMPILE_STATUS)) console.error(gl.getShaderInfoLog(sh));
gl.attachShader(pr, sh);
}
gl.linkProgram(pr);
if (!gl.getProgramParameter(pr, gl.LINK_STATUS)) console.error(gl.getProgramInfoLog(pr));
return pr;
};
const sceneProg = build(SCENE);
const blurProg = build(BLUR);
const brightProg = build(BRIGHT);
const compProg = build(COMPOSITE);
const uni = (pr: WebGLProgram, names: string[]) =>
Object.fromEntries(names.map((n) => [n, gl.getUniformLocation(pr, n)])) as Record<string, WebGLUniformLocation | null>;
const US = uni(sceneProg, ["uRes", "uMouse", "uEnv", "uTime", "uClock", "uIn", "uSheen", "uHover", "uPour", "uLight", "uInk", "uBg", "uD", "uF", "uRipe", "uSway", "uR"]);
const UB = uni(blurProg, ["uTex", "uStep"]);
const UR = uni(brightProg, ["uTex"]);
const UC = uni(compProg, ["uScene", "uBloom", "uWide", "uGlow", "uTime"]);
const quad = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, quad);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);
const drawQuad = (pr: WebGLProgram) => {
const a = gl.getAttribLocation(pr, "aQ");
gl.bindBuffer(gl.ARRAY_BUFFER, quad);
gl.enableVertexAttribArray(a);
gl.vertexAttribPointer(a, 2, gl.FLOAT, false, 0, 0);
gl.drawArrays(gl.TRIANGLES, 0, 3);
gl.disableVertexAttribArray(a);
};
type Target = { fb: WebGLFramebuffer; tex: WebGLTexture; w: number; h: number };
const target = (tw: number, th: number): Target => {
const tex = gl.createTexture()!;
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, tw, th, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
const fb = gl.createFramebuffer()!;
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
return { fb, tex, w: tw, h: th };
};
let T: { scene: Target; a: Target; b: Target; c: Target; d: Target } | null = null;
const freeTargets = () => {
if (!T) return;
for (const x of Object.values(T)) {
gl.deleteFramebuffer(x.fb);
gl.deleteTexture(x.tex);
}
T = null;
};
let w = 1, h = 1, dpr = 1;
const resize = () => {
dpr = Math.min(window.devicePixelRatio || 1, 1.5);
w = Math.max(1, host.clientWidth);
h = Math.max(1, host.clientHeight);
canvas.width = Math.round(w * dpr);
canvas.height = Math.round(h * dpr);
const sw = canvas.width, sh = canvas.height;
freeTargets();
T = {
scene: target(sw, sh),
a: target(Math.max(1, sw >> 2), Math.max(1, sh >> 2)),
b: target(Math.max(1, sw >> 2), Math.max(1, sh >> 2)),
c: target(Math.max(1, sw >> 4), Math.max(1, sh >> 4)),
d: target(Math.max(1, sw >> 4), Math.max(1, sh >> 4)),
};
};
resize();
// ---- state: every value GSAP moves (height units, y up) ----
const s = { in: still ? 1 : 0, pour: still ? 1 : 0, ex: 0, ey: 0, dx: 0, dy: 0, mx: -9, my: -9, hover: 0, stretch: 1 };
let time = still ? 10 : 0;
const rand = (a: number, b: number) => a + Math.random() * (b - a);
type Drip = { x: number; len: number; max: number; rate: number; bulb: number; w: number; sway: number; sv: number; phase: number; hold: boolean; near: number };
type Drop = { x: number; y: number; r: number; v: number; vx: number; age: number };
// ripples on the liquid: rings that run outward from the cursor, clicks and letting go
type Ripple = { x: number; y: number; t: number; s: number };
const ripples: Ripple[] = [];
const t0 = performance.now();
const clock = () => (performance.now() - t0) / 1000;
const ripple = (x: number, y: number, strength: number) => {
ripples.push({ x, y, t: clock(), s: strength });
if (ripples.length > MAXR) ripples.shift();
};
const drips: Drip[] = [];
const drops: Drop[] = [];
// pick a spot that keeps clear of the other drips, so they never crowd into a clump
const freeX = () => {
const hi = Math.max(0.3, w / h - 0.04);
let best = rand(0.04, hi);
let bestGap = -1;
for (let k = 0; k < 24; k++) {
const x = rand(0.04, hi);
const gap = drips.reduce((m, d) => Math.min(m, Math.abs(d.x - x)), 9);
if (gap > bestGap) {
bestGap = gap;
best = x;
}
}
return best;
};
const newDrip = (x?: number): Drip => ({ x: x ?? freeX(), len: still ? rand(0.1, 0.5) : rand(0.0, 0.06), max: rand(0.25, 0.75), rate: rand(0.015, 0.05), bulb: rand(0.016, 0.026), w: rand(0.008, 0.013), sway: 0, sv: 0, phase: rand(0, 6.28), hold: false, near: 0 });
const fill = () => {
const n = Math.max(1, Math.min(MAXD, Math.round(props.current.drips)));
while (drips.length < n) drips.push(newDrip());
while (drips.length > n) drips.pop();
};
fill();
const Dbuf = new Float32Array(MAXD * 4), Fbuf = new Float32Array(MAXF * 4), Rbuf = new Float32Array(MAXD), Sbuf = new Float32Array(MAXD);
const RPbuf = new Float32Array(MAXR * 4);
// where the pool's edge sits at x: the same curve as the shader
const edgeAt = (x: number) =>
1 - (0.34 + 0.05 * Math.sin(x * 3.7 + time * 0.28) + 0.026 * Math.sin(x * 8.3 - time * 0.21) + 0.012 * Math.sin(x * 17 + time * 0.4)) * s.pour + 0.01;
let mvx = 0;
const blurPass = (src: Target, dst: Target, dx: number, dy: number) => {
gl.bindFramebuffer(gl.FRAMEBUFFER, dst.fb);
gl.viewport(0, 0, dst.w, dst.h);
gl.useProgram(blurProg);
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, src.tex);
gl.uniform1i(UB.uTex, 0);
gl.uniform2f(UB.uStep, dx / src.w, dy / src.h);
drawQuad(blurProg);
};
const draw = () => {
if (!T) return;
const p = props.current;
const X = T;
gl.bindFramebuffer(gl.FRAMEBUFFER, X.scene.fb);
gl.viewport(0, 0, X.scene.w, X.scene.h);
gl.useProgram(sceneProg);
gl.uniform2f(US.uRes, X.scene.w, X.scene.h);
fill();
Dbuf.fill(0);
Fbuf.fill(0);
Rbuf.fill(0);
Sbuf.fill(0);
drips.forEach((d, i) => {
Rbuf[i] = Math.min(1, d.len / d.max);
Sbuf[i] = d.sway;
});
drips.forEach((d, i) => {
// the bulb breathes as it ripens and swells when the cursor is near
const ripe = Math.min(1, d.len / d.max);
const breathe = 1 + 0.06 * Math.sin(time * 3.1 + d.phase) * ripe + d.near * 0.22;
Dbuf.set([d.x, d.len * s.stretch * s.pour, d.bulb * Math.min(1, 0.4 + d.len * 3) * breathe, d.w], i * 4);
});
drops.slice(0, MAXF).forEach((f, i) => {
// pulled long by its speed, wobbling for a moment after it lets go
const stretch = 1 + Math.min(0.55, f.v * 0.45) + 0.16 * Math.sin(f.age * 23) * Math.exp(-f.age * 4.5);
Fbuf.set([f.x, f.y, f.r, stretch], i * 4);
});
RPbuf.fill(0);
ripples.forEach((r, i) => RPbuf.set([r.x, r.y, r.t, r.s], i * 4));
gl.uniform2f(US.uMouse, s.mx, s.my);
gl.uniform2f(US.uEnv, s.ex + s.dx, s.ey + s.dy);
gl.uniform1f(US.uTime, time);
gl.uniform1f(US.uClock, clock());
gl.uniform4fv(US.uR, RPbuf);
gl.uniform1f(US.uIn, s.in);
gl.uniform1f(US.uSheen, p.sheen);
gl.uniform1f(US.uHover, s.hover);
gl.uniform1f(US.uPour, s.pour);
gl.uniform3fv(US.uLight, rgb(p.light));
gl.uniform3fv(US.uInk, rgb(p.ink));
gl.uniform3fv(US.uBg, rgb(p.background));
gl.uniform4fv(US.uD, Dbuf);
gl.uniform4fv(US.uF, Fbuf);
gl.uniform1fv(US.uRipe, Rbuf);
gl.uniform1fv(US.uSway, Sbuf);
drawQuad(sceneProg);
gl.bindFramebuffer(gl.FRAMEBUFFER, X.a.fb);
gl.viewport(0, 0, X.a.w, X.a.h);
gl.useProgram(brightProg);
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, X.scene.tex);
gl.uniform1i(UR.uTex, 0);
drawQuad(brightProg);
blurPass(X.a, X.b, 1, 0);
blurPass(X.b, X.a, 0, 1);
blurPass(X.a, X.c, 1, 0);
blurPass(X.c, X.d, 0, 1);
blurPass(X.d, X.c, 1.8, 0);
blurPass(X.c, X.d, 0, 1.8);
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
gl.viewport(0, 0, canvas.width, canvas.height);
gl.useProgram(compProg);
[X.scene.tex, X.a.tex, X.d.tex].forEach((tex, i) => {
gl.activeTexture(gl.TEXTURE0 + i);
gl.bindTexture(gl.TEXTURE_2D, tex);
});
gl.uniform1i(UC.uScene, 0);
gl.uniform1i(UC.uBloom, 1);
gl.uniform1i(UC.uWide, 2);
gl.uniform1f(UC.uGlow, p.glow);
gl.uniform1f(UC.uTime, time);
drawQuad(compProg);
gl.activeTexture(gl.TEXTURE0);
};
const ro = new ResizeObserver(() => {
resize();
draw();
});
ro.observe(host);
if (still) {
draw();
redraw.current = draw;
return () => {
redraw.current = null;
ro.disconnect();
freeTargets();
canvas.remove();
gl.getExtension("WEBGL_lose_context")?.loseContext();
};
}
// ---- on load: the liquid pours down from the top ----
const intro = gsap
.timeline({ delay: 0.1 })
.to(s, { in: 1, duration: 1.2, ease: "power2.out" }, 0)
.to(s, { pour: 1, duration: 2.6, ease: "power3.out" }, 0);
// ---- idle: the studio light glides, so the gleams slide over the liquid ----
const drift = gsap
.timeline({ repeat: -1, yoyo: true })
.to(s, { dx: 0.2, dy: -0.12, duration: 6, ease: "sine.inOut" })
.to(s, { dx: -0.18, dy: 0.1, duration: 6.5, ease: "sine.inOut" });
// ---- cursor: the liquid leans toward it and the reflections follow ----
const exTo = gsap.quickTo(s, "ex", { duration: 1, ease: "power3" });
const eyTo = gsap.quickTo(s, "ey", { duration: 1, ease: "power3" });
const mxTo = gsap.quickTo(s, "mx", { duration: 0.6, ease: "power3" });
const myTo = gsap.quickTo(s, "my", { duration: 0.6, ease: "power3" });
const hoverTo = gsap.quickTo(s, "hover", { duration: 0.8, ease: "power2.inOut" });
const local = (e: PointerEvent) => {
const r = host.getBoundingClientRect();
return { x: (e.clientX - r.left) / r.height, y: (r.bottom - e.clientY) / r.height, nx: (e.clientX - r.left) / r.width - 0.5, ny: (r.bottom - e.clientY) / r.height - 0.5 };
};
let first = true;
let lastRipple = 0;
let lx = 0, ly = 0, lt = 0;
const move = (e: PointerEvent) => {
if (!props.current.interactive) return;
const p = local(e);
if (first) {
gsap.set(s, { mx: p.x, my: p.y });
first = false;
lx = p.x;
ly = p.y;
lt = performance.now();
}
// dragging through the liquid leaves a trail of ripples, stronger the faster you go
const now = performance.now();
const speed = Math.hypot(p.x - lx, p.y - ly) / Math.max(0.008, (now - lt) / 1000);
lx = p.x;
ly = p.y;
lt = now;
if (now - lastRipple > 70 && speed > 0.15 && p.y > edgeAt(p.x) - 0.03) {
lastRipple = now;
ripple(p.x, p.y, Math.min(1.3, 0.35 + speed * 0.35));
}
mvx = Math.max(-2, Math.min(2, (p.x - s.mx) * 6));
mxTo(p.x);
myTo(p.y);
hoverTo(1);
exTo(p.nx * -0.9);
eyTo(p.ny * -0.9);
};
const leave = () => {
first = true;
hoverTo(0);
exTo(0);
eyTo(0);
};
// ---- click: a new drip starts right where you clicked, running fast ----
const down = (e: PointerEvent) => {
if (!props.current.interactive) return;
const p = local(e);
ripple(p.x, Math.max(p.y, edgeAt(p.x) + 0.02), 1.8);
// replace the shortest drip so the count stays the same
let k = 0;
drips.forEach((d, i) => {
if (d.len < drips[k].len) k = i;
});
const nd = newDrip(p.x);
nd.rate = 0.18;
nd.max = Math.max(0.3, (0.8 - p.y) + 0.25);
gsap.killTweensOf(drips[k]);
drips[k] = nd;
};
host.addEventListener("pointermove", move);
host.addEventListener("pointerleave", leave);
host.addEventListener("pointerdown", down);
// ---- scroll: the drips stretch longer ----
const stretchTo = gsap.quickTo(s, "stretch", { duration: 1.2, ease: "power3" });
const st = ScrollTrigger.create({
trigger: host,
scroller: scroller ?? undefined,
start: "top bottom",
end: "bottom top",
onUpdate: (self) => {
stretchTo(1 + Math.max(0, self.progress - 0.5) * 0.8);
const v = Math.max(-3000, Math.min(3000, self.getVelocity())) / 3000;
drips.forEach((d, i) => (d.sv += v * 0.18 * (i % 2 ? 1 : -0.7)));
},
});
// ---- loop, only while on screen ----
let visible = true;
let prev = performance.now();
const loop = () => {
const now = performance.now();
const dt = Math.min(0.05, (now - prev) / 1000);
prev = now;
if (!visible) return;
const sp = props.current.speed;
time += dt * sp;
// drips grow slowly, faster as the bulb gets heavy, then let go of a drop and spring back
for (let i = 0; i < drips.length; i++) {
const d = drips[i];
// the cursor: drips near it grow faster and reach toward it; a fast pass flicks them
const top = edgeAt(d.x);
const tipY = top - d.len * s.stretch * s.pour;
const dx = s.mx - d.x;
const near = Math.exp(-(dx * dx) / 0.012) * (s.my < top + 0.05 ? 1 : 0.4) * s.hover;
d.near += (near - d.near) * Math.min(1, dt * 6);
const idle = Math.sin(time * 0.7 + d.phase) * 0.006 * (0.4 + d.len);
const target = idle + Math.max(-0.028, Math.min(0.028, dx * 0.35)) * near * Math.min(1, d.len * 3);
// a damped spring, so the drips swing like real liquid and settle
d.sv += ((target - d.sway) * 26 - d.sv * 4.5 + mvx * near * 3) * dt;
d.sway += d.sv * dt;
if (!d.hold) d.len += d.rate * (0.6 + d.len * 2.2) * (1 + near * 1.2) * dt * sp;
if (!d.hold && d.len > d.max) {
// let go: the drop leaves from the tip, and the drip springs back up smoothly
drops.push({ x: d.x + d.sway, y: tipY, r: d.bulb * 0.95, v: 0.02, vx: d.sv * 0.4, age: 0 });
// the recoil runs back up the drip and rings out across the pool
ripple(d.x, top + 0.015, 0.7);
d.hold = true;
gsap.to(d, {
len: d.max * 0.3,
duration: 1.1,
ease: "elastic.out(1, 0.45)",
onComplete: () => {
d.hold = false;
d.max = rand(0.25, 0.75);
d.rate = rand(0.015, 0.05);
},
});
} else if (d.rate > 0.1 && d.len > 0.15) d.rate = 0.05;
}
mvx *= Math.exp(-dt * 6);
for (let i = drops.length - 1; i >= 0; i--) {
const f = drops[i];
f.v += 1.4 * dt * sp;
f.age += dt;
f.y -= f.v * dt * sp;
f.x += f.vx * dt;
if (f.y < -0.1) drops.splice(i, 1);
}
if (drops.length > MAXF) drops.splice(0, drops.length - MAXF);
draw();
};
const io = new IntersectionObserver(([en]) => {
visible = en.isIntersecting;
prev = performance.now();
});
io.observe(host);
gsap.ticker.add(loop);
return () => {
gsap.ticker.remove(loop);
intro.kill();
drift.kill();
st.kill();
io.disconnect();
ro.disconnect();
host.removeEventListener("pointermove", move);
host.removeEventListener("pointerleave", leave);
host.removeEventListener("pointerdown", down);
gsap.killTweensOf(s);
drips.forEach((d) => gsap.killTweensOf(d));
freeTargets();
canvas.remove();
gl.getExtension("WEBGL_lose_context")?.loseContext();
};
}, [scroller]);
return (
<div ref={hostRef} className={["isolate overflow-hidden", className].filter(Boolean).join(" ")} style={{ background }}>
{children && <div className="relative z-10 h-full">{children}</div>}
</div>
);
}
One prompt, any AI agent
Paste into Claude Code, Codex, Cursor or Windsurf. It carries your tweaks and the full source, so the agent installs it exactly.
Props
11 propslightstringColour of the reflections.default "#f2f2ee"default "#f2f2ee"inkstringTint of the liquid.default "#8a8f99"default "#8a8f99"backgroundstringBackground colour.default "#000000"default "#000000"sheennumberStrength of the oil-slick colour.default 1default 1dripsnumberHow many drips.default 9default 9glownumberStrength of the bloom.default 0.6default 0.6speednumberSpeed of the dripping.default 1default 1interactivebooleanCursor pull, click drip.default truedefault truescrollerElement | nullScroll container, if the page does not scroll the window.childrenReactNodeForeground content, drawn above the liquid.classNamestringSize it, e.g. h-screen w-full.