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.
0.25
2.00
0.50
3.50
/*{ "DESCRIPTION": "Raymarched twisted torus with iridescent thin-film colors, orbiting lights, and cosmic glow", "INPUTS": [ { "NAME": "speed", "TYPE": "float", "DEFAULT": 0.25, "MIN": 0.0, "MAX": 1.0 }, { "NAME": "twist", "TYPE": "float", "DEFAULT": 2.0, "MIN": 0.0, "MAX": 5.0 }, { "NAME": "glow_intensity", "TYPE": "float", "DEFAULT": 0.5, "MIN": 0.0, "MAX": 2.0 }, { "NAME": "camera_distance", "TYPE": "float", "DEFAULT": 3.5, "MIN": 2.0, "MAX": 6.0 } ] }*/ // Torus SDF float sdTorus(vec3 p, vec2 t) { vec2 q = vec2(length(p.xz) - t.x, p.y); return length(q) - t.y; } // 2D rotation mat2 rot2(float a) { float c = cos(a); float s = sin(a); return mat2(c, -s, s, c); } // Hash for stars float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); } // Scene SDF — untwist point, evaluate regular torus, exact distance preserved float map(vec3 p) { float t = TIME * speed; // Untwist the space to evaluate the regular torus SDF float angle = -p.y * twist - t; p.xz = rot2(angle) * p.xz; // Ribbed detail + breathing pulse float rib = sin(atan(p.z, p.x) * 16.0 + t * 2.0) * 0.02; float pulse = 1.0 + 0.05 * sin(t * 1.5); float d = sdTorus(p, vec2(1.2 * pulse, 0.3 + rib)); return d; } // Normal via 6-tap central differences vec3 getNormal(vec3 p) { vec2 e = vec2(0.001, 0.0); return normalize(vec3( map(p + e.xyy) - map(p - e.xyy), map(p + e.yxy) - map(p - e.yxy), map(p + e.yyx) - map(p - e.yyx) )); } // Thin-film iridescence — hue driven by view·normal phase vec3 iridescent(float cosTheta, float film) { float phase = film / (cosTheta + 0.01); vec3 a = vec3(0.5, 0.5, 0.5); vec3 b = vec3(0.5, 0.5, 0.5); vec3 c = vec3(1.0, 1.0, 1.0); vec3 d = vec3(0.00, 0.33, 0.67); return a + b * cos(6.28318 * (c * phase + d)); } // Ambient occlusion float calcAO(vec3 p, vec3 n) { float occ = 0.0; float sca = 1.0; for(int i = 0; i < 4; i++) { float h = 0.01 + 0.04 * float(i); float d = map(p + h * n); occ += (h - d) * sca; sca *= 0.95; } return clamp(1.0 - 3.0 * occ, 0.0, 1.0); } void main() { // Aspect-corrected UV centered at origin vec2 uv = (gl_FragCoord.xy - 0.5 * RENDERSIZE.xy) / RENDERSIZE.y; float t = TIME * speed; // Orbiting camera float camAngle = t * 0.4; vec3 ro = vec3( camera_distance * cos(camAngle), 1.0 + 0.5 * sin(t * 0.3), camera_distance * sin(camAngle) ); vec3 ta = vec3(0.0, 0.0, 0.0); vec3 ww = normalize(ta - ro); vec3 uu = normalize(cross(ww, vec3(0.0, 1.0, 0.0))); vec3 vv = normalize(cross(uu, ww)); vec3 rd = normalize(uv.x * uu + uv.y * vv + 1.8 * ww); // Raymarch with glow accumulation float dist = 0.0; float hit = -1.0; float glow = 0.0; for(int i = 0; i < 96; i++) { vec3 p = ro + rd * dist; float d = map(p); // Volumetric glow along the ray glow += exp(-d * 4.0) * 0.015; // Pixel-relative hit test if(d < 0.001 * dist) { hit = dist; break; } dist += d * 0.9; // slight under-step for safety if(dist > 40.0) break; } // Deep space background vec3 col = vec3(0.008, 0.01, 0.015); // Drifting starfield vec2 starUV = uv * 2.0 + vec2(t * 0.02, t * 0.01); vec2 starId = floor(starUV * 80.0); float starHash = hash(starId); float star = smoothstep(0.997, 1.0, starHash); float twinkle = sin(t * 2.0 + starHash * 100.0) * 0.5 + 0.5; vec3 starColor = vec3( 0.8 + 0.2 * sin(starHash * 10.0), 0.85 + 0.15 * sin(starHash * 20.0), 1.0 ); col += starColor * star * twinkle * 0.8; // Shade the surface if(hit > 0.0) { vec3 p = ro + rd * hit; vec3 n = getNormal(p); float ao = calcAO(p, n); // Three colored light sources vec3 l1 = normalize(vec3(1.0, 1.0, -0.5)); vec3 l2 = normalize(vec3(-0.8, 0.3, 1.0)); vec3 l3 = normalize(vec3(0.0, -1.0, 0.0)); float diff1 = max(dot(n, l1), 0.0); float diff2 = max(dot(n, l2), 0.0); float diff3 = max(dot(n, l3), 0.0); // Specular highlight vec3 viewDir = -rd; vec3 half1 = normalize(l1 + viewDir); float spec1 = pow(max(dot(n, half1), 0.0), 64.0); // Iridescent base color with position-varying film thickness float cosTheta = abs(dot(n, viewDir)); float posPhase = atan(p.z, p.x) * 0.5 + p.y * 0.3; vec3 baseColor = iridescent(cosTheta, 3.0 + sin(posPhase) * 0.5); // Light colors: warm white, purple, cyan vec3 c1 = vec3(1.0, 0.95, 0.9); vec3 c2 = vec3(0.7, 0.5, 1.0); vec3 c3 = vec3(0.2, 0.6, 1.0); col = baseColor * (0.15 + 0.85 * (diff1 * c1 + diff2 * c2 * 0.6 + diff3 * c3 * 0.3)); col += vec3(1.0, 0.95, 0.9) * spec1 * 0.6; // Fresnel rim light float fresnel = pow(1.0 - cosTheta, 3.0); col += vec3(0.5, 0.7, 1.0) * fresnel * 0.5; // Occlusion + depth fog col *= ao; col *= exp(-0.06 * hit); } // Add atmospheric glow col += vec3(0.4, 0.6, 1.0) * glow * glow_intensity; // Tone map + contrast col = col / (1.0 + col * 0.4); col = pow(col, vec3(0.95)); gl_FragColor = vec4(col, 1.0); }
Raymarched twisted torus with iridescent thin-film colors, orbiting lights, and cosmic glow
by ufffdwitnessed_generationmade with glslopCC0-1.0active·created 2026-07-17 21:02Z125 views0 forks4 paramskimi-k2.6
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).