{
  "license": "CC0-1.0",
  "shader": {
    "id": "qyaow34s",
    "title": "Aurora Torus",
    "license": "CC0-1.0",
    "provenance_type": "witnessed_generation",
    "made_with": "glslop",
    "status": "active",
    "compile_ok": true,
    "render_hash": "3fffffffc9ff0000",
    "tags": [
      "raymarch",
      "torus",
      "iridescent",
      "3d",
      "glow",
      "space",
      "procedural",
      "animation"
    ],
    "parents": [],
    "author": "zazi5inxhmgi",
    "author_name": "ufffd",
    "author_url": "/u/ufffd",
    "created_at": "2026-07-17T21:02:08.663Z",
    "poster_url": "/posters/qyaow34s.avif",
    "stats": {
      "slops": 0,
      "views": 126,
      "forks": 0
    },
    "self": "/api/v1/shaders/qyaow34s",
    "isf": "/*{\n    \"DESCRIPTION\": \"Raymarched twisted torus with iridescent thin-film colors, orbiting lights, and cosmic glow\",\n    \"INPUTS\": [\n        { \"NAME\": \"speed\", \"TYPE\": \"float\", \"DEFAULT\": 0.25, \"MIN\": 0.0, \"MAX\": 1.0 },\n        { \"NAME\": \"twist\", \"TYPE\": \"float\", \"DEFAULT\": 2.0, \"MIN\": 0.0, \"MAX\": 5.0 },\n        { \"NAME\": \"glow_intensity\", \"TYPE\": \"float\", \"DEFAULT\": 0.5, \"MIN\": 0.0, \"MAX\": 2.0 },\n        { \"NAME\": \"camera_distance\", \"TYPE\": \"float\", \"DEFAULT\": 3.5, \"MIN\": 2.0, \"MAX\": 6.0 }\n    ]\n}*/\n\n// Torus SDF\nfloat sdTorus(vec3 p, vec2 t) {\n    vec2 q = vec2(length(p.xz) - t.x, p.y);\n    return length(q) - t.y;\n}\n\n// 2D rotation\nmat2 rot2(float a) {\n    float c = cos(a);\n    float s = sin(a);\n    return mat2(c, -s, s, c);\n}\n\n// Hash for stars\nfloat hash(vec2 p) {\n    return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);\n}\n\n// Scene SDF — untwist point, evaluate regular torus, exact distance preserved\nfloat map(vec3 p) {\n    float t = TIME * speed;\n    \n    // Untwist the space to evaluate the regular torus SDF\n    float angle = -p.y * twist - t;\n    p.xz = rot2(angle) * p.xz;\n    \n    // Ribbed detail + breathing pulse\n    float rib = sin(atan(p.z, p.x) * 16.0 + t * 2.0) * 0.02;\n    float pulse = 1.0 + 0.05 * sin(t * 1.5);\n    float d = sdTorus(p, vec2(1.2 * pulse, 0.3 + rib));\n    \n    return d;\n}\n\n// Normal via 6-tap central differences\nvec3 getNormal(vec3 p) {\n    vec2 e = vec2(0.001, 0.0);\n    return normalize(vec3(\n        map(p + e.xyy) - map(p - e.xyy),\n        map(p + e.yxy) - map(p - e.yxy),\n        map(p + e.yyx) - map(p - e.yyx)\n    ));\n}\n\n// Thin-film iridescence — hue driven by view·normal phase\nvec3 iridescent(float cosTheta, float film) {\n    float phase = film / (cosTheta + 0.01);\n    vec3 a = vec3(0.5, 0.5, 0.5);\n    vec3 b = vec3(0.5, 0.5, 0.5);\n    vec3 c = vec3(1.0, 1.0, 1.0);\n    vec3 d = vec3(0.00, 0.33, 0.67);\n    return a + b * cos(6.28318 * (c * phase + d));\n}\n\n// Ambient occlusion\nfloat calcAO(vec3 p, vec3 n) {\n    float occ = 0.0;\n    float sca = 1.0;\n    for(int i = 0; i < 4; i++) {\n        float h = 0.01 + 0.04 * float(i);\n        float d = map(p + h * n);\n        occ += (h - d) * sca;\n        sca *= 0.95;\n    }\n    return clamp(1.0 - 3.0 * occ, 0.0, 1.0);\n}\n\nvoid main() {\n    // Aspect-corrected UV centered at origin\n    vec2 uv = (gl_FragCoord.xy - 0.5 * RENDERSIZE.xy) / RENDERSIZE.y;\n    \n    float t = TIME * speed;\n    \n    // Orbiting camera\n    float camAngle = t * 0.4;\n    vec3 ro = vec3(\n        camera_distance * cos(camAngle),\n        1.0 + 0.5 * sin(t * 0.3),\n        camera_distance * sin(camAngle)\n    );\n    vec3 ta = vec3(0.0, 0.0, 0.0);\n    vec3 ww = normalize(ta - ro);\n    vec3 uu = normalize(cross(ww, vec3(0.0, 1.0, 0.0)));\n    vec3 vv = normalize(cross(uu, ww));\n    vec3 rd = normalize(uv.x * uu + uv.y * vv + 1.8 * ww);\n    \n    // Raymarch with glow accumulation\n    float dist = 0.0;\n    float hit = -1.0;\n    float glow = 0.0;\n    \n    for(int i = 0; i < 96; i++) {\n        vec3 p = ro + rd * dist;\n        float d = map(p);\n        \n        // Volumetric glow along the ray\n        glow += exp(-d * 4.0) * 0.015;\n        \n        // Pixel-relative hit test\n        if(d < 0.001 * dist) {\n            hit = dist;\n            break;\n        }\n        \n        dist += d * 0.9; // slight under-step for safety\n        if(dist > 40.0) break;\n    }\n    \n    // Deep space background\n    vec3 col = vec3(0.008, 0.01, 0.015);\n    \n    // Drifting starfield\n    vec2 starUV = uv * 2.0 + vec2(t * 0.02, t * 0.01);\n    vec2 starId = floor(starUV * 80.0);\n    float starHash = hash(starId);\n    float star = smoothstep(0.997, 1.0, starHash);\n    float twinkle = sin(t * 2.0 + starHash * 100.0) * 0.5 + 0.5;\n    vec3 starColor = vec3(\n        0.8 + 0.2 * sin(starHash * 10.0),\n        0.85 + 0.15 * sin(starHash * 20.0),\n        1.0\n    );\n    col += starColor * star * twinkle * 0.8;\n    \n    // Shade the surface\n    if(hit > 0.0) {\n        vec3 p = ro + rd * hit;\n        vec3 n = getNormal(p);\n        \n        float ao = calcAO(p, n);\n        \n        // Three colored light sources\n        vec3 l1 = normalize(vec3(1.0, 1.0, -0.5));\n        vec3 l2 = normalize(vec3(-0.8, 0.3, 1.0));\n        vec3 l3 = normalize(vec3(0.0, -1.0, 0.0));\n        \n        float diff1 = max(dot(n, l1), 0.0);\n        float diff2 = max(dot(n, l2), 0.0);\n        float diff3 = max(dot(n, l3), 0.0);\n        \n        // Specular highlight\n        vec3 viewDir = -rd;\n        vec3 half1 = normalize(l1 + viewDir);\n        float spec1 = pow(max(dot(n, half1), 0.0), 64.0);\n        \n        // Iridescent base color with position-varying film thickness\n        float cosTheta = abs(dot(n, viewDir));\n        float posPhase = atan(p.z, p.x) * 0.5 + p.y * 0.3;\n        vec3 baseColor = iridescent(cosTheta, 3.0 + sin(posPhase) * 0.5);\n        \n        // Light colors: warm white, purple, cyan\n        vec3 c1 = vec3(1.0, 0.95, 0.9);\n        vec3 c2 = vec3(0.7, 0.5, 1.0);\n        vec3 c3 = vec3(0.2, 0.6, 1.0);\n        \n        col = baseColor * (0.15 + 0.85 * (diff1 * c1 + diff2 * c2 * 0.6 + diff3 * c3 * 0.3));\n        col += vec3(1.0, 0.95, 0.9) * spec1 * 0.6;\n        \n        // Fresnel rim light\n        float fresnel = pow(1.0 - cosTheta, 3.0);\n        col += vec3(0.5, 0.7, 1.0) * fresnel * 0.5;\n        \n        // Occlusion + depth fog\n        col *= ao;\n        col *= exp(-0.06 * hit);\n    }\n    \n    // Add atmospheric glow\n    col += vec3(0.4, 0.6, 1.0) * glow * glow_intensity;\n    \n    // Tone map + contrast\n    col = col / (1.0 + col * 0.4);\n    col = pow(col, vec3(0.95));\n    \n    gl_FragColor = vec4(col, 1.0);\n}",
    "generator": {
      "model": "kimi-k2.6",
      "provider": null,
      "prompt": null,
      "params": null
    }
  }
}