{
  "license": "CC0-1.0",
  "shader": {
    "id": "h0795jlv",
    "title": "CHRONOFOLD — Second Movement",
    "license": "CC0-1.0",
    "provenance_type": "witnessed_generation",
    "made_with": "OpenAI Codex; human art direction; glslop renderer",
    "status": "active",
    "compile_ok": true,
    "render_hash": "00000030fcfffdff",
    "tags": [
      "abstract",
      "3d",
      "raymarching",
      "kinetic",
      "clockwork",
      "animation",
      "loop",
      "multipass"
    ],
    "parents": [],
    "author": "zazi5inxhmgi",
    "author_name": "ufffd",
    "author_url": "/u/ufffd",
    "created_at": "2026-09-05T03:04:28.494Z",
    "poster_url": "/posters/h0795jlv.avif",
    "stats": {
      "slops": 1,
      "views": 143,
      "forks": 0
    },
    "self": "/api/v1/shaders/h0795jlv",
    "isf": "/*{\n  \"DESCRIPTION\": \"CHRONOFOLD — Second Movement. A liquid escapement refined with nested clearances, relieved guide rails and bearing seams. Eight carriages drive thirty-two breathing pistons and sixty-four counter-orbiting pearls; twelve hinged iris vanes unfold in two counter-rotating crowns. A continuous 96-second camera orbit reveals both faces. The mechanism repeats every 32 seconds; the full scene repeats every 96 seconds at default controls. Fully procedural, no external assets.\",\n  \"CREDIT\": \"OpenAI / Codex\",\n  \"ISFVSN\": \"2\",\n  \"CATEGORIES\": [\"3D\", \"Abstract\", \"Raymarching\"],\n  \"PASSES\": [{\"TARGET\": \"clockImage\", \"FLOAT\": true}, {\"TARGET\": \"haloHorizontal\", \"FLOAT\": true}, {\"TARGET\": \"haloVertical\", \"FLOAT\": true}, {}],\n  \"INPUTS\": [\n    {\"NAME\": \"tempo\", \"LABEL\": \"Tempo\", \"TYPE\": \"float\", \"DEFAULT\": 1.0, \"MIN\": 0.2, \"MAX\": 2.0},\n    {\"NAME\": \"liquidity\", \"LABEL\": \"Liquid joints\", \"TYPE\": \"float\", \"DEFAULT\": 0.75, \"MIN\": 0.0, \"MAX\": 1.0},\n    {\"NAME\": \"orbitSpeed\", \"LABEL\": \"Camera orbit speed\", \"TYPE\": \"float\", \"DEFAULT\": 1.0, \"MIN\": 0.0, \"MAX\": 2.0},\n    {\"NAME\": \"bloomAmount\", \"LABEL\": \"Halation\", \"TYPE\": \"float\", \"DEFAULT\": 0.65, \"MIN\": 0.0, \"MAX\": 1.5},\n    {\"NAME\": \"exposure\", \"LABEL\": \"Exposure\", \"TYPE\": \"float\", \"DEFAULT\": 1.0, \"MIN\": 0.6, \"MAX\": 1.5}\n  ]\n}*/\n\nconst float PI=3.14159265359;\nconst float TAU=6.28318530718;\nconst float SCULPTURE_BOUND=4.50;\nfloat phase;\nmat3 worldToClock;\nmat3 innerTurn;\nvec3 carriage[8];\nvec2 outward[8];\nvec2 rotor[8];\nvec2 microRotor[8];\nfloat extension[8];\nvec3 innerPearl[4];\nfloat traceExhausted=0.0;\nfloat traceSteps=0.0;\nvec4 primaryMaterial=vec4(0,-2,0,0);\n\nmat2 rotation(float a){float c=cos(a),s=sin(a);return mat2(c,s,-s,c);}\nmat3 rx(float a){float c=cos(a),s=sin(a);return mat3(1,0,0,0,c,s,0,-s,c);}\nmat3 ry(float a){float c=cos(a),s=sin(a);return mat3(c,0,-s,0,1,0,s,0,c);}\nmat3 rz(float a){float c=cos(a),s=sin(a);return mat3(c,s,0,-s,c,0,0,0,1);}\nvec2 turn(vec2 p,vec2 cs){return vec2(cs.x*p.x-cs.y*p.y,cs.y*p.x+cs.x*p.y);}\nfloat sat(float x){return clamp(x,0.0,1.0);}\nfloat sq(float x){return x*x;}\nfloat hash(vec2 p){return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453);}\nfloat roundedSquare(vec2 p,float side,float corner){vec2 q=abs(p)-side;return length(max(q,0.0))+min(max(q.x,q.y),0.0)-corner;}\nfloat squareTube(vec3 p,float side,float corner,float tube){return length(vec2(roundedSquare(p.xy,side,corner),p.z))-tube;}\nfloat roundBox(vec3 p,vec3 b,float r){vec3 q=abs(p)-b;return length(max(q,0.0))+min(max(q.x,max(q.y,q.z)),0.0)-r;}\nfloat torus(vec3 p,float major,float minor){return length(vec2(length(p.xy)-major,p.z))-minor;}\nfloat cylinder(vec3 p,float radius,float halfHeight){vec2 q=vec2(length(p.xz)-radius,abs(p.y)-halfHeight);return min(max(q.x,q.y),0.0)+length(max(q,0.0));}\nfloat capsuleX(vec3 p,float a,float b,float r){p.x-=clamp(p.x,a,b);return length(p)-r;}\nvec4 closest(vec4 a,vec4 b){return a.x<b.x?a:b;}\nvec4 weld(vec4 a,vec4 b,float k){float h=clamp(0.5+0.5*(b.x-a.x)/k,0.0,1.0);vec4 v=mix(b,a,h);v.x-=k*h*(1.0-h);return v;}\nfloat smoothMax(float a,float b,float k){float h=clamp(0.5+0.5*(a-b)/k,0.0,1.0);return mix(b,a,h)+k*h*(1.0-h);}\n// Material coordinates: distance, ceramic coverage, brass coverage, emission.\nvec4 ceramic(float d){return vec4(d,1,0,0);}\nvec4 brass(float d){return vec4(d,0,1,0);}\nvec4 enamel(float d){return vec4(d,0,0,0);}\nvec4 lightMaterial(float d){return vec4(d,0.25,0.25,1);}\n\n// Arc-length parametrization: straight, quarter circle, straight. Position and\n// tangent are continuous through every corner and at the four quadrant seams.\nvec4 roundedTrack(float u,float straight,float corner){\n    float sector=floor(u),arc=corner*0.5*PI,s=fract(u)*(2.0*straight+arc);\n    vec2 p,n;\n    if(s<straight){p=vec2(s,straight+corner);n=vec2(0,1);}\n    else if(s<straight+arc){float a=0.5*PI-(s-straight)/corner;n=vec2(cos(a),sin(a));p=vec2(straight)+corner*n;}\n    else{p=vec2(straight+corner,straight-(s-straight-arc));n=vec2(1,0);}\n    mat2 r=rotation(-sector*0.5*PI);return vec4(r*p,r*n);\n}\n\nvoid prepare(){\n    phase=TAU*mod(TIME*tempo,32.0)/32.0;\n    worldToClock=rx(-0.10+0.10*cos(phase))*ry(-0.22-0.28*sin(phase))*rz(-0.13-0.14*sin(phase));\n    innerTurn=rz(phase)*ry(phase*2.0)*rx(0.3+phase);\n    for(int i=0;i<8;i++){\n        float fi=float(i),parity=mod(fi,2.0)*2.0-1.0;\n        vec4 tr=roundedTrack(phase/TAU*4.0+fi*0.5,1.55,0.65);\n        carriage[i]=vec3(tr.xy,0.0);outward[i]=tr.zw;\n        float a=parity*phase*2.0+fi*PI*0.25;\n        rotor[i]=vec2(cos(a),sin(a));\n        float b=-parity*phase*4.0+fi*PI*0.5;\n        microRotor[i]=vec2(cos(b),sin(b));\n        float pulse=0.5+0.5*sin(phase*4.0-fi*PI*0.5);\n        extension[i]=0.37+0.46*pulse*pulse;\n    }\n    for(int i=0;i<4;i++)innerPearl[i]=vec3(roundedTrack(phase/TAU*4.0+float(i),0.43,0.50).xy,0.0);\n}\n\nvec4 mechanism(vec3 p){\n    vec3 q=worldToClock*p;\n    vec4 h=ceramic(squareTube(q,1.55,0.65,0.19));\n    // The twin threads are seated into the ceramic, not almost tangent to it.\n    vec3 rail=q;rail.z=abs(rail.z)-0.17;\n    h=weld(h,brass(squareTube(rail,1.55,0.65,0.028)),0.012);\n    vec3 cage=q;cage.z=abs(cage.z)-0.38;\n    float guideDistance=squareTube(cage,1.95,0.86,0.028);\n    // Eight articulated carriages. Bounding spheres skip the expensive anatomy\n    // for ray steps which cannot possibly touch a local module.\n    for(int i=0;i<8;i++){\n        vec3 v=q-carriage[i];\n        float bound=length(v)-1.20;\n        if(bound<min(h.x,guideDistance)+0.22){\n            vec2 n=outward[i];\n            vec3 c=vec3(dot(v.xy,n),dot(v.xy,vec2(-n.y,n.x)),v.z);\n            vec4 pod=enamel(roundBox(c,vec3(0.17,0.25,0.18),0.14));\n            vec3 collar=c;collar.y=abs(collar.y)-0.24;\n            float knurl=0.010*cos(atan(c.x,c.z)*12.0+phase*4.0);\n            float bearing=torus(collar.xzy,0.28+knurl,0.032)*0.84;\n            vec3 localRotor=c;localRotor.xz=turn(localRotor.xz,rotor[i]);\n            // Evaluate the complete four-spoke assembly: unequal strokes must\n            // not inherit the seams of a nearest-sector approximation.\n            for(int spoke=0;spoke<4;spoke++){\n            vec2 axis=spoke==0?vec2(1,0):(spoke==1?vec2(0,1):(spoke==2?vec2(-1,0):vec2(0,-1)));\n            vec3 r=vec3(dot(localRotor.xz,axis),localRotor.y,dot(localRotor.xz,vec2(-axis.y,axis.x)));\n            float radialDirection=dot(rotor[i],axis);\n            float reach=extension[i];\n            // Pistons facing the central escapement retract before their entire\n            // head/pearl assembly reaches its clearance sphere.\n            float along=dot(carriage[i].xy,outward[i])*radialDirection;\n            float gapDisc=along*along-dot(carriage[i],carriage[i])+2.02*2.02;\n            if(along<0.0&&gapDisc>0.0)reach=min(reach,max(0.12,-along-sqrt(gapDisc)));\n            if(capsuleX(r,0.16,reach,0.42)>pod.x+0.2)continue;\n            vec4 finger=ceramic(length(r-vec3(reach,0,0))-0.165);\n            finger=weld(finger,enamel(capsuleX(r,0.16,max(0.17,reach-0.08),0.058)),0.13*liquidity+0.02);\n            vec3 bead=r-vec3(reach,0,0);\n            bead.yz=turn(bead.yz,microRotor[i]);bead.y=abs(bead.y);\n            float radius=0.22+0.055*sin(phase*4.0+float(i)*PI*0.5);\n            vec4 micro=brass(length(bead-vec3(0,radius,0))-0.071);\n            vec3 stem=bead.yxz;\n            micro=weld(micro,brass(capsuleX(stem,0.08,radius,0.021)),0.045);\n            finger=weld(finger,micro,0.055+0.08*liquidity);\n            pod=weld(pod,finger,0.035+0.15*liquidity);\n            }\n            pod.x=max(pod.x,-bearing-0.014);\n            pod=closest(pod,brass(bearing));\n            // Rounded reliefs open in the guide rail around each moving module.\n            // Keep these rails out of the soft union so they do not fuse to it.\n            guideDistance=smoothMax(guideDistance,-pod.x-0.065,0.035);\n            h=weld(h,pod,0.035+0.07*liquidity);\n        }\n    }\n    h=closest(h,brass(guideDistance));\n    // An independent triple-axis escapement, suspended in the central opening.\n    vec3 a=innerTurn*q;\n    vec4 heart=ceramic(squareTube(a,0.43,0.50,0.070));\n    vec3 b=ry(-phase*2.0)*rz(0.25*PI)*q;\n    heart=closest(heart,brass(torus(b.yzx,0.73,0.045)));\n    vec3 c=rx(phase*2.0)*rz(-0.25*PI)*q;\n    heart=closest(heart,enamel(squareTube(c,0.26,1.08,0.058)));\n    vec3 core=rz(-phase)*ry(phase)*q;\n    float inhale=0.5+0.5*sin(phase*4.0);\n    float d=mix(roundBox(core,vec3(0.22),0.12),length(core)-0.40,inhale);\n    vec3 buds=abs(core);float axis=max(buds.x,max(buds.y,buds.z));\n    float bud=sqrt(max(dot(buds,buds)-axis*axis,0.0)+sq(axis-(0.25+0.14*inhale)))-0.14;\n    heart=weld(heart,lightMaterial(d),0.1);\n    heart=weld(heart,lightMaterial(bud),0.11+0.10*liquidity);\n    // The white pearls now follow the actual rounded-square centerline.\n    for(int i=0;i<4;i++)heart=weld(heart,ceramic(length(a-innerPearl[i])-0.102),0.025);\n    h=closest(h,heart);\n    // A new depth layer: mirrored six-petal iris crowns. Their counter-rotation\n    // and alternating hinge angle share the escapement's master phase.\n    for(int side=0;side<2;side++){\n        float face=float(side)*2.0-1.0;\n        vec3 crown=q;crown.z-=face*1.78;\n        if(length(crown)-1.55<h.x){\n            crown.xy=rotation(-face*phase)*crown.xy;\n            vec4 iris=brass(torus(crown,0.81,0.036));\n            float sector=floor(atan(crown.y,crown.x)/(TAU/6.0)+0.5);\n            crown.xy=rotation(-sector*(TAU/6.0))*crown.xy;\n            vec3 hinge=crown-vec3(0.81,0,0);\n            float pitch=face*(0.36+0.30*sin(phase*2.0+face*PI*0.5));\n            vec3 vane=hinge;vane.xz=rotation(pitch)*vane.xz;vane.x-=0.25;\n            vec4 petal=ceramic(roundBox(vane,vec3(0.19,0.095,0.028),0.075));\n            // Recessed enamel flutes and a brass hinge give each folding blade\n            // a legible front and back when the camera moves around the clock.\n            vec3 flute=vane;flute.z=abs(flute.z)-0.100;\n            float channel=roundBox(flute,vec3(0.115,0.025,0.012),0.019);\n            petal.x=max(petal.x,-channel);\n            vec3 inlay=flute;inlay.z+=0.021;\n            petal=closest(petal,enamel(roundBox(inlay,vec3(0.10,0.015,0.009),0.012)));\n            float pin=torus(hinge.xzy,0.10,0.025);\n            petal.x=max(petal.x,-pin-0.012);\n            iris=closest(iris,petal);iris=closest(iris,brass(pin));\n            iris=closest(iris,lightMaterial(length(vane-vec3(0.19,0,0.082))-0.029));\n            h=closest(h,iris);\n        }\n    }\n    // Fine gimbal arcs enclose the clock without hiding its silhouette.\n    vec3 g=ry(0.75+0.20*sin(phase))*rx(0.55)*p;\n    h=closest(h,brass(torus(g,4.20,0.026)));\n    vec3 g2=rx(-0.70+0.12*cos(phase))*ry(-0.8)*p;\n    h=closest(h,enamel(torus(g2,4.38,0.035)));\n    vec3 bead=g;bead.xy=rotation(phase)*bead.xy;bead.xy=abs(bead.xy);\n    if(bead.y>bead.x)bead.xy=bead.yx;\n    h=closest(h,lightMaterial(length(bead-vec3(4.20,0,0))-0.048));\n    float tickSector=TAU/96.0;\n    float tickAngle=atan(g.y,g.x);\n    vec3 tick=g;tick.xy=rotation(-floor(tickAngle/tickSector+0.5)*tickSector)*tick.xy;\n    h=closest(h,brass(roundBox(tick-vec3(4.20,0,0),vec3(0.042,0.009,0.021),0.006)));\n    return h;\n}\n\nvec4 scene(vec3 p){\n    float bound=length(p)-SCULPTURE_BOUND;\n    vec4 h=enamel(bound);\n    if(bound<0.7)h=mechanism(p);\n    vec3 base=p-vec3(0,-4.50,0);\n    vec4 plinth=vec4(cylinder(base,2.9,0.18)-0.055,-1,0,0);\n    vec3 lip=base;lip.y+=0.09;\n    plinth=closest(plinth,brass(torus(lip.xzy,2.94,0.026)));\n    vec3 foot=base;foot.y+=0.24;\n    plinth=closest(plinth,vec4(cylinder(foot,2.55,0.11)-0.055,-1,0,0));\n    h=closest(h,plinth);\n    return closest(h,vec4(p.y+5.05,-2,0,0));\n}\n\nvec2 march(vec3 ro,vec3 rd,float limit){\n    float t=0.0,found=-1.0;\n    for(int i=0;i<1536;i++){\n        vec4 h=scene(ro+t*rd);\n        traceSteps=float(i);\n        if(h.x<max(0.00006,t*0.000008)){primaryMaterial=h;found=1.0;break;}\n        t+=h.x*0.78;\n        if(t>limit)break;\n        if(i==1535)traceExhausted=1.0;\n    }\n    return vec2(t,found);\n}\n\n// Normal, contact occlusion and key-light shadow share a single SDF call site.\n// This matters to WebGL drivers that inline the complete mechanism at every\n// call site: a compact source should also be a compact compiler workload.\nvoid geometryLighting(vec3 p,float eps,out vec3 n,out float ao,out float sh){\n    vec3 gradient=vec3(0),key=normalize(vec3(-0.55,0.85,0.65));\n    n=vec3(0,1,0);\n    float occ=0.0,weight=1.0,visibility=1.0,t=0.035;\n    for(int i=0;i<44;i++){\n        vec3 samplePoint,e=vec3(0);float r=0.0;\n        if(i<4){\n            e=0.5773*(2.0*vec3(float((i+3)/2-(i+3)/4*2),float(i/2),float(i-i/2*2))-1.0);\n            samplePoint=p+eps*e;\n        }else if(i<8){r=0.06+float(i-4)*0.15;samplePoint=p+n*r;}\n        else{if(visibility<0.015||t>8.0)break;samplePoint=p+n*0.007+key*t;}\n        float d=scene(samplePoint).x;\n        if(i<4){gradient+=e*d;if(i==3)n=normalize(gradient);}\n        else if(i<8){occ+=(r-d)*weight;weight*=0.6;}\n        else{visibility=min(visibility,10.0*d/t);t+=clamp(d,0.025,0.5);}\n    }\n    ao=sat(1.0-1.7*occ);sh=mix(0.17,1.0,sat(visibility));\n}\n\n// A procedural photographic lighting rig, reflected by the metal and enamel.\nvec3 studio(vec3 d,float rough){\n    vec3 col=mix(vec3(0.055,0.105,0.12),vec3(0.36,0.40,0.39),smoothstep(-0.65,0.8,d.y));\n    float soft=0.03+rough*0.38;\n    vec3 key=normalize(vec3(-0.65,0.8,0.7));\n    vec3 side=normalize(cross(key,vec3(0,1,0))),up=cross(side,key);\n    vec2 k=vec2(dot(d,side),dot(d,up))/max(0.01,dot(d,key));\n    float panel=(1.0-smoothstep(0.22,0.22+soft,abs(k.x)))*(1.0-smoothstep(0.72,0.72+soft,abs(k.y)))*step(0.0,dot(d,key));\n    col+=vec3(3.8,3.4,2.8)*panel;\n    vec3 rim=normalize(vec3(0.85,0.15,-0.5));\n    float band=pow(max(dot(d,rim),0.0),mix(100.0,9.0,rough));\n    col+=vec3(0.40,1.4,1.7)*band*3.0;\n    float strip=pow(max(dot(d,normalize(vec3(0.5,0.5,0.8))),0.0),mix(220.0,14.0,rough));\n    col+=vec3(2.4,1.10,0.46)*strip;\n    return col;\n}\n\nvec3 directLight(vec3 n,vec3 v,vec3 l,vec3 albedo,vec3 f0,float metal,float rough){\n    vec3 h=normalize(l+v);\n    float nl=max(dot(n,l),0.0),nv=max(dot(n,v),0.001),nh=max(dot(n,h),0.0);\n    float a=rough*rough,a2=a*a;\n    float d=a2/(PI*sq(nh*nh*(a2-1.0)+1.0));\n    float k=sq(rough+1.0)/8.0;\n    float g=nl/(nl*(1.0-k)+k)*nv/(nv*(1.0-k)+k);\n    vec3 f=f0+(1.0-f0)*pow(1.0-max(dot(h,v),0.0),5.0);\n    return ((1.0-f)*(1.0-metal)*albedo/PI+d*g*f/max(0.004,4.0*nl*nv))*nl;\n}\n\n// One geometric reflection bounce, clipped to the sculpture's bounding sphere.\n// A compact secondary lighting model avoids recursive shading and shadow rays.\nvec3 reflectedScene(vec3 ro,vec3 rd,float rough){\n    vec3 env=studio(rd,rough);\n    float b=dot(ro,rd),disc=b*b-dot(ro,ro)+SCULPTURE_BOUND*SCULPTURE_BOUND;\n    if(disc<0.0)return env;\n    float t=max(0.012,-b-sqrt(disc)),end=-b+sqrt(disc);\n    if(end<t)return env;\n    vec4 h=vec4(1,0,0,0);bool found=false;\n    for(int i=0;i<112;i++){\n        h=mechanism(ro+rd*t);\n        if(h.x<0.0015+t*0.0003){found=true;break;}\n        t+=max(h.x*0.8,0.001);\n        if(t>end)break;\n    }\n    if(!found)return env;\n    // A broad view-facing lobe for reflected hits: full geometry is traced,\n    // but secondary microfacets are deliberately not evaluated a second time.\n    vec3 n=-rd;\n    vec3 albedo=mix(vec3(0.012,0.13,0.145),vec3(0.81,0.84,0.73),sat(h.y));\n    albedo=mix(albedo,vec3(0.78,0.44,0.19),sat(h.z));\n    vec3 color=albedo*(0.15+1.10*max(dot(n,normalize(vec3(-0.55,0.85,0.65))),0.0));\n    color+=vec3(0.12,0.23,0.24)*max(dot(n,normalize(vec3(0.85,0.2,-0.55))),0.0);\n    color+=studio(reflect(rd,n),0.33)*mix(0.10,0.50,sat(h.z));\n    color=mix(color,vec3(1.2,0.22,0.045)+color*0.5,sat(h.w));\n    return color;\n}\n\nvec3 surface(vec3 p,vec3 n,vec3 rd,vec4 h,float ao,float sh){\n    float ceramicMix=sat(h.y),metalMix=sat(h.z),glow=sat(h.w);\n    vec3 albedo=mix(vec3(0.012,0.13,0.145),vec3(0.81,0.84,0.73),ceramicMix);\n    albedo=mix(albedo,vec3(0.78,0.44,0.19),metalMix);\n    float metal=mix(0.46,0.10,ceramicMix);metal=mix(metal,0.92,metalMix);\n    float rough=mix(0.25,0.28,ceramicMix);rough=mix(rough,0.25,metalMix);\n    if(h.y< -0.5){\n        metal=0.5;rough=0.34;albedo=vec3(0.028,0.046,0.045);\n        if(h.y< -1.5){metal=0.25;rough=0.36;albedo=vec3(0.018,0.030,0.034);}\n        // A uniform satin finish stays stable through the complete orbit;\n        // subpixel concentric grooves shimmered under grazing side lighting.\n    }\n    vec3 v=-rd;float nv=max(dot(n,v),0.0);\n    vec3 f0=mix(vec3(0.045),albedo,metal);\n    vec3 fresnel=f0+(1.0-f0)*pow(1.0-nv,5.0);\n    vec3 key=normalize(vec3(-0.55,0.85,0.65));\n    vec3 color=directLight(n,v,key,albedo,f0,metal,rough)*vec3(4.0,3.6,2.95)*sh;\n    color+=directLight(n,v,normalize(vec3(0.85,0.2,-0.55)),albedo,f0,metal,rough)*vec3(0.9,2.0,2.2)*ao;\n    color+=directLight(n,v,normalize(vec3(0.1,-0.3,1.0)),albedo,f0,metal,rough)*vec3(0.7,0.58,0.46)*ao;\n    color+=albedo*(1.0-metal)*mix(vec3(0.06,0.13,0.14),vec3(0.45,0.48,0.42),n.y*0.5+0.5)*ao;\n    vec3 env=reflectedScene(p+n*0.015,reflect(rd,n),rough);\n    color+=env*fresnel*mix(0.42,1.0,ao)*(0.9-0.35*rough);\n    // Pearlescent clearcoat is restrained to the ivory, strongest at grazing angles.\n    vec3 iridescence=0.5+0.5*cos(vec3(0,2.1,4.2)+nv*7.0+0.4);\n    color+=ceramicMix*iridescence*pow(1.0-nv,3.0)*0.16*ao;\n    vec3 heartLight=vec3(1.0,0.19,0.055)*1.5/(1.0+dot(p,p)*2.0);\n    color+=heartLight*albedo*max(dot(n,normalize(-p+vec3(0.001))),0.0)*ao;\n    color=mix(color,vec3(1.8,0.22,0.045)*(0.45+0.65*nv*nv)+color*0.85,glow);\n    return color;\n}\n\nvec3 background(vec3 ro,vec3 rd){\n    float horizon=exp(-sq((rd.y+0.15)*2.8));\n    vec3 c=mix(vec3(0.010,0.026,0.035),vec3(0.055,0.090,0.095),horizon);\n    float warm=pow(max(dot(rd,normalize(vec3(-0.6,0.1,-1))),0.0),8.0);\n    return c+vec3(0.085,0.053,0.026)*warm;\n}\n\nvec3 render(vec2 pixel){\n    prepare();\n    vec2 uv=(pixel-0.5*RENDERSIZE)/RENDERSIZE.y;\n    // Independent from the 32-second machinery phase: never reverse or jump\n    // back to the starting angle when an escapement cycle completes.\n    float orbit=TAU*mod(TIME*orbitSpeed,96.0)/96.0;\n    vec3 ro=ry(orbit)*vec3(7.45,4.32,15.55),target=vec3(0,-0.60,0);\n    // Keep the complete machine framed on portrait displays as well.\n    ro*=max(1.0,0.85*RENDERSIZE.y/RENDERSIZE.x);\n    vec3 fw=normalize(target-ro),right=normalize(cross(fw,vec3(0,1,0))),up=cross(right,fw);\n    vec3 rd=normalize(fw*1.62+right*uv.x+up*uv.y);\n    vec3 col=background(ro,rd);\n    vec2 hit=march(ro,rd,65.0);\n    // The infinite stage continues beyond the finite sculpture trace distance.\n    if(hit.y<0.0&&rd.y< -0.0001)hit=vec2((-5.05-ro.y)/rd.y,1.0);\n    if(hit.y>0.0){\n        vec3 p=ro+rd*hit.x;vec4 h=primaryMaterial;\n        vec3 n;float ao,sh;\n        geometryLighting(p,0.0003,n,ao,sh);\n        col=surface(p,n,rd,h,ao,sh);\n        float fog=1.0-exp(-max(hit.x-11.0,0.0)*0.025);\n        col=mix(col,background(ro,rd),fog);\n    }\n    col*=1.0-0.12*dot(uv,uv);\n    return max(col,0.0);\n}\n\nvec3 tonemap(vec3 x){return clamp((x*(2.51*x+0.03))/(x*(2.43*x+0.59)+0.14),0.0,1.0);}\n// Explicit bilinear filtering also works when float textures are nearest-only.\nvec3 filteredImage(vec2 uv){\n    vec2 p=uv*RENDERSIZE-0.5,cell=floor(p),f=fract(p);\n    vec3 a=IMG_PIXEL(clockImage,clamp(cell+vec2(0.5),vec2(0.5),RENDERSIZE-0.5)).rgb;\n    vec3 b=IMG_PIXEL(clockImage,clamp(cell+vec2(1.5,0.5),vec2(0.5),RENDERSIZE-0.5)).rgb;\n    vec3 c=IMG_PIXEL(clockImage,clamp(cell+vec2(0.5,1.5),vec2(0.5),RENDERSIZE-0.5)).rgb;\n    vec3 d=IMG_PIXEL(clockImage,clamp(cell+vec2(1.5),vec2(0.5),RENDERSIZE-0.5)).rgb;\n    return mix(mix(a,b,f.x),mix(c,d,f.x),f.y);\n}\nvec3 antialias(vec2 uv){\n    vec2 px=1.0/RENDERSIZE;vec3 lum=vec3(0.299,0.587,0.114);\n    vec3 center=filteredImage(uv);\n    float nw=dot(filteredImage(uv+vec2(-1,1)*px),lum),ne=dot(filteredImage(uv+px),lum);\n    float sw=dot(filteredImage(uv-px),lum),se=dot(filteredImage(uv+vec2(1,-1)*px),lum);\n    float mid=dot(center,lum),lo=min(mid,min(min(nw,ne),min(sw,se))),hi=max(mid,max(max(nw,ne),max(sw,se)));\n    if(hi-lo<max(0.015,hi*0.08))return center;\n    vec2 dir=vec2(-((nw+ne)-(sw+se)),(nw+sw)-(ne+se));\n    float reduce=max((nw+ne+sw+se)*0.03125,0.0078125);\n    dir=clamp(dir/(min(abs(dir.x),abs(dir.y))+reduce),-6.0,6.0)*px;\n    vec3 a=0.5*(filteredImage(uv-dir/6.0)+filteredImage(uv+dir/6.0));\n    vec3 b=a*0.5+0.25*(filteredImage(uv-dir*0.5)+filteredImage(uv+dir*0.5));\n    float lb=dot(b,lum);return lb<lo||lb>hi?a:b;\n}\nvoid main(){\n    if(PASSINDEX==0){gl_FragColor=vec4(render(gl_FragCoord.xy),1.0);return;}\n    vec2 uv=gl_FragCoord.xy/RENDERSIZE;\n    // Full, contiguous separable kernels avoid the repeated glint copies that\n    // sparse radial bloom taps can leave around narrow metallic geometry.\n    if(PASSINDEX==1||PASSINDEX==2){\n        vec3 sum=vec3(0);float total=0.0;\n        for(int i=0;i<25;i++){\n            float offset=float(i)-12.0,w=exp(-offset*offset/40.0);\n            vec2 p=gl_FragCoord.xy+(PASSINDEX==1?vec2(offset,0):vec2(0,offset));\n            p=clamp(p,vec2(0.5),RENDERSIZE-0.5);\n            vec3 tap;\n            if(PASSINDEX==1)tap=max(IMG_PIXEL(clockImage,p).rgb-0.85,0.0);\n            else tap=IMG_PIXEL(haloHorizontal,p).rgb;\n            sum+=tap*w;total+=w;\n        }\n        gl_FragColor=vec4(sum/total,1);return;\n    }\n    vec3 color=antialias(uv);\n    color+=IMG_NORM_PIXEL(haloVertical,uv).rgb*bloomAmount*0.23;\n    color=pow(tonemap(color*exposure),vec3(1.0/2.2));\n    color+=(hash(gl_FragCoord.xy)-0.5)/255.0;\n    gl_FragColor=vec4(color,1.0);\n}\n",
    "generator": {
      "model": "gpt-6",
      "provider": "openai",
      "prompt": "Original brief (summary): Create a visually incredible, original abstract 3D world of bizarre blobby clockwork machinery. Build complex but intentional geometric motion around a square or torus, with staggered orbiting shapes, smaller orbiting satellites and periodically extending, pulsing elements. Take the concept much further creatively, with shapes meshing, merging and melding in neatly aligned geometric patterns. Refinement feedback: 'beautiful stuff, let's try refining some of the intersections a bit, make the camera continuously orbit slowly, and maybe even add 1 more layer of stuff going on'.",
      "params": {
        "study": "Second Movement: an original abstract kinetic shader refined with human feedback. The first movement is preserved locally and is unpublished; this is an independent publication, unrelated to the Cathedral landscapes.",
        "passes": 4,
        "workflow": "Original GLSL authored and revised in Codex; visual iteration, sampled geometric-clearance checks, full-orbit diagnostics and canonical glslop WebGL2 validation.",
        "loop_note": "The 96-second full-scene period applies to default inputs; changing tempo or orbit speed can change the combined period.",
        "poster_width": 512,
        "poster_height": 512,
        "seamless_loop": true,
        "default_inputs": {
          "tempo": 1,
          "exposure": 1,
          "liquidity": 0.75,
          "orbitSpeed": 1,
          "bloomAmount": 0.65
        },
        "poster_time_seconds": 0,
        "external_texture_assets": false,
        "loop_seconds_at_defaults": 96,
        "camera_orbit_seconds_at_default_speed": 96,
        "mechanism_cycle_seconds_at_default_tempo": 32
      }
    }
  }
}