experimental backend WebGL2 · not opted in
Enable WebGPU controls in settings. WebGL2 remains unchanged. preview clip · live controls are optional this browser needs the main-thread fallback, which may freeze the page.
1.00
30.00
1.00
1.00
1.00
0.00
1.00
1.00
1.00
0.00
0.00
0.40
/*{ "DESCRIPTION": "Hopf fibration: coiled fibers of S3 stereographically projected to R3, with orange, red and blue comet lights spiralling along them. Speeds are integrated in a persistent clock buffer, so knobs never make anything jump.", "CREDIT": "Hopf Fibration VJ", "CATEGORIES": ["Generator", "Geometry", "VJ"], "ISFVSN": "2", "INPUTS": [ { "NAME": "size", "TYPE": "float", "DEFAULT": 1.0, "MIN": 0.4, "MAX": 2.0 }, { "NAME": "amount", "TYPE": "float", "DEFAULT": 30.0, "MIN": 4.0, "MAX": 36.0 }, { "NAME": "warp", "TYPE": "float", "DEFAULT": 1.0, "MIN": 0.0, "MAX": 2.0 }, { "NAME": "warpSpeed", "TYPE": "float", "DEFAULT": 1.0, "MIN": 0.0, "MAX": 4.0 }, { "NAME": "cometSpeed", "TYPE": "float", "DEFAULT": 1.0, "MIN": 0.0, "MAX": 4.0 }, { "NAME": "hue", "TYPE": "float", "DEFAULT": 0.0, "MIN": -180.0, "MAX": 180.0 }, { "NAME": "glow", "TYPE": "float", "DEFAULT": 1.0, "MIN": 0.0, "MAX": 1.0 }, { "NAME": "zoom", "TYPE": "float", "DEFAULT": 1.0, "MIN": 0.4, "MAX": 2.5 }, { "NAME": "orbitSpeed", "TYPE": "float", "DEFAULT": 1.0, "MIN": 0.0, "MAX": 4.0 }, { "NAME": "cameraYaw", "TYPE": "float", "DEFAULT": 0.0, "MIN": -3.1416,"MAX": 3.1416 }, { "NAME": "cameraPitch", "TYPE": "float", "DEFAULT": 0.0, "MIN": -1.1, "MAX": 1.1 }, { "NAME": "quality", "TYPE": "float", "DEFAULT": 0.4, "MIN": 0.3, "MAX": 1.0 } ], "PASSES": [ { "TARGET": "clockBuf", "PERSISTENT": true, "FLOAT": true, "FILTER": "NEAREST" }, { "TARGET": "fiberBuf", "FLOAT": true, "FILTER": "NEAREST" }, { "TARGET": "sceneBuf", "FLOAT": true }, { } ] }*/ // Pass 0 clockBuf texels (0..2,0): comet, warp and orbit clocks, each stored as // (256 s blocks, quarter-seconds, remainder) so 16-bit floats stay precise for hours. // Pass 1 fiberBuf texels (0..35, 0..3): one column per fiber; column 48 = camera target + fiber count. // Pass 2 sceneBuf HDR raymarch of the coiled fibers into the bottom-left `quality` fraction of the buffer. // Pass 3 screen upscale, bloom, hue, tone map, vignette, grain. #define NF 36 #define COILS 26.0 #define TAU 6.2831853 float hsh(float i) { return fract(sin(i * 127.1 + 11.7) * 43758.5453); } float rnd(vec2 p) { return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453); } vec3 pal(float c) { // 0 orange, 1 red, 2 blue return c < 0.5 ? vec3(1.0, 0.40, 0.05) : (c < 1.5 ? vec3(1.0, 0.06, 0.09) : vec3(0.08, 0.36, 1.0)); } float ringN(float r) { return r < 0.5 ? 6.0 : (r < 1.5 ? 9.0 : (r < 2.5 ? 10.0 : 11.0)); } float ringA(float r) { return r < 0.5 ? 0.38 : (r < 1.5 ? 0.85 : (r < 2.5 ? 1.32 : 1.8)); } float ringC(float r) { return r < 1.5 ? 2.0 : (r < 2.5 ? 1.0 : 0.0); } float ringCount(float r) { return max(1.0, floor(ringN(r) * amount / 36.0 + 0.5)); } vec4 clockAdvance(vec4 s, float d) { float lo = s.z + d, q = floor(lo * 4.0); lo -= q * 0.25; float mid = s.y + q, hb = floor(mid / 1024.0); return vec4(s.x + hb, mid - hb * 1024.0, lo, 0.0); } float clockValue(vec4 s) { return s.x * 256.0 + s.y * 0.25 + s.z; } // Fiber idx as a circle in R3, through three points of its S3 great circle after projection. bool fiber(float idx, float WT, out vec4 C, out vec4 N, out vec4 U, out vec4 K) { float start = 0.0, ri = -1.0, j = 0.0, cnt = 1.0; for (int r = 0; r < 4; r++) { float fr = float(r), c = ringCount(fr); if (ri < 0.0 && idx < start + c) { ri = fr; j = idx - start; cnt = c; } start += c; } C = vec4(1e4, 0.0, 0.0, 1.0); N = vec4(0.0, 0.0, 1.0, 0.0); U = vec4(1.0, 0.0, 0.0, 0.0); K = vec4(0.0); if (ri < 0.0) return false; float r1 = warp * (0.55 * sin(WT * 0.11) + 0.15 * sin(WT * 0.037)) + 0.12 * warp; float r2 = WT * 0.09; float a = ringA(ri) + 0.06 * warp * sin(WT * 0.07) * (ri - 1.5); float b = j / cnt * TAU + ri * 0.5 + WT * 0.035 * (mod(ri, 2.0) > 0.5 ? 1.0 : -1.0); float ca = cos(a * 0.5), sa = sin(a * 0.5); vec3 P0 = vec3(0.0), P1 = vec3(0.0), P2 = vec3(0.0); for (int k = 0; k < 3; k++) { // one inlined copy instead of three float t = float(k) * 2.0944; float x1 = ca * cos(t), x2 = ca * sin(t), x3 = sa * cos(t + b), x4 = sa * sin(t + b); float y1 = x1 * cos(r1) - x4 * sin(r1), y4 = x1 * sin(r1) + x4 * cos(r1); // x1-x4 rotation: the warp float y2 = x2 * cos(r2) - x3 * sin(r2), y3 = x2 * sin(r2) + x3 * cos(r2); vec3 P = vec3(y1, y3, y2) / max(1.0 - y4, 1e-3); if (k == 0) P0 = P; else if (k == 1) P1 = P; else P2 = P; } vec3 p = P0 - P2, q = P1 - P2, n = cross(p, q); float nn = max(dot(n, n), 1e-9); vec3 cen = P2 + cross(q * dot(p, p) - p * dot(q, q), n) / (2.0 * nn); float rad = length(P0 - cen); float w = rad > 25.0 ? 0.0 : min(1.0, rad / 1.6) / (1.0 + 0.1 * rad); float rc = ringC(ri); C = vec4(cen * size, rad * size); N = vec4(normalize(n), w); U = vec4(normalize(P0 - cen), mod(rc + 1.0 + mod(j + ri, 2.0), 3.0) + hsh(idx)); K = vec4(pal(rc) * 0.55, (0.07 + 0.06 * hsh(idx + 40.0)) * (mod(idx, 3.0) > 0.5 ? 1.0 : -1.0)); return true; } vec3 aces(vec3 x) { return clamp((x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14), 0.0, 1.0); } vec3 hueRot(vec3 c, float a) { vec3 k = vec3(0.57735); float ca = cos(a); return c * ca + cross(k, c) * sin(a) + k * dot(k, c) * (1.0 - ca); } void main() { vec2 fc = gl_FragCoord.xy; // ---------- pass 0: clocks (3 texels) ---------- if (PASSINDEX == 0) { if (fc.y > 1.0 || fc.x > 3.0) { gl_FragColor = vec4(0.0); return; } float d = clamp(TIMEDELTA, 0.0, 0.1); float sp = fc.x < 1.0 ? cometSpeed : (fc.x < 2.0 ? warpSpeed : orbitSpeed); gl_FragColor = clockAdvance(IMG_PIXEL(clockBuf, fc), d * sp); return; } vec4 ck0 = IMG_PIXEL(clockBuf, vec2(0.5, 0.5)); vec4 ck1 = IMG_PIXEL(clockBuf, vec2(1.5, 0.5)); vec4 ck2 = IMG_PIXEL(clockBuf, vec2(2.5, 0.5)); float CT = clockValue(ck0), WT = clockValue(ck1), OT = clockValue(ck2); // ---------- pass 1: fiber table (49 x 4 texels) ---------- if (PASSINDEX == 1) { if (fc.y > 4.0 || fc.x > 49.0) { gl_FragColor = vec4(0.0); return; } float col = floor(fc.x), row = floor(fc.y); vec4 res = vec4(0.0), C, N, U, K; vec3 s = vec3(0.0); float ws = 0.0, total = 0.0; for (int i = 0; i < NF; i++) { float fi = float(i); bool ok = fiber(fi, WT, C, N, U, K); if (ok) total += 1.0; if (ok && N.w > 0.0 && C.w < 6.0 * size) { s += C.xyz * N.w; ws += N.w; } if (fi == col) res = row < 0.5 ? C : (row < 1.5 ? N : (row < 2.5 ? U : K)); if (col < 47.5 && fi >= col) break; // fiber columns stop early; column 48 sums all } gl_FragColor = col > 47.5 ? vec4(ws > 0.0 ? s / ws : vec3(0.0), total) : res; return; } // ---------- pass 2: raymarch at `quality` resolution ---------- if (PASSINDEX == 2) { vec2 rs = floor(RENDERSIZE * quality); if (fc.x > rs.x || fc.y > rs.y) { gl_FragColor = vec4(0.0); return; } vec4 tg = IMG_PIXEL(fiberBuf, vec2(48.5, 0.5)); vec3 tgt = tg.xyz; float cnt = tg.w; float yaw = OT * 0.06 + cameraYaw, pit = 0.32 + 0.22 * sin(OT * 0.045) + cameraPitch; vec3 ro = 7.2 * zoom * vec3(cos(pit) * sin(yaw), sin(pit), cos(pit) * cos(yaw)); vec3 f = normalize(-ro); float roll = 0.08 * sin(OT * 0.13); vec3 r = normalize(cross(f, vec3(sin(roll), cos(roll), 0.0))), u = cross(r, f); vec2 p = (fc * 2.0 - rs) / rs.y; vec3 rd = normalize(mat3(r, u, f) * vec3(p, 1.9)); // per-fiber ray interval: bounding sphere intersected with the slab around the circle's plane vec2 iv[NF]; float tS = 1e9, tE = -1e9; for (int i = 0; i < NF; i++) { float fx = float(i) + 0.5; vec4 Ci = IMG_PIXEL(fiberBuf, vec2(fx, 0.5)); vec4 Ni = IMG_PIXEL(fiberBuf, vec2(fx, 1.5)); vec3 oc = ro - (Ci.xyz - tgt); float Rb = Ci.w + 0.95, bb = dot(oc, rd), h = bb * bb - dot(oc, oc) + Rb * Rb; vec2 seg = vec2(1e9, -1e9); if (float(i) < cnt && Ni.w > 0.0 && h > 0.0) { h = sqrt(h); seg = vec2(-bb - h, -bb + h); float dn = dot(rd, Ni.xyz), on = dot(oc, Ni.xyz); if (abs(dn) > 1e-4) { float ta = (-0.95 - on) / dn, tb = (0.95 - on) / dn; seg = vec2(max(seg.x, min(ta, tb)), min(seg.y, max(ta, tb))); } else if (abs(on) > 0.95) seg = vec2(1e9, -1e9); seg.x = max(seg.x, 0.0); if (seg.x > seg.y) seg = vec2(1e9, -1e9); } iv[i] = seg; tS = min(tS, seg.x); tE = max(tE, seg.y); } float gk = mix(0.3, 1.0, glow), coil = 0.038 * size, minStep = mix(0.009, 0.013, glow); vec3 col = vec3(0.0); float t = tS + rnd(fc + fract(TIME) * 17.0) * 0.06; for (int s = 0; s < 140; s++) { if (t > tE) break; vec3 q0 = ro + rd * t, acc = vec3(0.0); float md = 1e9, nextE = 1e9; bool hit = false; for (int i = 0; i < NF; i++) { vec2 seg = iv[i]; if (t < seg.x) { nextE = min(nextE, seg.x); continue; } if (t > seg.y) continue; hit = true; float fx = float(i) + 0.5; vec4 Ci = IMG_PIXEL(fiberBuf, vec2(fx, 0.5)); vec4 Ni = IMG_PIXEL(fiberBuf, vec2(fx, 1.5)); vec3 q = q0 - (Ci.xyz - tgt), n = Ni.xyz; float hh = dot(q, n); vec3 rr = q - hh * n; float e = length(rr) - Ci.w; float tb2 = hh * hh + e * e, rc = clamp(0.04 * Ci.w, 0.25 * coil, 1.4 * coil); if (tb2 > 0.8) { float q1 = max(sqrt(tb2) - rc, 0.0); md = min(md, q1 * q1); continue; } vec4 Ui = IMG_PIXEL(fiberBuf, vec2(fx, 2.5)); vec4 Ki = IMG_PIXEL(fiberBuf, vec2(fx, 3.5)); vec3 ua = Ui.xyz, va = cross(n, ua); float ang = atan(dot(rr, va), dot(rr, ua)); float th = ang * (Ki.w > 0.0 ? COILS : -COILS) + CT * 0.9 + fract(Ui.w) * TAU; vec2 cd = vec2(e, hh) - rc * vec2(cos(th), sin(th)); float d2 = dot(cd, cd); md = min(md, d2); float w = Ni.w; acc += Ki.rgb * w * (0.00034 * gk / (d2 + 0.0004 * gk)); // coiled line float x = fract(ang * 0.31831 + CT * Ki.w + fract(Ui.w)); // two comets per fiber float com = x < 0.045 ? smoothstep(0.0, 0.045, x) : exp(-(x - 0.045) * 6.5); // soft front, long tail float hc = mod(floor(Ui.w) + fract(Ui.w) * 0.6 + TIME * 0.015, 3.0); vec3 cc = mix(pal(floor(hc)), pal(mod(floor(hc) + 1.0, 3.0)), smoothstep(0.0, 1.0, fract(hc))); acc += cc * w * com * (0.0028 * gk / (d2 + 0.0004 * gk)); acc += vec3(1.0, 0.92, 0.82) * w * com * com * com * (0.00035 / (d2 + 0.00015)); // hot core } if (!hit) { // empty space: jump to the next fiber's bound if (nextE > 1e8) break; t = nextE + 0.002; continue; } float dt = clamp(sqrt(md) * 0.45, minStep, 0.32); col += acc * dt; t += min(dt, max(nextE - t, minStep)); } gl_FragColor = vec4(min(col, vec3(60000.0)), 1.0); return; } // ---------- pass 3: composite ---------- vec2 uv = isf_FragNormCoord.xy, dc = uv - 0.5; vec2 rs = floor(RENDERSIZE * quality), sc = rs / RENDERSIZE, px = 1.0 / RENDERSIZE; vec2 lo = px * 0.5, hi = sc - px * 1.5; vec2 su = uv * sc; float ca = 0.006; vec3 c = vec3(IMG_NORM_PIXEL(sceneBuf, clamp(su - dc * ca * sc, lo, hi)).r, IMG_NORM_PIXEL(sceneBuf, clamp(su, lo, hi)).g, IMG_NORM_PIXEL(sceneBuf, clamp(su + dc * ca * sc, lo, hi)).b); vec2 asp = vec2(RENDERSIZE.y / RENDERSIZE.x, 1.0) * sc; float rot = rnd(fc) * TAU; vec3 bs = vec3(0.0), bl = vec3(0.0); float wsum = 0.0; for (int k = 0; k < 16; k++) { // two-radius spiral bloom, rotated per pixel float fk = float(k) + 0.5, rr = sqrt(fk / 16.0), th = fk * 2.39996 + rot; vec2 o = vec2(cos(th), sin(th)) * rr * asp; float wk = exp(-rr * rr * 2.5); bs += IMG_NORM_PIXEL(sceneBuf, clamp(su + o * 0.018, lo, hi)).rgb * wk; bl += IMG_NORM_PIXEL(sceneBuf, clamp(su + o * 0.07, lo, hi)).rgb * wk; wsum += wk; } vec3 bloom = (bs * 1.1 + bl * 1.4) / wsum; c = hueRot(max(c + bloom * 0.14 * glow * glow, 0.0), hue * 0.0174533); c = aces(c * 0.9); c *= 1.0 - smoothstep(0.35, 1.05, length(dc * vec2(1.15, 1.0))); c = max(c - 0.002, 0.0) * 1.002; // true black floor c = pow(c, vec3(1.0 / 2.2)); c *= 1.0 + (rnd(fc + TIME * 61.0) - 0.5) * 0.08; // grain on lit pixels only gl_FragColor = vec4(clamp(c, 0.0, 1.0), 1.0); }
Hopf fibration: coiled fibers of S3 stereographically projected to R3, with orange, red and blue comet lights spiralling along them. Speeds are integrated in a persistent clock buffer, so knobs never make anything jump.
by hawkknbredmade with glslopCC0-1.0credit: Hopf Fibration VJactive·created 2026-12-05 05:44Z18 views0 forks12 paramsmultipass ×4
lineage
forked from
export clip · render a video in your browser
Renders to video in your browser (no upload), stepping the real renderer frame by frame so multipass + feedback come out right. motion auto-animates the shader's own knobs — each export rolls a fresh take (🎲 re-roll, 🔒 to pin one you like). GIF is slower with a tighter length cap; MP4/WebM are faster. Some devices record in real time (noted below if so) — keep the tab visible.
caps: ≤1920 per side, ≤60fps, ≤18000 frames (GIF ≤300)
embed · drop this shader into any page
Renders client-side in the reader's browser (CC0 — no attribution required, but the backlink is appreciated).