fork a shader
Write or paste an ISF shader (GLSL ES with a /*{ ... }*/ header). It compiles + renders in yer browser. New-account submissions go to the moderation queue; trusted level 2+ authors can go live immediately. Everything is CC0. Got a file first? preview it locally →
A model marks this as witnessed_generation (honest AI provenance). Leave blank if you hand-authored it.
/*{ "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.", "CREDIT": "OpenAI / Codex", "ISFVSN": "2", "CATEGORIES": ["3D", "Abstract", "Raymarching"], "PASSES": [{"TARGET": "clockImage", "FLOAT": true}, {"TARGET": "haloHorizontal", "FLOAT": true}, {"TARGET": "haloVertical", "FLOAT": true}, {}], "INPUTS": [ {"NAME": "tempo", "LABEL": "Tempo", "TYPE": "float", "DEFAULT": 1.0, "MIN": 0.2, "MAX": 2.0}, {"NAME": "liquidity", "LABEL": "Liquid joints", "TYPE": "float", "DEFAULT": 0.75, "MIN": 0.0, "MAX": 1.0}, {"NAME": "orbitSpeed", "LABEL": "Camera orbit speed", "TYPE": "float", "DEFAULT": 1.0, "MIN": 0.0, "MAX": 2.0}, {"NAME": "bloomAmount", "LABEL": "Halation", "TYPE": "float", "DEFAULT": 0.65, "MIN": 0.0, "MAX": 1.5}, {"NAME": "exposure", "LABEL": "Exposure", "TYPE": "float", "DEFAULT": 1.0, "MIN": 0.6, "MAX": 1.5} ] }*/ const float PI=3.14159265359; const float TAU=6.28318530718; const float SCULPTURE_BOUND=4.50; float phase; mat3 worldToClock; mat3 innerTurn; vec3 carriage[8]; vec2 outward[8]; vec2 rotor[8]; vec2 microRotor[8]; float extension[8]; vec3 innerPearl[4]; float traceExhausted=0.0; float traceSteps=0.0; vec4 primaryMaterial=vec4(0,-2,0,0); mat2 rotation(float a){float c=cos(a),s=sin(a);return mat2(c,s,-s,c);} mat3 rx(float a){float c=cos(a),s=sin(a);return mat3(1,0,0,0,c,s,0,-s,c);} mat3 ry(float a){float c=cos(a),s=sin(a);return mat3(c,0,-s,0,1,0,s,0,c);} mat3 rz(float a){float c=cos(a),s=sin(a);return mat3(c,s,0,-s,c,0,0,0,1);} vec2 turn(vec2 p,vec2 cs){return vec2(cs.x*p.x-cs.y*p.y,cs.y*p.x+cs.x*p.y);} float sat(float x){return clamp(x,0.0,1.0);} float sq(float x){return x*x;} float hash(vec2 p){return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453);} float 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;} float squareTube(vec3 p,float side,float corner,float tube){return length(vec2(roundedSquare(p.xy,side,corner),p.z))-tube;} float 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;} float torus(vec3 p,float major,float minor){return length(vec2(length(p.xy)-major,p.z))-minor;} float 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));} float capsuleX(vec3 p,float a,float b,float r){p.x-=clamp(p.x,a,b);return length(p)-r;} vec4 closest(vec4 a,vec4 b){return a.x<b.x?a:b;} vec4 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;} float 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);} // Material coordinates: distance, ceramic coverage, brass coverage, emission. vec4 ceramic(float d){return vec4(d,1,0,0);} vec4 brass(float d){return vec4(d,0,1,0);} vec4 enamel(float d){return vec4(d,0,0,0);} vec4 lightMaterial(float d){return vec4(d,0.25,0.25,1);} // Arc-length parametrization: straight, quarter circle, straight. Position and // tangent are continuous through every corner and at the four quadrant seams. vec4 roundedTrack(float u,float straight,float corner){ float sector=floor(u),arc=corner*0.5*PI,s=fract(u)*(2.0*straight+arc); vec2 p,n; if(s<straight){p=vec2(s,straight+corner);n=vec2(0,1);} else if(s<straight+arc){float a=0.5*PI-(s-straight)/corner;n=vec2(cos(a),sin(a));p=vec2(straight)+corner*n;} else{p=vec2(straight+corner,straight-(s-straight-arc));n=vec2(1,0);} mat2 r=rotation(-sector*0.5*PI);return vec4(r*p,r*n); } void prepare(){ phase=TAU*mod(TIME*tempo,32.0)/32.0; worldToClock=rx(-0.10+0.10*cos(phase))*ry(-0.22-0.28*sin(phase))*rz(-0.13-0.14*sin(phase)); innerTurn=rz(phase)*ry(phase*2.0)*rx(0.3+phase); for(int i=0;i<8;i++){ float fi=float(i),parity=mod(fi,2.0)*2.0-1.0; vec4 tr=roundedTrack(phase/TAU*4.0+fi*0.5,1.55,0.65); carriage[i]=vec3(tr.xy,0.0);outward[i]=tr.zw; float a=parity*phase*2.0+fi*PI*0.25; rotor[i]=vec2(cos(a),sin(a)); float b=-parity*phase*4.0+fi*PI*0.5; microRotor[i]=vec2(cos(b),sin(b)); float pulse=0.5+0.5*sin(phase*4.0-fi*PI*0.5); extension[i]=0.37+0.46*pulse*pulse; } for(int i=0;i<4;i++)innerPearl[i]=vec3(roundedTrack(phase/TAU*4.0+float(i),0.43,0.50).xy,0.0); } vec4 mechanism(vec3 p){ vec3 q=worldToClock*p; vec4 h=ceramic(squareTube(q,1.55,0.65,0.19)); // The twin threads are seated into the ceramic, not almost tangent to it. vec3 rail=q;rail.z=abs(rail.z)-0.17; h=weld(h,brass(squareTube(rail,1.55,0.65,0.028)),0.012); vec3 cage=q;cage.z=abs(cage.z)-0.38; float guideDistance=squareTube(cage,1.95,0.86,0.028); // Eight articulated carriages. Bounding spheres skip the expensive anatomy // for ray steps which cannot possibly touch a local module. for(int i=0;i<8;i++){ vec3 v=q-carriage[i]; float bound=length(v)-1.20; if(bound<min(h.x,guideDistance)+0.22){ vec2 n=outward[i]; vec3 c=vec3(dot(v.xy,n),dot(v.xy,vec2(-n.y,n.x)),v.z); vec4 pod=enamel(roundBox(c,vec3(0.17,0.25,0.18),0.14)); vec3 collar=c;collar.y=abs(collar.y)-0.24; float knurl=0.010*cos(atan(c.x,c.z)*12.0+phase*4.0); float bearing=torus(collar.xzy,0.28+knurl,0.032)*0.84; vec3 localRotor=c;localRotor.xz=turn(localRotor.xz,rotor[i]); // Evaluate the complete four-spoke assembly: unequal strokes must // not inherit the seams of a nearest-sector approximation. for(int spoke=0;spoke<4;spoke++){ vec2 axis=spoke==0?vec2(1,0):(spoke==1?vec2(0,1):(spoke==2?vec2(-1,0):vec2(0,-1))); vec3 r=vec3(dot(localRotor.xz,axis),localRotor.y,dot(localRotor.xz,vec2(-axis.y,axis.x))); float radialDirection=dot(rotor[i],axis); float reach=extension[i]; // Pistons facing the central escapement retract before their entire // head/pearl assembly reaches its clearance sphere. float along=dot(carriage[i].xy,outward[i])*radialDirection; float gapDisc=along*along-dot(carriage[i],carriage[i])+2.02*2.02; if(along<0.0&&gapDisc>0.0)reach=min(reach,max(0.12,-along-sqrt(gapDisc))); if(capsuleX(r,0.16,reach,0.42)>pod.x+0.2)continue; vec4 finger=ceramic(length(r-vec3(reach,0,0))-0.165); finger=weld(finger,enamel(capsuleX(r,0.16,max(0.17,reach-0.08),0.058)),0.13*liquidity+0.02); vec3 bead=r-vec3(reach,0,0); bead.yz=turn(bead.yz,microRotor[i]);bead.y=abs(bead.y); float radius=0.22+0.055*sin(phase*4.0+float(i)*PI*0.5); vec4 micro=brass(length(bead-vec3(0,radius,0))-0.071); vec3 stem=bead.yxz; micro=weld(micro,brass(capsuleX(stem,0.08,radius,0.021)),0.045); finger=weld(finger,micro,0.055+0.08*liquidity); pod=weld(pod,finger,0.035+0.15*liquidity); } pod.x=max(pod.x,-bearing-0.014); pod=closest(pod,brass(bearing)); // Rounded reliefs open in the guide rail around each moving module. // Keep these rails out of the soft union so they do not fuse to it. guideDistance=smoothMax(guideDistance,-pod.x-0.065,0.035); h=weld(h,pod,0.035+0.07*liquidity); } } h=closest(h,brass(guideDistance)); // An independent triple-axis escapement, suspended in the central opening. vec3 a=innerTurn*q; vec4 heart=ceramic(squareTube(a,0.43,0.50,0.070)); vec3 b=ry(-phase*2.0)*rz(0.25*PI)*q; heart=closest(heart,brass(torus(b.yzx,0.73,0.045))); vec3 c=rx(phase*2.0)*rz(-0.25*PI)*q; heart=closest(heart,enamel(squareTube(c,0.26,1.08,0.058))); vec3 core=rz(-phase)*ry(phase)*q; float inhale=0.5+0.5*sin(phase*4.0); float d=mix(roundBox(core,vec3(0.22),0.12),length(core)-0.40,inhale); vec3 buds=abs(core);float axis=max(buds.x,max(buds.y,buds.z)); float bud=sqrt(max(dot(buds,buds)-axis*axis,0.0)+sq(axis-(0.25+0.14*inhale)))-0.14; heart=weld(heart,lightMaterial(d),0.1); heart=weld(heart,lightMaterial(bud),0.11+0.10*liquidity); // The white pearls now follow the actual rounded-square centerline. for(int i=0;i<4;i++)heart=weld(heart,ceramic(length(a-innerPearl[i])-0.102),0.025); h=closest(h,heart); // A new depth layer: mirrored six-petal iris crowns. Their counter-rotation // and alternating hinge angle share the escapement's master phase. for(int side=0;side<2;side++){ float face=float(side)*2.0-1.0; vec3 crown=q;crown.z-=face*1.78; if(length(crown)-1.55<h.x){ crown.xy=rotation(-face*phase)*crown.xy; vec4 iris=brass(torus(crown,0.81,0.036)); float sector=floor(atan(crown.y,crown.x)/(TAU/6.0)+0.5); crown.xy=rotation(-sector*(TAU/6.0))*crown.xy; vec3 hinge=crown-vec3(0.81,0,0); float pitch=face*(0.36+0.30*sin(phase*2.0+face*PI*0.5)); vec3 vane=hinge;vane.xz=rotation(pitch)*vane.xz;vane.x-=0.25; vec4 petal=ceramic(roundBox(vane,vec3(0.19,0.095,0.028),0.075)); // Recessed enamel flutes and a brass hinge give each folding blade // a legible front and back when the camera moves around the clock. vec3 flute=vane;flute.z=abs(flute.z)-0.100; float channel=roundBox(flute,vec3(0.115,0.025,0.012),0.019); petal.x=max(petal.x,-channel); vec3 inlay=flute;inlay.z+=0.021; petal=closest(petal,enamel(roundBox(inlay,vec3(0.10,0.015,0.009),0.012))); float pin=torus(hinge.xzy,0.10,0.025); petal.x=max(petal.x,-pin-0.012); iris=closest(iris,petal);iris=closest(iris,brass(pin)); iris=closest(iris,lightMaterial(length(vane-vec3(0.19,0,0.082))-0.029)); h=closest(h,iris); } } // Fine gimbal arcs enclose the clock without hiding its silhouette. vec3 g=ry(0.75+0.20*sin(phase))*rx(0.55)*p; h=closest(h,brass(torus(g,4.20,0.026))); vec3 g2=rx(-0.70+0.12*cos(phase))*ry(-0.8)*p; h=closest(h,enamel(torus(g2,4.38,0.035))); vec3 bead=g;bead.xy=rotation(phase)*bead.xy;bead.xy=abs(bead.xy); if(bead.y>bead.x)bead.xy=bead.yx; h=closest(h,lightMaterial(length(bead-vec3(4.20,0,0))-0.048)); float tickSector=TAU/96.0; float tickAngle=atan(g.y,g.x); vec3 tick=g;tick.xy=rotation(-floor(tickAngle/tickSector+0.5)*tickSector)*tick.xy; h=closest(h,brass(roundBox(tick-vec3(4.20,0,0),vec3(0.042,0.009,0.021),0.006))); return h; } vec4 scene(vec3 p){ float bound=length(p)-SCULPTURE_BOUND; vec4 h=enamel(bound); if(bound<0.7)h=mechanism(p); vec3 base=p-vec3(0,-4.50,0); vec4 plinth=vec4(cylinder(base,2.9,0.18)-0.055,-1,0,0); vec3 lip=base;lip.y+=0.09; plinth=closest(plinth,brass(torus(lip.xzy,2.94,0.026))); vec3 foot=base;foot.y+=0.24; plinth=closest(plinth,vec4(cylinder(foot,2.55,0.11)-0.055,-1,0,0)); h=closest(h,plinth); return closest(h,vec4(p.y+5.05,-2,0,0)); } vec2 march(vec3 ro,vec3 rd,float limit){ float t=0.0,found=-1.0; for(int i=0;i<1536;i++){ vec4 h=scene(ro+t*rd); traceSteps=float(i); if(h.x<max(0.00006,t*0.000008)){primaryMaterial=h;found=1.0;break;} t+=h.x*0.78; if(t>limit)break; if(i==1535)traceExhausted=1.0; } return vec2(t,found); } // Normal, contact occlusion and key-light shadow share a single SDF call site. // This matters to WebGL drivers that inline the complete mechanism at every // call site: a compact source should also be a compact compiler workload. void geometryLighting(vec3 p,float eps,out vec3 n,out float ao,out float sh){ vec3 gradient=vec3(0),key=normalize(vec3(-0.55,0.85,0.65)); n=vec3(0,1,0); float occ=0.0,weight=1.0,visibility=1.0,t=0.035; for(int i=0;i<44;i++){ vec3 samplePoint,e=vec3(0);float r=0.0; if(i<4){ e=0.5773*(2.0*vec3(float((i+3)/2-(i+3)/4*2),float(i/2),float(i-i/2*2))-1.0); samplePoint=p+eps*e; }else if(i<8){r=0.06+float(i-4)*0.15;samplePoint=p+n*r;} else{if(visibility<0.015||t>8.0)break;samplePoint=p+n*0.007+key*t;} float d=scene(samplePoint).x; if(i<4){gradient+=e*d;if(i==3)n=normalize(gradient);} else if(i<8){occ+=(r-d)*weight;weight*=0.6;} else{visibility=min(visibility,10.0*d/t);t+=clamp(d,0.025,0.5);} } ao=sat(1.0-1.7*occ);sh=mix(0.17,1.0,sat(visibility)); } // A procedural photographic lighting rig, reflected by the metal and enamel. vec3 studio(vec3 d,float rough){ vec3 col=mix(vec3(0.055,0.105,0.12),vec3(0.36,0.40,0.39),smoothstep(-0.65,0.8,d.y)); float soft=0.03+rough*0.38; vec3 key=normalize(vec3(-0.65,0.8,0.7)); vec3 side=normalize(cross(key,vec3(0,1,0))),up=cross(side,key); vec2 k=vec2(dot(d,side),dot(d,up))/max(0.01,dot(d,key)); 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)); col+=vec3(3.8,3.4,2.8)*panel; vec3 rim=normalize(vec3(0.85,0.15,-0.5)); float band=pow(max(dot(d,rim),0.0),mix(100.0,9.0,rough)); col+=vec3(0.40,1.4,1.7)*band*3.0; float strip=pow(max(dot(d,normalize(vec3(0.5,0.5,0.8))),0.0),mix(220.0,14.0,rough)); col+=vec3(2.4,1.10,0.46)*strip; return col; } vec3 directLight(vec3 n,vec3 v,vec3 l,vec3 albedo,vec3 f0,float metal,float rough){ vec3 h=normalize(l+v); float nl=max(dot(n,l),0.0),nv=max(dot(n,v),0.001),nh=max(dot(n,h),0.0); float a=rough*rough,a2=a*a; float d=a2/(PI*sq(nh*nh*(a2-1.0)+1.0)); float k=sq(rough+1.0)/8.0; float g=nl/(nl*(1.0-k)+k)*nv/(nv*(1.0-k)+k); vec3 f=f0+(1.0-f0)*pow(1.0-max(dot(h,v),0.0),5.0); return ((1.0-f)*(1.0-metal)*albedo/PI+d*g*f/max(0.004,4.0*nl*nv))*nl; } // One geometric reflection bounce, clipped to the sculpture's bounding sphere. // A compact secondary lighting model avoids recursive shading and shadow rays. vec3 reflectedScene(vec3 ro,vec3 rd,float rough){ vec3 env=studio(rd,rough); float b=dot(ro,rd),disc=b*b-dot(ro,ro)+SCULPTURE_BOUND*SCULPTURE_BOUND; if(disc<0.0)return env; float t=max(0.012,-b-sqrt(disc)),end=-b+sqrt(disc); if(end<t)return env; vec4 h=vec4(1,0,0,0);bool found=false; for(int i=0;i<112;i++){ h=mechanism(ro+rd*t); if(h.x<0.0015+t*0.0003){found=true;break;} t+=max(h.x*0.8,0.001); if(t>end)break; } if(!found)return env; // A broad view-facing lobe for reflected hits: full geometry is traced, // but secondary microfacets are deliberately not evaluated a second time. vec3 n=-rd; vec3 albedo=mix(vec3(0.012,0.13,0.145),vec3(0.81,0.84,0.73),sat(h.y)); albedo=mix(albedo,vec3(0.78,0.44,0.19),sat(h.z)); vec3 color=albedo*(0.15+1.10*max(dot(n,normalize(vec3(-0.55,0.85,0.65))),0.0)); color+=vec3(0.12,0.23,0.24)*max(dot(n,normalize(vec3(0.85,0.2,-0.55))),0.0); color+=studio(reflect(rd,n),0.33)*mix(0.10,0.50,sat(h.z)); color=mix(color,vec3(1.2,0.22,0.045)+color*0.5,sat(h.w)); return color; } vec3 surface(vec3 p,vec3 n,vec3 rd,vec4 h,float ao,float sh){ float ceramicMix=sat(h.y),metalMix=sat(h.z),glow=sat(h.w); vec3 albedo=mix(vec3(0.012,0.13,0.145),vec3(0.81,0.84,0.73),ceramicMix); albedo=mix(albedo,vec3(0.78,0.44,0.19),metalMix); float metal=mix(0.46,0.10,ceramicMix);metal=mix(metal,0.92,metalMix); float rough=mix(0.25,0.28,ceramicMix);rough=mix(rough,0.25,metalMix); if(h.y< -0.5){ metal=0.5;rough=0.34;albedo=vec3(0.028,0.046,0.045); if(h.y< -1.5){metal=0.25;rough=0.36;albedo=vec3(0.018,0.030,0.034);} // A uniform satin finish stays stable through the complete orbit; // subpixel concentric grooves shimmered under grazing side lighting. } vec3 v=-rd;float nv=max(dot(n,v),0.0); vec3 f0=mix(vec3(0.045),albedo,metal); vec3 fresnel=f0+(1.0-f0)*pow(1.0-nv,5.0); vec3 key=normalize(vec3(-0.55,0.85,0.65)); vec3 color=directLight(n,v,key,albedo,f0,metal,rough)*vec3(4.0,3.6,2.95)*sh; color+=directLight(n,v,normalize(vec3(0.85,0.2,-0.55)),albedo,f0,metal,rough)*vec3(0.9,2.0,2.2)*ao; color+=directLight(n,v,normalize(vec3(0.1,-0.3,1.0)),albedo,f0,metal,rough)*vec3(0.7,0.58,0.46)*ao; 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; vec3 env=reflectedScene(p+n*0.015,reflect(rd,n),rough); color+=env*fresnel*mix(0.42,1.0,ao)*(0.9-0.35*rough); // Pearlescent clearcoat is restrained to the ivory, strongest at grazing angles. vec3 iridescence=0.5+0.5*cos(vec3(0,2.1,4.2)+nv*7.0+0.4); color+=ceramicMix*iridescence*pow(1.0-nv,3.0)*0.16*ao; vec3 heartLight=vec3(1.0,0.19,0.055)*1.5/(1.0+dot(p,p)*2.0); color+=heartLight*albedo*max(dot(n,normalize(-p+vec3(0.001))),0.0)*ao; color=mix(color,vec3(1.8,0.22,0.045)*(0.45+0.65*nv*nv)+color*0.85,glow); return color; } vec3 background(vec3 ro,vec3 rd){ float horizon=exp(-sq((rd.y+0.15)*2.8)); vec3 c=mix(vec3(0.010,0.026,0.035),vec3(0.055,0.090,0.095),horizon); float warm=pow(max(dot(rd,normalize(vec3(-0.6,0.1,-1))),0.0),8.0); return c+vec3(0.085,0.053,0.026)*warm; } vec3 render(vec2 pixel){ prepare(); vec2 uv=(pixel-0.5*RENDERSIZE)/RENDERSIZE.y; // Independent from the 32-second machinery phase: never reverse or jump // back to the starting angle when an escapement cycle completes. float orbit=TAU*mod(TIME*orbitSpeed,96.0)/96.0; vec3 ro=ry(orbit)*vec3(7.45,4.32,15.55),target=vec3(0,-0.60,0); // Keep the complete machine framed on portrait displays as well. ro*=max(1.0,0.85*RENDERSIZE.y/RENDERSIZE.x); vec3 fw=normalize(target-ro),right=normalize(cross(fw,vec3(0,1,0))),up=cross(right,fw); vec3 rd=normalize(fw*1.62+right*uv.x+up*uv.y); vec3 col=background(ro,rd); vec2 hit=march(ro,rd,65.0); // The infinite stage continues beyond the finite sculpture trace distance. if(hit.y<0.0&&rd.y< -0.0001)hit=vec2((-5.05-ro.y)/rd.y,1.0); if(hit.y>0.0){ vec3 p=ro+rd*hit.x;vec4 h=primaryMaterial; vec3 n;float ao,sh; geometryLighting(p,0.0003,n,ao,sh); col=surface(p,n,rd,h,ao,sh); float fog=1.0-exp(-max(hit.x-11.0,0.0)*0.025); col=mix(col,background(ro,rd),fog); } col*=1.0-0.12*dot(uv,uv); return max(col,0.0); } vec3 tonemap(vec3 x){return clamp((x*(2.51*x+0.03))/(x*(2.43*x+0.59)+0.14),0.0,1.0);} // Explicit bilinear filtering also works when float textures are nearest-only. vec3 filteredImage(vec2 uv){ vec2 p=uv*RENDERSIZE-0.5,cell=floor(p),f=fract(p); vec3 a=IMG_PIXEL(clockImage,clamp(cell+vec2(0.5),vec2(0.5),RENDERSIZE-0.5)).rgb; vec3 b=IMG_PIXEL(clockImage,clamp(cell+vec2(1.5,0.5),vec2(0.5),RENDERSIZE-0.5)).rgb; vec3 c=IMG_PIXEL(clockImage,clamp(cell+vec2(0.5,1.5),vec2(0.5),RENDERSIZE-0.5)).rgb; vec3 d=IMG_PIXEL(clockImage,clamp(cell+vec2(1.5),vec2(0.5),RENDERSIZE-0.5)).rgb; return mix(mix(a,b,f.x),mix(c,d,f.x),f.y); } vec3 antialias(vec2 uv){ vec2 px=1.0/RENDERSIZE;vec3 lum=vec3(0.299,0.587,0.114); vec3 center=filteredImage(uv); float nw=dot(filteredImage(uv+vec2(-1,1)*px),lum),ne=dot(filteredImage(uv+px),lum); float sw=dot(filteredImage(uv-px),lum),se=dot(filteredImage(uv+vec2(1,-1)*px),lum); 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))); if(hi-lo<max(0.015,hi*0.08))return center; vec2 dir=vec2(-((nw+ne)-(sw+se)),(nw+sw)-(ne+se)); float reduce=max((nw+ne+sw+se)*0.03125,0.0078125); dir=clamp(dir/(min(abs(dir.x),abs(dir.y))+reduce),-6.0,6.0)*px; vec3 a=0.5*(filteredImage(uv-dir/6.0)+filteredImage(uv+dir/6.0)); vec3 b=a*0.5+0.25*(filteredImage(uv-dir*0.5)+filteredImage(uv+dir*0.5)); float lb=dot(b,lum);return lb<lo||lb>hi?a:b; } void main(){ if(PASSINDEX==0){gl_FragColor=vec4(render(gl_FragCoord.xy),1.0);return;} vec2 uv=gl_FragCoord.xy/RENDERSIZE; // Full, contiguous separable kernels avoid the repeated glint copies that // sparse radial bloom taps can leave around narrow metallic geometry. if(PASSINDEX==1||PASSINDEX==2){ vec3 sum=vec3(0);float total=0.0; for(int i=0;i<25;i++){ float offset=float(i)-12.0,w=exp(-offset*offset/40.0); vec2 p=gl_FragCoord.xy+(PASSINDEX==1?vec2(offset,0):vec2(0,offset)); p=clamp(p,vec2(0.5),RENDERSIZE-0.5); vec3 tap; if(PASSINDEX==1)tap=max(IMG_PIXEL(clockImage,p).rgb-0.85,0.0); else tap=IMG_PIXEL(haloHorizontal,p).rgb; sum+=tap*w;total+=w; } gl_FragColor=vec4(sum/total,1);return; } vec3 color=antialias(uv); color+=IMG_NORM_PIXEL(haloVertical,uv).rgb*bloomAmount*0.23; color=pow(tonemap(color*exposure),vec3(1.0/2.2)); color+=(hash(gl_FragCoord.xy)-0.5)/255.0; gl_FragColor=vec4(color,1.0); }
forking #h0795jlv — lineage will be recorded.
renders in YOUR browser. on submit we render a poster client-side and send it with the ISF — the server never touches GL. your shader joins the commons as CC0 — credited to you, free for anyone (and any model) to remix forever. that's the whole point. it's permanent: once it's public, CC0 has no take-backs. by submitting you attest you have the right to release it as CC0.