Liquid Glass PIN
A 4-digit PIN field made of glass. A wrong code turns it red and shakes the digits off, the right one melts all four cells into one pill.
- Codes & PIN
- Free
- webgl
- glass
- Added Sep 16, 2026
<style>
.wrap { position: relative; width: 540px; max-width: 100vw; }
.wrap canvas { display: block; width: 100%; aspect-ratio: 540 / 340; }
/* the only real input: invisible, sits on top of the glass, keeps iOS code autofill working */
.wrap input { position: absolute; inset: 0; opacity: 0; font-size: 16px; caret-color: transparent; }
.hint { margin-top: 18px; text-align: center; font-size: 13px; color: #5C6472; }
</style>
<div class="wrap">
<canvas id="gl" width="1080" height="680"></canvas>
<input id="code" inputmode="numeric" autocomplete="one-time-code" maxlength="4" aria-label="4-digit code">
</div>
<script>
// the numbers worth changing
const PIN = '2486';
const REFRACT = 34, MERGE = 22; // lens strength at the edge, how soft the cells melt together
const W = 540, H = 340, CX = 270, CY = 206, CELL_W = 86, CELL_H = 100, GAP = 18;
const clamp = (x, a = 0, b = 1) => Math.min(b, Math.max(a, x));
const lerp = (a, b, k) => a + (b - a) * k;
const eio = k => (k = clamp(k), k < .5 ? 4 * k * k * k : 1 - Math.pow(-2 * k + 2, 3) / 2);
const eout = k => 1 - Math.pow(1 - clamp(k), 3);
const bump = s => s < 0 ? 0 : Math.exp(-s * 9) * Math.sin(s * 34);
const input = document.getElementById('code');
let digits = [], landed = [], errT = -1, mergeT = -1, now = 0;
const cells = [0, 1, 2, 3].map(() => ({ x: 0, y: 0, w: 0, h: 0 }));
input.addEventListener('input', () => {
if (errT >= 0 || mergeT >= 0) { input.value = digits.join(''); return; }
const v = input.value.replace(/\D/g, '').slice(0, 4);
input.value = v;
for (let i = digits.length; i < v.length; i++) landed[i] = now;
digits = v.split('');
if (digits.length === 4) check(v);
});
input.addEventListener('pointerdown', () => { if (mergeT >= 0) reset(); });
addEventListener('keydown', e => { if (e.key === 'Escape') reset(); });
function reset() { digits = []; landed = []; errT = -1; mergeT = -1; input.value = ''; input.focus(); }
function check(code) {
if (code !== PIN) return shake();
mergeT = now;
}
function shake() {
errT = now;
setTimeout(() => { digits = []; landed = []; errT = -1; input.value = ''; }, 750);
}
function layout() {
cells.forEach((c, i) => { c.x = CX + (i - 1.5) * (CELL_W + GAP); c.y = CY; c.w = CELL_W / 2; c.h = CELL_H / 2; });
landed.forEach((t, i) => { const b = bump(now - t); cells[i].w += b * 4; cells[i].h += b * 5; });
let red = 0, smear = 0;
if (errT >= 0) {
const s = now - errT;
const dx = Math.exp(-s * 5) * Math.sin(s * 42) * 9;
cells.forEach(c => c.x += dx);
red = clamp(s / .12);
smear = clamp((s - .45) / .3);
}
if (mergeT >= 0) {
const k = eio((now - mergeT) / .7);
cells.forEach(c => c.x = lerp(c.x, CX, k));
cells.forEach(c => { c.w = lerp(CELL_W / 2, 158, k); c.h = lerp(CELL_H / 2, 46, k); });
const p = bump((now - mergeT - .7) * .7) * 1.2;
cells.forEach(c => { c.w += p * 10; c.h += p * 4; });
}
return { red, smear };
}
// layers: bg is refracted by the glass, fg (digits) sits on the glass
const mk = () => { const c = document.createElement('canvas'); c.width = W * 2; c.height = H * 2; const g = c.getContext('2d'); g.scale(2, 2); return [c, g]; };
const [bgC, bg] = mk(), [fgC, fg] = mk();
function drawBg(ok) {
bg.clearRect(0, 0, W, H);
bg.save(); bg.beginPath(); bg.roundRect(36, 6, 468, 328, 30); bg.clip();
bg.fillStyle = '#0E1116'; bg.fillRect(0, 0, W, H);
const w = now * .6;
const blobs = [
[CX - 120 + 40 * Math.sin(w), CY + 10 + 18 * Math.cos(w), 120, ok ? [58, 214, 140] : [46, 230, 200]],
[CX + 110 + 36 * Math.cos(2 * w), CY - 6 + 22 * Math.sin(w), 110, ok ? [120, 240, 170] : [123, 92, 255]],
[CX + 10 * Math.sin(2 * w), CY + 40 + 14 * Math.sin(2 * w), 96, ok ? [30, 160, 110] : [255, 122, 69]],
];
bg.filter = 'blur(26px)';
for (const [x, y, r, [R, G, B]] of blobs) {
const gr = bg.createRadialGradient(x, y, 0, x, y, r);
gr.addColorStop(0, `rgba(${R},${G},${B},.95)`); gr.addColorStop(1, `rgba(${R},${G},${B},0)`);
bg.fillStyle = gr; bg.fillRect(x - r, y - r, r * 2, r * 2);
}
bg.filter = 'none';
bg.strokeStyle = 'rgba(255,255,255,.07)';
for (let x = 52; x < 500; x += 16) { bg.beginPath(); bg.moveTo(x, 118); bg.lineTo(x, 300); bg.stroke(); }
bg.textAlign = 'center';
bg.fillStyle = '#F3F5F8'; bg.font = '700 23px system-ui'; bg.fillText(ok ? 'Verified' : 'Enter passcode', CX, 62);
bg.fillStyle = '#7A8290'; bg.font = '500 14px system-ui'; bg.fillText(ok ? 'Welcome back' : 'Sent to •• 42', CX, 86);
bg.restore();
}
function drawFg(st) {
fg.clearRect(0, 0, W, H);
const merge = mergeT >= 0 ? eio((now - mergeT) / .45) : 0;
fg.textAlign = 'center'; fg.textBaseline = 'middle'; fg.font = '600 44px system-ui';
digits.forEach((ch, i) => {
const land = eout((now - landed[i]) / .16);
fg.globalAlpha = land * (1 - st.smear) * (1 - merge);
fg.fillStyle = st.red > .05 ? '#FFD9D9' : '#FFFFFF';
fg.fillText(ch, cells[i].x, cells[i].y + 2 - (1 - land) * 14);
});
fg.globalAlpha = 1;
if (digits.length < 4 && errT < 0 && document.activeElement === input && Math.floor(now * 2.5) % 2 === 0) {
const c = cells[digits.length]; fg.fillStyle = '#FFFFFF'; fg.fillRect(c.x - 1.5, c.y - 21, 3, 42);
}
const ck = mergeT >= 0 ? clamp((now - mergeT - .8) / .4) : 0;
if (ck > 0) {
const a = [CX - 26, CY + 1], b = [CX - 8, CY + 18], c = [CX + 28, CY - 17];
const L1 = Math.hypot(18, 17), L2 = Math.hypot(36, 35), len = (L1 + L2) * eout(ck);
fg.strokeStyle = '#FFFFFF'; fg.lineWidth = 6.5; fg.lineCap = fg.lineJoin = 'round';
fg.beginPath(); fg.moveTo(...a);
if (len <= L1) fg.lineTo(lerp(a[0], b[0], len / L1), lerp(a[1], b[1], len / L1));
else { fg.lineTo(...b); const k = (len - L1) / L2; fg.lineTo(lerp(b[0], c[0], k), lerp(b[1], c[1], k)); }
fg.stroke();
}
}
// glass shader: rounded boxes melt together with smin, the edge bends what is behind
const gl = document.getElementById('gl').getContext('webgl2');
const FS = `#version 300 es
precision highp float;
uniform sampler2D bg, fg; uniform vec4 cell[4];
uniform float REFRACT, MERGE, red, smear, glow, time;
out vec4 o;
const vec2 RES = vec2(540., 340.);
float box(vec2 p, vec4 c) { vec2 q = abs(p - c.xy) - c.zw + 18.; return length(max(q, 0.)) + min(max(q.x, q.y), 0.) - 18.; }
float smin(float a, float b, float k) { float h = clamp(.5 + .5 * (b - a) / k, 0., 1.); return mix(b, a, h) - k * h * (1. - h); }
float scene(vec2 p) {
float d = 1e5;
for (int i = 0; i < 4; i++)
d = smin(d, box(p, cell[i]), MERGE);
return d;
}
vec3 tex(vec2 p) { return texture(bg, clamp(p / RES, 0., 1.)).rgb; }
void main() {
vec2 p = vec2(gl_FragCoord.x, 680. - gl_FragCoord.y) / 2.;
float d = scene(p);
vec2 e = vec2(.6, 0.);
vec2 n = normalize(vec2(scene(p + e.xy) - scene(p - e.xy), scene(p + e.yx) - scene(p - e.yx)) + 1e-5);
float edge = pow(1. - clamp(-d / 26., 0., 1.), 3.);
vec3 base = tex(p) * (1. - .45 * smoothstep(16., -6., scene(p - vec2(0., 10.))) * step(0., d));
vec2 uv = p - n * REFRACT * edge;
vec3 col = tex(uv);
vec3 glass = vec3(0.);
for (int k = 0; k < 6; k++) {
vec2 j = vec2(cos(float(k) * 1.0472), sin(float(k) * 1.0472)) * 1.6;
glass += vec3(tex(uv + j + n * 2.2 * edge).r, tex(uv + j).g, tex(uv + j - n * 2.2 * edge).b);
}
glass = mix(glass / 6., col, .35) * 1.06 + .035;
glass = mix(glass, vec3(1., .32, .34) * (dot(glass, vec3(.3, .59, .11)) * 1.3 + .12), red * .75);
vec2 L = normalize(vec2(-.55, -.85));
glass += smoothstep(2.4, 0., abs(d)) * (.28 + .72 * max(dot(n, L), 0.)) * .85;
glass += smoothstep(3., 0., abs(d + 3.)) * max(dot(n, -L), 0.) * .25;
vec4 f = texture(fg, clamp((p + vec2(sin(p.y * .35 + time * 30.), cos(p.x * .3)) * smear * 9.) / RES, 0., 1.));
glass = mix(glass, f.rgb, f.a * (1. - smear * .5));
vec3 outside = base + vec3(.24, .95, .6) * glow * exp(-max(d, 0.) / 16.) * step(0., d);
o = vec4(mix(outside, glass, smoothstep(.9, -.9, d)), 1.);
}`;
const sh = (t, s) => { const x = gl.createShader(t); gl.shaderSource(x, s); gl.compileShader(x); return x; };
const prog = gl.createProgram();
gl.attachShader(prog, sh(gl.VERTEX_SHADER, '#version 300 es\nin vec2 a; void main(){ gl_Position = vec4(a, 0., 1.); }'));
gl.attachShader(prog, sh(gl.FRAGMENT_SHADER, FS));
gl.linkProgram(prog); gl.useProgram(prog);
gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
gl.enableVertexAttribArray(0); gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
const U = n => gl.getUniformLocation(prog, n);
const tex = unit => { const t = gl.createTexture(); gl.activeTexture(gl.TEXTURE0 + unit); gl.bindTexture(gl.TEXTURE_2D, t);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); return t; };
const tBg = tex(0), tFg = tex(1);
gl.uniform1i(U('bg'), 0); gl.uniform1i(U('fg'), 1);
gl.uniform1f(U('REFRACT'), REFRACT); gl.uniform1f(U('MERGE'), MERGE);
function frame(ms) {
now = ms / 1000;
const st = layout(), ok = mergeT >= 0 && now - mergeT > .7;
drawBg(ok); drawFg(st);
gl.activeTexture(gl.TEXTURE0); gl.bindTexture(gl.TEXTURE_2D, tBg); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, bgC);
gl.activeTexture(gl.TEXTURE1); gl.bindTexture(gl.TEXTURE_2D, tFg); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, fgC);
const arr = new Float32Array(16); cells.forEach((c, i) => arr.set([c.x, c.y, c.w, c.h], i * 4));
gl.uniform4fv(U('cell[0]'), arr);
gl.uniform1f(U('red'), st.red); gl.uniform1f(U('smear'), st.smear); gl.uniform1f(U('time'), now);
gl.uniform1f(U('glow'), ok ? clamp((now - mergeT - .7) / .3) * (.55 + .2 * Math.sin(now * 4)) : 0);
gl.viewport(0, 0, 1080, 680); gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
requestAnimationFrame(frame);
}
input.focus();
requestAnimationFrame(frame);
</script>
Click the glass and type any 4 digits. The code that works is 2486.
What you can change
Change a number, save, and reload the page to see the difference.
PIN'2486'The code that passes. In a real project this check goes to your server, see step 4.
REFRACT34How hard the glass edge bends what is behind it. 0 is flat, 60 is a thick lens.
MERGE22How softly the cells melt together. 4 keeps the melt stiff, 60 makes them stick while you type.
Add it to your site
Put it inside your verification screen, where the code input should be.
CSS
Paste into your stylesheet, or inside a <style> tag in <head>.
.wrap { position: relative; width: 540px; max-width: 100vw; } .wrap canvas { display: block; width: 100%; aspect-ratio: 540 / 340; } /* the only real input: invisible, sits on top of the glass, keeps iOS code autofill working */ .wrap input { position: absolute; inset: 0; opacity: 0; font-size: 16px; caret-color: transparent; } .hint { margin-top: 18px; text-align: center; font-size: 13px; color: #5C6472; }HTML
Put it where the effect should appear on your page.
<div class="wrap"> <canvas id="gl" width="1080" height="680"></canvas> <input id="code" inputmode="numeric" autocomplete="one-time-code" maxlength="4" aria-label="4-digit code"> </div>JavaScript
Paste right before the closing </body> tag, inside <script></script>.
// the numbers worth changing const PIN = '2486'; const REFRACT = 34, MERGE = 22; // lens strength at the edge, how soft the cells melt together const W = 540, H = 340, CX = 270, CY = 206, CELL_W = 86, CELL_H = 100, GAP = 18; const clamp = (x, a = 0, b = 1) => Math.min(b, Math.max(a, x)); const lerp = (a, b, k) => a + (b - a) * k; const eio = k => (k = clamp(k), k < .5 ? 4 * k * k * k : 1 - Math.pow(-2 * k + 2, 3) / 2); const eout = k => 1 - Math.pow(1 - clamp(k), 3); const bump = s => s < 0 ? 0 : Math.exp(-s * 9) * Math.sin(s * 34); const input = document.getElementById('code'); let digits = [], landed = [], errT = -1, mergeT = -1, now = 0; const cells = [0, 1, 2, 3].map(() => ({ x: 0, y: 0, w: 0, h: 0 })); input.addEventListener('input', () => { if (errT >= 0 || mergeT >= 0) { input.value = digits.join(''); return; } const v = input.value.replace(/\D/g, '').slice(0, 4); input.value = v; for (let i = digits.length; i < v.length; i++) landed[i] = now; digits = v.split(''); if (digits.length === 4) check(v); }); input.addEventListener('pointerdown', () => { if (mergeT >= 0) reset(); }); addEventListener('keydown', e => { if (e.key === 'Escape') reset(); }); function reset() { digits = []; landed = []; errT = -1; mergeT = -1; input.value = ''; input.focus(); } function check(code) { if (code !== PIN) return shake(); mergeT = now; } function shake() { errT = now; setTimeout(() => { digits = []; landed = []; errT = -1; input.value = ''; }, 750); } function layout() { cells.forEach((c, i) => { c.x = CX + (i - 1.5) * (CELL_W + GAP); c.y = CY; c.w = CELL_W / 2; c.h = CELL_H / 2; }); landed.forEach((t, i) => { const b = bump(now - t); cells[i].w += b * 4; cells[i].h += b * 5; }); let red = 0, smear = 0; if (errT >= 0) { const s = now - errT; const dx = Math.exp(-s * 5) * Math.sin(s * 42) * 9; cells.forEach(c => c.x += dx); red = clamp(s / .12); smear = clamp((s - .45) / .3); } if (mergeT >= 0) { const k = eio((now - mergeT) / .7); cells.forEach(c => c.x = lerp(c.x, CX, k)); cells.forEach(c => { c.w = lerp(CELL_W / 2, 158, k); c.h = lerp(CELL_H / 2, 46, k); }); const p = bump((now - mergeT - .7) * .7) * 1.2; cells.forEach(c => { c.w += p * 10; c.h += p * 4; }); } return { red, smear }; } // layers: bg is refracted by the glass, fg (digits) sits on the glass const mk = () => { const c = document.createElement('canvas'); c.width = W * 2; c.height = H * 2; const g = c.getContext('2d'); g.scale(2, 2); return [c, g]; }; const [bgC, bg] = mk(), [fgC, fg] = mk(); function drawBg(ok) { bg.clearRect(0, 0, W, H); bg.save(); bg.beginPath(); bg.roundRect(36, 6, 468, 328, 30); bg.clip(); bg.fillStyle = '#0E1116'; bg.fillRect(0, 0, W, H); const w = now * .6; const blobs = [ [CX - 120 + 40 * Math.sin(w), CY + 10 + 18 * Math.cos(w), 120, ok ? [58, 214, 140] : [46, 230, 200]], [CX + 110 + 36 * Math.cos(2 * w), CY - 6 + 22 * Math.sin(w), 110, ok ? [120, 240, 170] : [123, 92, 255]], [CX + 10 * Math.sin(2 * w), CY + 40 + 14 * Math.sin(2 * w), 96, ok ? [30, 160, 110] : [255, 122, 69]], ]; bg.filter = 'blur(26px)'; for (const [x, y, r, [R, G, B]] of blobs) { const gr = bg.createRadialGradient(x, y, 0, x, y, r); gr.addColorStop(0, `rgba(${R},${G},${B},.95)`); gr.addColorStop(1, `rgba(${R},${G},${B},0)`); bg.fillStyle = gr; bg.fillRect(x - r, y - r, r * 2, r * 2); } bg.filter = 'none'; bg.strokeStyle = 'rgba(255,255,255,.07)'; for (let x = 52; x < 500; x += 16) { bg.beginPath(); bg.moveTo(x, 118); bg.lineTo(x, 300); bg.stroke(); } bg.textAlign = 'center'; bg.fillStyle = '#F3F5F8'; bg.font = '700 23px system-ui'; bg.fillText(ok ? 'Verified' : 'Enter passcode', CX, 62); bg.fillStyle = '#7A8290'; bg.font = '500 14px system-ui'; bg.fillText(ok ? 'Welcome back' : 'Sent to •• 42', CX, 86); bg.restore(); } function drawFg(st) { fg.clearRect(0, 0, W, H); const merge = mergeT >= 0 ? eio((now - mergeT) / .45) : 0; fg.textAlign = 'center'; fg.textBaseline = 'middle'; fg.font = '600 44px system-ui'; digits.forEach((ch, i) => { const land = eout((now - landed[i]) / .16); fg.globalAlpha = land * (1 - st.smear) * (1 - merge); fg.fillStyle = st.red > .05 ? '#FFD9D9' : '#FFFFFF'; fg.fillText(ch, cells[i].x, cells[i].y + 2 - (1 - land) * 14); }); fg.globalAlpha = 1; if (digits.length < 4 && errT < 0 && document.activeElement === input && Math.floor(now * 2.5) % 2 === 0) { const c = cells[digits.length]; fg.fillStyle = '#FFFFFF'; fg.fillRect(c.x - 1.5, c.y - 21, 3, 42); } const ck = mergeT >= 0 ? clamp((now - mergeT - .8) / .4) : 0; if (ck > 0) { const a = [CX - 26, CY + 1], b = [CX - 8, CY + 18], c = [CX + 28, CY - 17]; const L1 = Math.hypot(18, 17), L2 = Math.hypot(36, 35), len = (L1 + L2) * eout(ck); fg.strokeStyle = '#FFFFFF'; fg.lineWidth = 6.5; fg.lineCap = fg.lineJoin = 'round'; fg.beginPath(); fg.moveTo(...a); if (len <= L1) fg.lineTo(lerp(a[0], b[0], len / L1), lerp(a[1], b[1], len / L1)); else { fg.lineTo(...b); const k = (len - L1) / L2; fg.lineTo(lerp(b[0], c[0], k), lerp(b[1], c[1], k)); } fg.stroke(); } } // glass shader: rounded boxes melt together with smin, the edge bends what is behind const gl = document.getElementById('gl').getContext('webgl2'); const FS = `#version 300 es precision highp float; uniform sampler2D bg, fg; uniform vec4 cell[4]; uniform float REFRACT, MERGE, red, smear, glow, time; out vec4 o; const vec2 RES = vec2(540., 340.); float box(vec2 p, vec4 c) { vec2 q = abs(p - c.xy) - c.zw + 18.; return length(max(q, 0.)) + min(max(q.x, q.y), 0.) - 18.; } float smin(float a, float b, float k) { float h = clamp(.5 + .5 * (b - a) / k, 0., 1.); return mix(b, a, h) - k * h * (1. - h); } float scene(vec2 p) { float d = 1e5; for (int i = 0; i < 4; i++) d = smin(d, box(p, cell[i]), MERGE); return d; } vec3 tex(vec2 p) { return texture(bg, clamp(p / RES, 0., 1.)).rgb; } void main() { vec2 p = vec2(gl_FragCoord.x, 680. - gl_FragCoord.y) / 2.; float d = scene(p); vec2 e = vec2(.6, 0.); vec2 n = normalize(vec2(scene(p + e.xy) - scene(p - e.xy), scene(p + e.yx) - scene(p - e.yx)) + 1e-5); float edge = pow(1. - clamp(-d / 26., 0., 1.), 3.); vec3 base = tex(p) * (1. - .45 * smoothstep(16., -6., scene(p - vec2(0., 10.))) * step(0., d)); vec2 uv = p - n * REFRACT * edge; vec3 col = tex(uv); vec3 glass = vec3(0.); for (int k = 0; k < 6; k++) { vec2 j = vec2(cos(float(k) * 1.0472), sin(float(k) * 1.0472)) * 1.6; glass += vec3(tex(uv + j + n * 2.2 * edge).r, tex(uv + j).g, tex(uv + j - n * 2.2 * edge).b); } glass = mix(glass / 6., col, .35) * 1.06 + .035; glass = mix(glass, vec3(1., .32, .34) * (dot(glass, vec3(.3, .59, .11)) * 1.3 + .12), red * .75); vec2 L = normalize(vec2(-.55, -.85)); glass += smoothstep(2.4, 0., abs(d)) * (.28 + .72 * max(dot(n, L), 0.)) * .85; glass += smoothstep(3., 0., abs(d + 3.)) * max(dot(n, -L), 0.) * .25; vec4 f = texture(fg, clamp((p + vec2(sin(p.y * .35 + time * 30.), cos(p.x * .3)) * smear * 9.) / RES, 0., 1.)); glass = mix(glass, f.rgb, f.a * (1. - smear * .5)); vec3 outside = base + vec3(.24, .95, .6) * glow * exp(-max(d, 0.) / 16.) * step(0., d); o = vec4(mix(outside, glass, smoothstep(.9, -.9, d)), 1.); }`; const sh = (t, s) => { const x = gl.createShader(t); gl.shaderSource(x, s); gl.compileShader(x); return x; }; const prog = gl.createProgram(); gl.attachShader(prog, sh(gl.VERTEX_SHADER, '#version 300 es\nin vec2 a; void main(){ gl_Position = vec4(a, 0., 1.); }')); gl.attachShader(prog, sh(gl.FRAGMENT_SHADER, FS)); gl.linkProgram(prog); gl.useProgram(prog); gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer()); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW); gl.enableVertexAttribArray(0); gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0); const U = n => gl.getUniformLocation(prog, n); const tex = unit => { const t = gl.createTexture(); gl.activeTexture(gl.TEXTURE0 + unit); gl.bindTexture(gl.TEXTURE_2D, t); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); return t; }; const tBg = tex(0), tFg = tex(1); gl.uniform1i(U('bg'), 0); gl.uniform1i(U('fg'), 1); gl.uniform1f(U('REFRACT'), REFRACT); gl.uniform1f(U('MERGE'), MERGE); function frame(ms) { now = ms / 1000; const st = layout(), ok = mergeT >= 0 && now - mergeT > .7; drawBg(ok); drawFg(st); gl.activeTexture(gl.TEXTURE0); gl.bindTexture(gl.TEXTURE_2D, tBg); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, bgC); gl.activeTexture(gl.TEXTURE1); gl.bindTexture(gl.TEXTURE_2D, tFg); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, fgC); const arr = new Float32Array(16); cells.forEach((c, i) => arr.set([c.x, c.y, c.w, c.h], i * 4)); gl.uniform4fv(U('cell[0]'), arr); gl.uniform1f(U('red'), st.red); gl.uniform1f(U('smear'), st.smear); gl.uniform1f(U('time'), now); gl.uniform1f(U('glow'), ok ? clamp((now - mergeT - .7) / .3) * (.55 + .2 * Math.sin(now * 4)) : 0); gl.viewport(0, 0, 1080, 680); gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); requestAnimationFrame(frame); } input.focus(); requestAnimationFrame(frame);
Connect it to your backend
Find the check(code) function in the script. Replace code !== PIN with a request to your API and call shake() when the code is wrong.
Good to know
- Needs WebGL2. Every current Chrome, Safari and Firefox has it.
- The real input is invisible and sits on top of the glass, so iPhone code autofill keeps working.
Tilda, Webflow, WordPress
Press Copy all code at the top and paste it into one HTML block.
Add block, Other, T123 HTML code. Paste and save. Check the published page, the editor preview does not run scripts.
Add panel, Embed. Paste, then Save & Close. Custom code runs on the published site.
Add block, Custom HTML. Paste and press Update.


