// DSBH Regular License hero background: Home's glass engine over this hero's colour field and panes (WebGL fragment // shader). Loaded by the hero glass block in regular-license/rl.js (the shared Home code, home/home.js#glass). // GENERATED by regular-license/figma/glass/make-shader.py from the hero picture (Figma image 1655:2564; do not edit by hand). // The engine (the REFR.. constants, gPar, hash/noise/fbm/blob, sdPanel, glass) is copied verbatim from home/glass.frag; // regular-license/build.mjs warns when the two drift apart. This file's own parts: the frame, the colour field (bg) and // the nine panes (main). precision highp float; uniform vec2 uRes;uniform float uScale,uPx,uTime;uniform vec2 uMouse; // Frame: the scene is the hero picture (1440 x 867), 1.79 x 1.0777 units, framed like the (object-fit: cover, // object-position: 50% 100%, so measured from the bottom), and the canvas lands on the picture at every size. The shared script // measures the pointer from the bottom in its own frame (uScale); frame() moves it, and the pixel size, into ours. const float ASPECT=1.79,TALL=1.0777; float S,nPx;vec2 nMouse; void frame(){S=max(uRes.x/ASPECT,uRes.y/TALL);nPx=uPx*uScale/S;nMouse=vec2((uMouse.x-.5*ASPECT)*uScale/S+.5*ASPECT,uMouse.y*uScale/S);} #define uPx nPx #define uMouse nMouse const vec3 GLOW=vec3(.93,.97,1.); const float REFR=.51,LIQ=1.55,RIMW=1.3,RIM=.65,FILL=.10,LDEG=-45.,LIGHT=.80; vec2 gPar; float hash(vec2 p){p=fract(p*vec2(123.34,456.21));p+=dot(p,p+45.32);return fract(p.x*p.y);} float noise(vec2 p){vec2 i=floor(p),f=fract(p);f=f*f*(3.-2.*f);return mix(mix(hash(i),hash(i+vec2(1,0)),f.x),mix(hash(i+vec2(0,1)),hash(i+vec2(1,1)),f.x),f.y);} float fbm(vec2 p){float a=.5,s=0.;for(int i=0;i<3;i++){s+=a*noise(p);p=p*2.03+17.1;a*=.5;}return s;} float blob(vec2 p,vec2 c,vec2 st,float r2){vec2 d=(p-c)*st;return exp(-dot(d,d)/r2);} // The colour field: the picture (panes filled in) as a 8 x 12 cosine series per channel, cos(i pi x / ASPECT) cos(j pi y / TALL), // in mat4 blocks; the cosines come from the Chebyshev recurrence. const mat4 R00=mat4(.8801,.0316,-.0284,-.0061,-.1547,.02,-.0066,-.0276,-.0432,.0153,.0296,-.0248,-.0141,.0607,.0012,.0054); const mat4 R01=mat4(.0009,.0238,.0005,.0115,.0134,-.0202,.0091,.0063,.0103,-.0107,-.0005,.0054,.0076,-.0023,-.0031,.0006); const mat4 R02=mat4(.0046,-.0032,-.0013,-.0024,.001,-.0015,-.0014,-.0014,.0008,-.0004,-.0008,-.0002,.001,-.0003,-.0002,.0002); const mat4 R10=mat4(.0002,-.0092,.006,-.0004,.0081,-.015,.0089,.0003,.0076,-.0076,.0061,-.0019,-.0092,-.0003,.0026,-.0037); const mat4 R11=mat4(-.0131,.004,-.0036,.0003,-.0038,.0033,-.0032,.001,.0013,.0013,.0005,-.0012,.0003,.0009,.0007,-.0012); const mat4 R12=mat4(-.0013,.0001,-.0003,-.0003,-.0002,-.0007,-.0006,.0002,.0009,-.001,-.0003,.0003,.001,-.0019,.0007,.0006); const mat4 G00=mat4(.9122,.0445,-.0127,-.0112,-.1058,.0373,-.0055,-.0181,-.0129,-.0059,.0083,-.0047,.0038,.0184,-.0014,.0045); const mat4 G01=mat4(.0008,.0142,.0028,.0027,.0067,-.0085,.006,.0037,.006,-.0057,-.0007,.0045,.0035,-.0013,-.0011,.0004); const mat4 G02=mat4(.0023,-.0026,-.0001,-.0008,.0008,-.0013,-.0009,-.0002,.0005,-.0001,-.0003,-.0004,.0006,-.0001,-.0001,-.0001); const mat4 G10=mat4(.0004,-.0039,.003,-.0005,.0025,-.0069,.004,.0001,.0029,-.0045,.0021,0.,-.0016,-.001,.0011,-.0013); const mat4 G11=mat4(-.0046,.0017,-.0005,-.0004,-.0031,.0014,-.0007,.0002,-.0002,.0004,-.0001,-.0003,.0002,.0006,.0001,-.0005); const mat4 G12=mat4(-.0007,-.0002,.0005,-.0002,.0002,-.001,.0002,.0002,.0007,-.0007,-.0002,.0001,.0005,-.0011,.0004,0.); const mat4 B00=mat4(.9034,.0541,-.0072,-.0121,-.1017,.035,.0001,-.0116,.0139,-.0308,.0073,.0061,.0195,.0028,-.0021,.004); const mat4 B01=mat4(-.0005,.013,.0024,-.0034,.002,-.0067,.0046,.0013,.0031,-.0039,-.001,.004,.0016,.0014,-.0004,-.0003); const mat4 B02=mat4(.0016,-.001,.0008,-.0013,.0005,-.0013,-.0008,.0001,.0002,-.0002,-.0005,-.0001,.0007,.0002,.0004,-.0003); const mat4 B10=mat4(-.0026,0.,.0014,-.0003,-.0034,-.0016,.0007,.0009,.0002,-.0031,-.0007,.001,.0009,-.0018,.0005,-.0011); const mat4 B11=mat4(-.002,.0006,.0008,-.0007,-.0028,.0008,.0004,.0004,.0004,-.0002,-.0003,.0003,.0011,-.0001,-.0004,-.0005); const mat4 B12=mat4(-.0009,-.0004,.0005,-.0005,-.0003,-.0013,.0011,.0001,.001,-.0007,.0003,.0001,.0006,-.0003,.0003,-.0002); vec3 field(vec2 w){float a=cos(3.14159265*w.x/ASPECT),b=cos(3.14159265*w.y/TALL);vec4 X0;vec4 X1;vec4 Y0;vec4 Y1;vec4 Y2; X0=vec4(1.,a,2.*a*a-1.,0.);X0.w=2.*a*X0.z-X0.y;X1.x=2.*a*X0.w-X0.z;X1.y=2.*a*X1.x-X0.w;X1.z=2.*a*X1.y-X1.x;X1.w=2.*a*X1.z-X1.y;Y0=vec4(1.,b,2.*b*b-1.,0.);Y0.w=2.*b*Y0.z-Y0.y;Y1.x=2.*b*Y0.w-Y0.z;Y1.y=2.*b*Y1.x-Y0.w;Y1.z=2.*b*Y1.y-Y1.x;Y1.w=2.*b*Y1.z-Y1.y;Y2.x=2.*b*Y1.w-Y1.z;Y2.y=2.*b*Y2.x-Y1.w;Y2.z=2.*b*Y2.y-Y2.x;Y2.w=2.*b*Y2.z-Y2.y; return vec3(dot(X0,R00*Y0)+dot(X0,R01*Y1)+dot(X0,R02*Y2)+dot(X1,R10*Y0)+dot(X1,R11*Y1)+dot(X1,R12*Y2),dot(X0,G00*Y0)+dot(X0,G01*Y1)+dot(X0,G02*Y2)+dot(X1,G10*Y0)+dot(X1,G11*Y1)+dot(X1,G12*Y2),dot(X0,B00*Y0)+dot(X0,B01*Y1)+dot(X0,B02*Y2)+dot(X1,B10*Y0)+dot(X1,B11*Y1)+dot(X1,B12*Y2));} // The drift (warp, slow waves across the bands) grows in over the first 8 s and the pointer's pull and glow over 2.5 s, so // the first frame is the picture and the fade-in is seamless. vec3 bg(vec2 p){float t=uTime,k=min(t*.125,1.),kp=min(t*.4,1.); vec2 w=p+.12*k*(vec2(fbm(p*1.1+vec2(t*.05,-t*.04)),fbm(p*1.1+vec2(-t*.045,t*.05)+9.7))-.44); w.y+=.03*k*sin(w.x*2.3+t*.27)+.02*k*sin(w.x*1.4-t*.21+1.3); vec2 dm=w-uMouse;w-=dm*exp(-dot(dm,dm)*5.)*.38*kp; vec3 c=clamp(field(w),0.,1.); vec2 d0=p-uMouse;return mix(c,GLOW,.22*kp*exp(-dot(d0,d0)*9.));} float sdPanel(vec2 p,vec4 r,float k){float cx=.5*(r.x+r.y),hw=.5*(r.y-r.x);float y=p.y-(r.z+k*(p.x-r.x))+.5*r.w; vec2 d=vec2(abs(p.x-cx)-hw,(abs(y)-.5*r.w)/sqrt(1.+k*k));return min(max(d.x,d.y),0.)+length(max(d,0.));} void glass(inout vec3 col,vec2 q,vec4 r,float k,float depth,float ph){ vec2 sh=gPar*depth+vec2(0.,.009*sin(uTime*.55+ph));vec2 p=q-sh;float d=sdPanel(p,r,k);float bw=RIMW/1.4; if(d>(1.+4.*max(bw,1.))*uPx)return; float hov=smoothstep(.03,-.03,sdPanel(uMouse-sh,r,k)); vec2 uv=vec2((p.x-r.x)/(r.y-r.x),(r.z+k*(p.x-r.x)-p.y)/r.w); float la=radians(90.-LDEG);vec2 Ld=normalize(vec2(cos(la),sin(la))+.45*gPar); vec2 e=vec2(2.*uPx,0.);vec2 n=normalize(vec2(sdPanel(p+e.xy,r,k)-sdPanel(p-e.xy,r,k),sdPanel(p+e.yx,r,k)-sdPanel(p-e.yx,r,k))+1e-6); float lens=clamp(1.+d/.032,0.,1.);lens*=lens;vec2 off=-n*.044*REFR*(1.+.6*hov)*lens; float inside=smoothstep(0.,-10.*uPx,d);vec2 lp=p/uPx; off+=LIQ*inside*(1.+.5*hov)*uPx*vec2(8.*sin(lp.y*.045-uTime*.9+ph),22.*sin(lp.x*.028+uTime*.7+ph+.5*sin(lp.y*.03-uTime*.5))); vec3 g=bg(q+off);float facing=dot(n,Ld); g=mix(g,vec3(1.),FILL+.06*hov); vec2 c=(uv-.5)*2.;float along=dot(c,normalize(vec2(Ld.x,-Ld.y))); float lw=smoothstep(.05,1.1,abs(along))*(.35+.65*abs(facing)); float s=fract((p.x*.6+p.y)*.9-uTime*.035+ph*.1);float sweep=smoothstep(.14,0.,abs(s-.5)); vec2 dq=q-uMouse;float near=exp(-dot(dq,dq)*12.);float breathe=.90+.10*sin(uTime*.7+ph); float rimLight=clamp(LIGHT*lw*breathe+.40*sweep+.50*near+.20*hov,0.,1.); g=mix(g,vec3(1.),.28*exp(d/.014)*rimLight);g+=.04*sweep; col=mix(col,g,smoothstep(uPx,-uPx,d)); float core=smoothstep(bw*uPx,0.,abs(d)),halo=.22*smoothstep(4.*bw*uPx,0.,abs(d)); col=mix(col,vec3(1.),clamp((core+halo)*(.05+.95*rimLight)*RIM/.95,0.,1.));} void main(){frame();vec2 q=vec2((gl_FragCoord.x-.5*uRes.x)/S+.5*ASPECT,gl_FragCoord.y/S);gPar=uMouse-vec2(.5*ASPECT,.5*TALL); vec3 col=bg(q); glass(col,q,vec4(-.0497,.2001,.5193,.1883),-.295,.03,0.);glass(col,q,vec4(.2001,.5128,.2511,.1585),.295,.03,0.);glass(col,q,vec4(.7284,.9273,.4835,.1921),-.303,.04,2.1);glass(col,q,vec4(.9261,1.2387,.2312,.1591),.295,.04,2.1);glass(col,q,vec4(1.35,1.5507,.4717,.1896),-.294,.03,4.2);glass(col,q,vec4(1.5507,1.8894,.22,.1591),.299,.03,4.2); glass(col,q,vec4(-.0622,.5221,.1672,.1653),-.3,.07,1.);glass(col,q,vec4(.5221,1.1063,.1902,.1659),-.297,.075,3.);glass(col,q,vec4(1.1436,1.7278,.1784,.1579),-.29,.07,5.); col+=(hash(gl_FragCoord.xy+fract(uTime))-.5)*(1.5/255.);gl_FragColor=vec4(col,1.);}