{
  "license": "CC0-1.0",
  "shader": {
    "id": "fg7nznzh",
    "title": "Lumenworms",
    "license": "CC0-1.0",
    "provenance_type": "witnessed_generation",
    "made_with": "Claude",
    "status": "active",
    "compile_ok": true,
    "render_hash": "08101830300c0400",
    "tags": [
      "worms",
      "lumen",
      "light",
      "glow",
      "nudibranch",
      "alien",
      "underwaterm creature"
    ],
    "parents": [],
    "author": "u7y1evhf0znj",
    "author_name": "ksin",
    "author_url": "/u/ksin",
    "created_at": "2026-11-20T05:12:34.360Z",
    "poster_url": "/posters/fg7nznzh.avif",
    "stats": {
      "slops": 0,
      "views": 125,
      "forks": 0
    },
    "self": "/api/v1/shaders/fg7nznzh",
    "isf": "/*{\n  \"DESCRIPTION\": \"Lumenworms - undulating nudibranch-like sea creatures: ruffled mantles, hundreds of tiny cerata spines, rhinophores, caustic light on a dark curtain\",\n  \"CATEGORIES\": [\"Generator\", \"3D\", \"Raymarch\"],\n  \"INPUTS\": [\n    { \"NAME\": \"speed\",       \"TYPE\": \"float\", \"DEFAULT\": 1.0,  \"MIN\": 0.0,  \"MAX\": 3.0 },\n    { \"NAME\": \"swimSpeed\",   \"TYPE\": \"float\", \"DEFAULT\": 0.35, \"MIN\": 0.0,  \"MAX\": 1.5 },\n    { \"NAME\": \"undulation\",  \"TYPE\": \"float\", \"DEFAULT\": 1.0,  \"MIN\": 0.0,  \"MAX\": 2.5 },\n    { \"NAME\": \"spikeLength\", \"TYPE\": \"float\", \"DEFAULT\": 0.15, \"MIN\": 0.0,  \"MAX\": 0.3 },\n    { \"NAME\": \"causticAmt\",  \"TYPE\": \"float\", \"DEFAULT\": 1.0,  \"MIN\": 0.0,  \"MAX\": 3.0 },\n    { \"NAME\": \"glow\",        \"TYPE\": \"float\", \"DEFAULT\": 0.6,  \"MIN\": 0.0,  \"MAX\": 2.0 },\n    { \"NAME\": \"orbit\",       \"TYPE\": \"float\", \"DEFAULT\": 0.0,  \"MIN\": -3.14159, \"MAX\": 3.14159 }\n  ]\n}*/\n\n#ifdef GL_ES\nprecision highp float;\n#endif\n\n#define TAU 6.28318530718\n\nfloat T;\n// material info captured by map(): x = along body, y = side/r, z = cross-section angle, w = frill 0..1\nvec4  gInfo;\nfloat gId;\nfloat gPart;   // 0 body, 1 frill, 2 spikes/horns\n\nmat2 rot(float a) { float c = cos(a), s = sin(a); return mat2(c, s, -s, c); }\nfloat hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }\nfloat smin(float a, float b, float k) {\n    float h = clamp(0.5 + 0.5 * (b - a) / k, 0.0, 1.0);\n    return mix(b, a, h) - k * h * (1.0 - h);\n}\n\n// smooth looping swim path; each creature keeps its own depth lane so they never interpenetrate\nvec2 swimVel(float w, float fi, float dir, vec2 R) {\n    return vec2(-R.x * dir * sin(dir * w) + 0.17 * cos(1.7 * w + fi),\n                 R.y * dir * cos(dir * w) + 0.23 * cos(2.3 * w + fi * 3.0));\n}\nfloat wrapA(float a) { return atan(sin(a), cos(a)); }\n\nfloat map(vec3 p) {\n    float best = 1e5;\n    for (int i = 0; i < 3; i++) {\n        float fi = float(i);\n        float s1 = step(0.5, fi), s2 = step(1.5, fi);\n        // swim along a smooth loop; body bends to follow the path's curvature (worm-like)\n        float w   = T * swimSpeed * (0.8 + 0.2 * fi) + fi * 2.1;\n        float dir = 1.0 - 2.0 * s1 + 2.0 * s2;\n        vec2 pc   = mix(mix(vec2(-0.2, 0.35), vec2(0.22, -0.15), s1), vec2(-0.12, -0.6), s2);\n        vec2 pR   = mix(mix(vec2(0.42, 0.5), vec2(0.45, 0.5), s1), vec2(0.38, 0.3), s2);\n        vec3 c    = vec3(pc + pR * vec2(cos(dir * w), sin(dir * w)) + 0.1 * vec2(sin(1.7 * w + fi), sin(2.3 * w + fi * 3.0)),\n                         (fi - 1.0) * 0.75 + 0.06 * sin(0.9 * w + fi));\n        vec2 vH   = swimVel(w, fi, dir, pR);\n        vec2 vT   = swimVel(w - 1.45, fi, dir, pR);\n        float angH = atan(vH.y, vH.x);\n        float angT = atan(vT.y, vT.x);\n        float bendK = clamp(wrapA(angH - angT) / 2.5, -0.6, 0.6);\n        float heading = angH - bendK;\n        float sc = mix(mix(0.52, 0.47, s1), 0.4, s2);\n        vec3 q = (p - c) / sc;\n\n        // cheap bounding sphere\n        float bd = (length(q) - 1.95) * sc;\n        if (bd > 0.15) { best = min(best, bd); continue; }\n\n        q.xy = rot(-heading) * q.xy;\n        q.xy = rot(-bendK * q.x) * q.xy;\n        // serpentine swim: lateral travelling wave in the swim plane, small at the head, big at the tail;\n        // the wave runs backwards at roughly the swim speed so the body 'pushes' through the water\n        float envS = 0.25 + 0.75 * clamp((1.0 - q.x) / 2.5, 0.0, 1.0);\n        float swPh = 3.6 * q.x - T * (2.0 + 7.0 * swimSpeed) + fi * 2.0;\n        q.y -= undulation * envS * 0.24 * sin(swPh);\n        q.xz = rot(0.2 - fi * 0.15) * q.xz;\n        q.yz = rot(-0.75 + 0.15 * sin(T * 0.4 + fi * 2.0)) * q.yz;\n\n        float x    = q.x;\n        float xc   = clamp(x, -1.0, 1.0);\n        float xn   = x < 0.0 ? x / 1.5 : x / 0.95;\n        float prof = sqrt(max(0.0, 1.0 - xn * xn));\n        prof *= x < 0.0 ? mix(0.35, 1.0, sqrt(max(0.0, 1.0 + xn))) : 1.0;\n\n        // travelling body wave, bigger toward the tail\n        float ph  = x * 3.2 - T * 2.2 + fi * 2.1;\n        float env = 0.3 + 0.7 * clamp((1.0 - x) / 2.5, 0.0, 1.0);\n        vec2 cs = q.yz - undulation * env * vec2(0.05 * sin(ph), 0.04 * sin(ph * 0.8 + 1.3));\n\n        float r = (0.2 * prof + 0.008) * (1.0 + 0.22 * sin(x * 13.0 - T * 3.0 + fi));\n        float R = length(cs);\n        float body = max(length(vec2(cs.x * 1.35, cs.y)) - r, max(x - 0.95, -x - 1.5));\n        // head: smooth ellipsoid + flared, ruffled oral veil\n        vec3 hp = vec3(x - 0.9, cs.x - 0.01, cs.y);\n        vec3 hr = vec3(0.2, 0.13, 0.17);\n        float k0 = length(hp / hr), k1 = length(hp / (hr * hr));\n        float head = k0 * (k0 - 1.0) / k1;\n        body = smin(body, head, 0.08);\n        vec2 vp = vec2(x - 0.98, cs.y);\n        float vr = length(vp);\n        float vang = atan(vp.y, vp.x);\n        float vy = cs.x + 0.05 - 0.035 * sin(vang * 9.0 - T * 3.0 + fi) * smoothstep(0.08, 0.26, vr) + 0.08 * vr * vr;\n        float veil = max(max(abs(vy) - 0.006, vr - 0.27 - 0.02 * sin(vang * 5.0 + T)), 0.9 - x);\n        body = smin(body, veil, 0.04);\n\n        // ruffled mantle frill\n        float az  = abs(cs.y);\n        float fw  = (0.16 + 0.06 * sin(x * 4.0 + fi * 5.0)) * prof + 0.01;\n        float t01 = clamp((az - r * 0.5) / (fw + r * 0.5), 0.0, 1.0);\n        float ruf = (0.055 * sin(x * 17.0 - T * 3.5 + fi * 3.0) + 0.02 * sin(x * 61.0 + T * 2.0 + az * 20.0)) * t01\n                  + 0.07 * t01 * t01 - 0.03;\n        float frill = max(max(abs(cs.x - ruf) - 0.006, az - r - fw), max(x - 0.85, -x - 1.5));\n        float ruf2 = 0.06 * sin(x * 11.0 + T * 2.7 + fi) * t01 - 0.09 * t01 * t01 - 0.06;\n        float frill2 = max(max(abs(cs.x - ruf2) - 0.005, az - r - fw * 1.35), max(x - 0.8, -x - 1.45));\n        frill = min(frill, frill2);\n\n        // cerata: angular x longitudinal repetition of tiny swaying spines\n        float a   = atan(cs.x, cs.y);\n        float sw  = 0.26;\n        float ai  = floor(a / sw);\n        float al  = a - (ai + 0.5) * sw;\n        float cell = 0.06;\n        float xi  = floor(x / cell);\n        float h1  = hash(vec2(xi, ai + fi * 17.0));\n        float xl  = x - (xi + 0.5) * cell + (h1 - 0.5) * 0.008;\n        float dors = smoothstep(0.15, 0.9, sin((ai + 0.5) * sw));\n        float h   = spikeLength * mix(0.35, 1.0, s1) * (0.5 + 0.7 * h1) * dors * prof + 0.002;\n        float u   = R - r * 0.85;\n        float uc  = clamp(u, 0.0, h);\n        float bend = uc / h;\n        xl += 0.008 * bend * bend * sin(T * 3.0 + xi * 0.7 + ai * 1.3);\n        float sp = length(vec3(xl, R * sin(al), u - uc)) - 0.017 * (1.0 - 0.85 * bend) * (0.4 + 0.6 * dors);\n        sp = max(sp, max(x - 0.75, -x - 1.4));\n        float bulb = length(vec3(xl, R * sin(al), u - h)) - 0.022 * dors * (0.6 + 0.4 * sin(T * 4.0 + xi * 1.3 + ai));\n        bulb = max(bulb, max(x - 0.75, -x - 1.4));\n        // glowing eye spots on the head\n        float eye = length(vec3(x - 1.04, cs.x - 0.04, abs(cs.y) - 0.085)) - 0.028;\n        bulb = min(bulb, eye);\n\n        // rhinophores (head horns)\n        vec3 hq = vec3(x - 0.88, cs.x - 0.08, abs(cs.y) - 0.055);\n        vec3 hb = vec3(0.1 + 0.04 * sin(T * 1.7 + fi), 0.22, 0.05);\n        float hh = clamp(dot(hq, hb) / dot(hb, hb), 0.0, 1.0);\n        float horn = length(hq - hb * hh) - 0.022 * (1.0 - 0.6 * hh) * (1.0 + 0.3 * sin(hh * 45.0));\n\n        // five solid oral tendrils sprouting from the veil rim\n        float tend = 1e5;\n        float hx  = clamp(x - 1.05, 0.0, 0.7);\n        for (int k = 0; k < 5; k++) {\n            float fk = float(k);\n            float tang = fk * TAU / 5.0 + fi + 0.3 * sin(hx * 5.0 - T * 2.5 + fk * 2.0);\n            float tr = 0.11 + hx * 0.28;\n            vec2 tc = vec2(-0.05, 0.0) + tr * vec2(cos(tang), sin(tang))\n                    + 0.05 * hx * vec2(sin(hx * 7.0 - T * 3.0 + fk), cos(hx * 6.0 - T * 2.6 + fk));\n            tend = min(tend, length(vec2(length(cs - tc), x - 1.05 - hx)) - 0.015 * (1.0 - hx * 1.1));\n        }\n        float spikes = min(min(sp, horn), tend);\n        float d = smin(body, frill, 0.04);\n        d = smin(d, spikes, 0.02);\n        d = smin(d, bulb, 0.01);\n        d *= sc * 0.6;\n\n        if (d < best) {\n            best  = d;\n            gId   = fi;\n            gPart = (bulb < min(spikes, min(body, frill))) ? 3.0 : (spikes < min(body, frill)) ? 2.0 : ((frill < body) ? 1.0 : 0.0);\n            gInfo = vec4(x, cs.y / r, a, t01);\n        }\n    }\n    return best;\n}\n\n\n// warped ridge network -> caustic web\nfloat caustic(vec2 p, float t) {\n    vec2 q = p;\n    for (int k = 0; k < 4; k++) {\n        float fk = float(k) + 1.0;\n        q += vec2(sin(q.y * 0.9 * fk + t * 0.9 + fk), cos(q.x * 0.8 * fk - t * 0.7 + fk * 1.7)) * 0.45 / fk;\n    }\n    float l = 1.0 - abs(sin(q.x * 2.5) + sin(q.y * 2.5)) * 0.5;\n    return pow(clamp(l, 0.0, 1.0), 4.0);\n}\n\nvec3 background(vec2 uv) {\n    float x = uv.x;\n    float fold = 0.5 + 0.5 * sin(x * 38.0 + 2.5 * sin(x * 5.3) + 0.3 * sin(uv.y * 2.0 + T * 0.2));\n    vec3 c = vec3(0.002, 0.002, 0.004);\n    c += vec3(0.008, 0.009, 0.013) * pow(fold, 3.0) * (0.55 + 0.45 * uv.y);\n    c += vec3(0.006, 0.010, 0.030) * exp(-length(uv - vec2(0.15, 0.35)) * 1.6);\n    c += vec3(0.020, 0.003, 0.020) * exp(-length(uv - vec2(-0.45, -0.55)) * 2.0);\n    c += vec3(0.000, 0.012, 0.014) * exp(-length(uv - vec2(0.5, -0.2)) * 2.2);\n    // faint god rays from above\n    float ray = pow(0.5 + 0.5 * sin(x * 9.0 + uv.y * 1.5 + sin(T * 0.3 + x * 3.0)), 6.0);\n    c += vec3(0.003, 0.009, 0.014) * ray * smoothstep(-0.6, 0.6, uv.y);\n    // marine snow\n    vec2 g = uv * 22.0 + vec2(0.0, T * 0.25);\n    vec2 gi = floor(g);\n    float hs = hash(gi);\n    vec2 gp = fract(g) - 0.5 - 0.35 * vec2(hash(gi + 3.1) - 0.5, hash(gi + 7.7) - 0.5);\n    c += (0.5 + 0.5 * cos(hs * TAU + vec3(0.0, 2.1, 4.2))) * step(0.88, hs) * smoothstep(0.06, 0.0, length(gp)) * (0.15 + 0.15 * sin(T * 2.0 + hs * 40.0));\n    return c;\n}\n\nvoid main() {\n    T = TIME * speed;\n    vec2 uv = (gl_FragCoord.xy - 0.5 * RENDERSIZE.xy) / RENDERSIZE.y;\n\n    vec3 ro = vec3(0.0, 0.0, -5.2);\n    ro.xz = rot(orbit + 0.12 * sin(T * 0.1)) * ro.xz;\n    vec3 ta = vec3(0.0, 0.05, 0.0);\n    vec3 ww = normalize(ta - ro);\n    vec3 uu = normalize(cross(vec3(0.0, 1.0, 0.0), ww));\n    vec3 vv = cross(ww, uu);\n    vec3 rd = normalize(uv.x * uu + uv.y * vv + 1.7 * ww);\n\n    vec3 bg = background(uv) * 0.55;\n    vec3 col = bg;\n\n    // one loop does the march AND the 4 normal taps, so map() is only inlined once (halves compile time)\n    float t = 0.0;\n    bool hit = false;\n    float id = 0.0, part = 0.0;\n    vec4 info = vec4(0.0);\n    vec3 nacc = vec3(0.0);\n    float halo = 0.0, haloId = 0.0, minD = 1e5;\n    int nk = 0;\n    for (int i = 0; i < 128; i++) {\n        vec3 e = vec3(0.0);\n        if (hit) e = (nk == 0) ? vec3(1, -1, -1) : (nk == 1) ? vec3(-1, -1, 1) : (nk == 2) ? vec3(-1, 1, -1) : vec3(1, 1, 1);\n        float d = map(ro + rd * t + e * 0.0008);\n        if (!hit) {\n            // soft glow: accumulate how closely the ray grazes a creature\n            if (d < minD) { minD = d; haloId = gId; }\n            halo += 0.01 * exp(-d * 22.0);\n            if (d < 0.0006 * t) { hit = true; id = gId; part = gPart; info = gInfo; }\n            else { t += d; if (t > 9.0) break; }\n        } else {\n            nacc += e * d;\n            nk++;\n            if (nk == 4) break;\n        }\n    }\n\n    if (hit) {\n        vec3 pos = ro + rd * t;\n        vec3 n = normalize(nacc + vec3(0.0, 1e-6, 0.0));\n\n        // cheap occlusion: darker toward the body core and underside\n        float ao = mix(0.55, 1.0, clamp(0.5 + 0.5 * n.y, 0.0, 1.0)) * (part > 0.5 ? 1.0 : 0.85);\n\n        // palettes: green slug / pink-violet / white-lavender\n        vec3 base, accent, tip;\n        if (id < 0.5)      { base = vec3(0.00, 1.00, 0.30); accent = vec3(0.01, 0.03, 0.06); tip = vec3(1.00, 0.95, 0.10); }\n        else if (id < 1.5) { base = vec3(1.00, 0.12, 0.55); accent = vec3(0.45, 0.05, 1.00); tip = vec3(0.10, 0.90, 1.00); }\n        else               { base = vec3(0.80, 0.85, 1.00); accent = vec3(0.10, 0.35, 1.00); tip = vec3(1.00, 0.55, 0.10); }\n\n        float top  = step(0.0, sin(info.z));\n        float spot = smoothstep(0.55, 0.75, hash(floor(vec2(info.x * 22.0, info.y * 3.0 + info.z * 4.0))))\n                   * smoothstep(0.5, 0.2, length(fract(vec2(info.x * 22.0, info.y * 3.0 + info.z * 4.0)) - 0.5));\n        vec3 alb = base;\n        if (id < 0.5) {\n            alb = mix(alb, accent, smoothstep(0.14, 0.06, abs(info.y)) * top);            // dorsal black line\n            alb = mix(alb, accent, smoothstep(0.05, 0.015, abs(info.w - 0.45)) * 0.9);     // mantle line\n        } else {\n            alb = mix(alb, accent, spot * 0.85);\n        }\n        if (part > 0.5 && part < 1.5) alb = mix(alb, tip, smoothstep(0.75, 1.0, info.w)); // frill rim\n        if (part > 1.5) alb = mix(id < 0.5 ? base : accent, tip, 0.75);\n        // thin-film rainbow wash along the body\n        vec3 film = 0.5 + 0.5 * cos(TAU * (info.x * 0.6 + info.w * 0.5 + T * 0.05 + vec3(0.0, 0.33, 0.67)));\n        alb = mix(alb, alb * film * 1.6, 0.35);\n\n        vec3 L = normalize(vec3(0.35, 1.0, -0.35));\n        float dif = clamp(dot(n, L), 0.0, 1.0);\n        float c1 = caustic(pos.xz * 1.5 + pos.y * 0.4, T * 0.8);\n        float c2 = caustic(pos.xz * 3.1 - pos.y * 0.7 + 3.0, T * 1.1);\n        float cau = c1 + 0.6 * c2;\n        vec3 cauCol = vec3(0.35, 1.0, 0.95) * c1 + vec3(1.0, 0.45, 1.0) * c2 * 0.8;\n\n        col  = alb * (0.06 + (0.25 + 0.75 * dif) * (vec3(0.22) + causticAmt * cauCol * 2.2)) * ao;\n\n        // light through thin tissue (frills/spines)\n        float thin  = part > 0.5 ? 1.0 : 0.35;\n        float trans = clamp(dot(-n, L) * 0.5 + 0.5, 0.0, 1.0);\n        col += alb * tip * trans * thin * 0.25 * (0.5 + causticAmt * cau) * ao;\n\n        // iridescent fresnel rim\n        float fre = pow(1.0 - clamp(dot(n, -rd), 0.0, 1.0), 3.0);\n        vec3 irid = 0.5 + 0.5 * cos(TAU * (fre * 1.3 + vec3(0.0, 0.33, 0.67)) + id * 1.7 + 2.0);\n        col += irid * irid * fre * 1.1 * ao;\n\n        float spec = pow(clamp(dot(reflect(rd, n), L), 0.0, 1.0), 48.0);\n        col += (vec3(0.6) + cauCol) * spec * 0.8 * ao;\n\n        // alien emissive: travelling chromatophore bands + glowing vein web + pulsing bulbs\n        float wave  = pow(0.5 + 0.5 * sin(info.x * 9.0 - T * 4.0 + id * 2.0 + info.z * 1.5), 6.0);\n        vec2 vq = vec2(info.x * 8.0, info.y * 1.5 + info.z * 2.0);\n        vq += 0.4 * sin(vq.yx * 2.3 + T * 0.5);\n        float vein = smoothstep(0.12, 0.0, abs(sin(vq.x) * sin(vq.y)));\n        vec3 emi = 0.5 + 0.5 * cos(TAU * (info.x * 0.3 - T * 0.15 + id * 0.33 + vec3(0.0, 0.33, 0.67)));\n        col += emi * (wave * 0.5 + vein * 0.35) * glow * (part < 0.5 ? 1.0 : 0.5);\n        if (part > 2.5) col += tip * glow * (1.5 + 1.5 * sin(T * 4.0 + info.x * 20.0)) + emi * 0.6;\n        // bioluminescence (strongest on the green one)\n        float bio = (id < 0.5 ? 1.0 : 0.35) * glow;\n        col += alb * bio * (0.15 + 0.5 * cau) * (part > 0.5 ? 1.2 : 0.8);\n\n        col = mix(col, bg, 1.0 - exp(-0.006 * t * t));\n    }\n\n    vec3 haloCol = haloId < 0.5 ? vec3(0.1, 1.0, 0.45) : haloId < 1.5 ? vec3(1.0, 0.2, 0.75) : vec3(0.55, 0.6, 1.0);\n    col += haloCol * halo * glow * 0.55;\n\n    float lum = dot(col, vec3(0.299, 0.587, 0.114));\n    col = max(mix(vec3(lum), col, 1.35), 0.0);\n    col = col / (1.0 + col * 0.5);\n    col = pow(col, vec3(0.4545));\n    col *= 1.0 - 0.35 * dot(uv * 0.9, uv * 0.9);\n    gl_FragColor = vec4(col, 1.0);\n}\n",
    "generator": {
      "model": "Claude-Opus-5.5",
      "provider": null,
      "prompt": null,
      "params": null
    }
  }
}