Deck.transition('line', { dur: 1.45, frag: `void main(){ if(p<=0.){o=texture(tA,vUv);return;} if(p>=1.){o=texture(tB,vUv);return;} float y=vUv.y-.5; float a=1.-smoothstep(0.,.51,p); float b=smoothstep(.49,1.,p); float spread=p<.5?a:b; vec2 uv=vec2(vUv.x,.5+y/max(spread,.001)); float edge=1.-smoothstep(-.002,.003,abs(y)-.5*spread); vec3 frame=p<.5?texture(tA,clamp(uv,0.,1.)).rgb:texture(tB,clamp(uv,0.,1.)).rgb; float flare=pow(max(0.,1.-2.*abs(p-.5)),2.5); float slit=exp(-abs(y)*820.)+.23*exp(-abs(y)*92.); vec3 dark=vec3(.018,.021,.024)*sin(p*3.141593); o=vec4(mix(dark,frame,edge)+vec3(.98,.75,.47)*slit*flare,1.); }` }); Deck.scene({ id:'aim', title:'Aim', enterWith:'line', post:{tone:'aces',exposure:1,bloom:.57,threshold:1,vignette:.22,grain:.022}, beats:[{dur:2.4,hold:4},{dur:4.2,hold:4},{dur:4.8,hold:5},{dur:5,hold:5}], notes:[ 'Everything so far assumed one thing: that it aims where we meant it to. Alignment is the question of what it actually wants.', 'Suppose we get it almost right. One degree off. At ten metres that is seventeen centimetres. Every demo and every test happens at ten metres.', 'But the same degree keeps going. At the Moon you miss by about 6,700 kilometres, almost two whole Moons. At the nearest star you miss by 4,700 times the distance from the Earth to the Sun. It is only geometry: the tangent of one degree times the distance.', 'The lines are still pointing almost the same way. But out here, they end up in very different places. So which line do we want to follow?' ], setup(d){ return { U:{uClose:0,uShot:0,uSpace:0,uFar:0,uMouse:[0,0]}, paper:'#f7e9d3', blue:'#a5d8fa', bg:d.pass(` uniform float uClose,uShot,uSpace,uFar; uniform vec2 uMouse; const vec3 Amber=vec3(1.,.60,.28); const vec3 Ice=vec3(.27,.62,1.); float ink(float v,float w){return 1.-smoothstep(w,w+1.35,abs(v));} float disk(float dist,float r){return 1.-smoothstep(r-.8,r+.8,dist);} float aimWindow(vec2 s){ vec2 z=vec2(mod(s.x+2.2,4.4)-2.2,s.y); return max(1.34-z.y,max(abs(z.x)-1.16,length(vec2(z.x,max(z.y-3.76,0.)))-1.16)); } float lattice(vec2 s){ vec2 z=vec2(mod(s.x+2.2,4.4)-2.2,s.y); float a=abs(fract(z.x/.385+.5)-.5)*.385; float b=abs(fract((z.y-1.34)/.51+.5)-.5)*.51; return smoothstep(.016,.041,min(a,b)); } vec3 hall(vec2 q){ float cx=mix(1110.,1280.,uClose); vec3 ro=vec3(uMouse.x*.10,1.65+uMouse.y*.035,3.5*uClose); vec3 rd=vec3((q.x-cx)/920.,(496.-q.y)/920.,1.); float tw=(sign(rd.x)*4.8-ro.x)/(sign(rd.x)*max(abs(rd.x),.0001)+.0000001); if(abs(rd.x)<.0001)tw=10000.; float ty=(mix(0.,5.65,step(0.,rd.y))-ro.y)/(sign(rd.y)*max(abs(rd.y),.0001)+.0000001); if(abs(rd.y)<.0001)ty=10000.; float tz=23.-ro.z; float t=min(min(tw,ty),tz); vec3 h=ro+rd*t; vec3 c=vec3(.117,.086,.066); if(t==ty && rd.y<0.){ float pl=floor(h.x/.47); float seam=smoothstep(.004,.021,abs(fract(h.x/.47)-.5)*.47); float joint=smoothstep(.007,.034,abs(fract(h.z/3.7+hash12(vec2(pl,8.)))-.5)*3.7); float grain=vnoise(vec2(h.x*26.,h.z*2.3)); c=vec3(.217,.133,.075)*(.7+.38*hash12(vec2(pl,2.))+.18*grain)*(.6+.4*seam)*(.76+.24*joint); }else if(t==ty){ float rafter=smoothstep(.07,.13,abs(fract(h.z/2.2)-.5)*2.2); c=vec3(.079,.059,.048)*(.48+.52*rafter); }else if(t==tw){ float postMask=smoothstep(.08,.15,abs(fract((h.z+2.2)/4.4)-.5)*4.4); float rail=smoothstep(.04,.09,abs(h.y-1.19)); c=vec3(.17,.117,.077)*(.63+.28*vnoise(vec2(h.z*4.,h.y*16.)))*(.55+.45*rail); c*=.75+.25*postMask; float w=aimWindow(h.zy); float glaze=1.-smoothstep(-.035,.016,w); float bars=lattice(h.zy); float right=step(0.,h.x); vec3 skyCol=mix(vec3(.26,.34,.39),vec3(.87,.57,.31),right); skyCol*=.78+.26*smoothstep(1.4,4.7,h.y)+.10*vnoise(h.zy*.74); c=mix(c,skyCol*(.15+.85*bars),glaze); c=mix(c,vec3(.064,.046,.037),(.7+.3*postMask)*(1.-smoothstep(.013,.068,abs(w)))); c+=right*vec3(.50,.33,.17)*exp(-abs(w+.033)*94.)*bars; }else{ float beam=smoothstep(.025,.076,abs(fract(h.x/1.36)-.5)*1.36); c=vec3(.15,.108,.079)*(.68+.32*beam)*(.88+.17*vnoise(h.xy*18.)); c*=.65+.35*smoothstep(.8,1.3,h.y); } vec3 sun=vec3(1.,.60,.31); vec3 hit=h+sun*((4.8-h.x)/sun.x); float win=1.-smoothstep(-.09,.11,aimWindow(hit.zy)); if(t!=tw) c+=Amber*.32*win*(.42+.58*lattice(hit.zy))*exp(-.06*(4.8-h.x)); c=mix(c,vec3(.109,.103,.093),1.-exp(-t*.020)); float shafts=0.; for(int i=0;i<5;i++){ vec3 v=ro+rd*t*(float(i)+.5)/5.; vec3 w=v+sun*(4.8-v.x); float gate=1.-smoothstep(-.23,.12,aimWindow(w.zy)); shafts+=gate*(.68+.32*lattice(w.zy))*smoothstep(2.,5.,w.z)*(1.-smoothstep(18.,23.,w.z)); } c+=Amber*shafts*.037*exp(-abs(q.x-1330.)/1130.); c*=mix(.66,1.,smoothstep(410.,1160.,q.x)); vec2 dust=q+vec2(uTime*3.3,-uTime*2.2); vec2 cell=floor(dust/34.); float rnd=hash12(cell); vec2 mote=fract(dust/34.)-vec2(rnd,hash12(cell+19.)); c+=Amber*.15*exp(-dot(mote,mote)*340.)*step(.86,rnd)*sat(shafts*.39); vec2 tc=vec2(mix(1304.,1348.,uClose),mix(532.,535.,uClose))-uMouse*vec2(6.,3.); float R=mix(76.,223.,uClose); vec2 p=(q-tc)/R; float legY=step(.36,p.y)*(1.-smoothstep(1.52,1.57,p.y)); float legs=(1.-smoothstep(.021,.043,abs(abs(p.x)-(.25+.205*p.y))))*legY; float brace=(1.-smoothstep(.022,.043,abs(p.y-1.24)))*(1.-smoothstep(.45,.55,abs(p.x))); c=mix(c,vec3(.16,.091,.05),max(legs,brace)); c+=Amber*.17*legs*(1.-smoothstep(.009,.025,abs(abs(p.x)-(.232+.205*p.y)))); float rho=length(p*vec2(1.02,1.)); float shadow=disk(length((q-tc-vec2(8.,14.))*vec2(1.02,1.)),R+4.); c*=1.-.26*shadow; vec3 paper=vec3(.63,.52,.35); paper=mix(paper,vec3(.066,.089,.09),1.-smoothstep(.72,.733,rho)); paper=mix(paper,vec3(.23,.36,.42),1.-smoothstep(.54,.552,rho)); paper=mix(paper,vec3(.53,.199,.108),1.-smoothstep(.365,.376,rho)); paper=mix(paper,vec3(.92,.57,.13),1.-smoothstep(.184,.196,rho)); paper*=.91+.12*vnoise(q*vec2(.57,.32))+.04*hash12(floor(q*1.1)); paper*=.94+.12*(-p.x-p.y); paper=mix(paper,vec3(.39,.24,.115),smoothstep(.956,.974,rho)); paper+=Amber*.33*exp(-abs(rho-.968)*180.)*sat(.43-p.x-p.y); c=mix(c,paper,disk(rho*R,R)); if(uShot>.001){ float xa=430., ya=620.; float reach=mix(xa,tc.x+94.,uShot); float line1=mix(ya,tc.y,(q.x-xa)/(tc.x-xa)); float line2=mix(ya,tc.y,(q.x-xa)/(tc.x+94.-xa)); float along=smoothstep(xa,xa+146.,q.x); c+=Ice*(.44*ink(q.y-line1,.65)+.11*exp(-abs(q.y-line1)*.27))*along*(1.-smoothstep(min(reach,tc.x),min(reach,tc.x)+3.,q.x)); c+=Amber*(1.55*ink(q.y-line2,1.)+.20*exp(-abs(q.y-line2)*.24))*along*(1.-smoothstep(reach,reach+3.,q.x)); c+=Amber*2.1*exp(-length(q-vec2(reach,mix(ya,tc.y,(reach-xa)/(tc.x+94.-xa))))*.22)*uShot; } return c; } vec3 cosmos(vec2 q){ vec2 m=q+uMouse*vec2(9.,5.); float band=exp(-pow((m.y-700.+.235*(m.x-960.))/245.,2.)); float cloud=fbm(m*vec2(.0028,.0046)+vec2(4.3,uTime*.002)); vec3 c=vec3(.014,.020,.037)+vec3(.053,.076,.13)*band*(.25+.9*cloud); c+=vec3(.062,.041,.046)*cloud*exp(-length((m-vec2(1700.,310.))/vec2(770.,270.))); for(int i=0;i<2;i++){ vec2 g=m/(31.+float(i)*32.)+float(i)*27.; vec2 id=floor(g); float r=hash12(id); vec2 xy=(fract(g)-vec2(.15+.7*r,.15+.7*hash12(id+9.)))*(31.+float(i)*32.); float dr=length(xy); c+=mix(vec3(.54,.73,1.),vec3(1.,.83,.65),r)*step(.91+float(i)*.04,r)* (.15+.53*r)*exp(-dr*dr/(.8+float(i)*1.75))*(.84+.16*sin(uTime*.46+r*470.)); } float moonFade=1.-smoothstep(0.,.78,uFar); vec2 mc=vec2(1322.+440.*uFar,550.+198.*uFar)-uMouse*vec2(9.,5.); float mr=mix(159.,85.,uFar); vec2 p=(q-mc)/mr; float rr=dot(p,p); if(rr<1.015 && moonFade>.001){ vec3 n=vec3(p,sqrt(max(0.,1.-rr))); float light=sat(dot(n,normalize(vec3(-.57,-.42,.76)))); float maria=fbm(p*4.2+4.); float tex=vnoise(p*49.); float cr=0.; for(int i=0;i<13;i++){ float f=float(i); vec2 id=vec2(f,3.); vec2 cp=vec2(hash12(id),hash12(id+17.))*1.72-.86; float rad=.045+.149*hash12(id+37.); vec2 rel=p-cp; float u=length(rel)/rad; cr+=.16*exp(-pow((u-.86)*7.,2.))*(-.28+dot(normalize(rel+vec2(.00001)),vec2(.66,.47))) -.17*(1.-smoothstep(.47,.80,u)); } vec3 rock=vec3(.56,.57,.55)*(.12+.91*light)*(.71+.36*maria+.12*tex+cr); rock+=vec3(.083,.113,.17)*pow(sat(1.-n.z),4.); c=mix(c,rock,disk(sqrt(rr)*mr,mr)*moonFade); } float yA=mix(548.,603.,uFar); float yB=mix(339.,223.,uFar); float x=q.x-1322.; float a=yA+x*mix(-.018,.027,uFar); float b=yB-x*mix(.18,.282,uFar); float run=smoothstep(-40.,370.,q.x)*smoothstep(q.x-40.,q.x+12.,uSpace*2100.); c+=run*(Ice*(.85*ink(q.y-a,.77)+.14*exp(-abs(q.y-a)*.19)) + Amber*(1.27*ink(q.y-b,1.)+.17*exp(-abs(q.y-b)*.19))); float ring=length(q-vec2(1322.,548.)); float ret=ink(ring-38.,1.)+.6*ink(ring-49.,.6)*step(.26,min(abs(q.x-1322.),abs(q.y-548.))/49.); c+=Ice*(.89*ret+1.45*exp(-ring*.32))*moonFade*smoothstep(.55,.86,uSpace); vec2 sp=vec2(1472.,603.+150.*.027); vec2 ss=q-sp; float sr=length(ss); float star=smoothstep(.26,.95,uFar); vec3 hot=vec3(1.,.74,.42); c+=star*hot*(.47*exp(-sr/66.)+.73*exp(-sr/14.)+5.1*disk(sr,7.)); c+=star*hot*.86*(exp(-abs(ss.x)*.37-abs(ss.y)*.035)+exp(-abs(ss.y)*.51-abs(ss.x)*.024)); c+=star*Ice*.39*ink(sr-46.,.65); return c; } void main(){ vec2 q=design(vUv); vec3 c; if(uSpace<=.001)c=hall(q); else if(uSpace>=.999)c=cosmos(q); else { float edge=uSpace*2470.-230.; float swept=1.-smoothstep(edge-180.,edge+160.,1920.-q.x+.12*(q.y-540.)); c=mix(hall(q),cosmos(q),swept); c+=vec3(.27,.34,.43)*.13*sin(swept*3.141593); } o=vec4(c,1.); }`,'Aim — late light and long sightlines') }; }, bracket(d,x0,y0,x1,y1,alpha){ if(alpha<=.001)return; const c=d.ctx2d, vert=Math.abs(x1-x0)<1; const tx=vert?9:0, ty=vert?0:9; c.save(); c.globalAlpha=alpha; c.strokeStyle='#a5d8fa'; c.fillStyle='#a5d8fa'; c.lineWidth=1.7; c.beginPath(); c.moveTo(x0,y0);c.lineTo(x1,y1); c.moveTo(x0-tx,y0-ty);c.lineTo(x0+tx,y0+ty); c.moveTo(x1-tx,y1-ty);c.lineTo(x1+tx,y1+ty); c.stroke(); c.beginPath();c.arc(x0,y0,3.1,0,Math.PI*2);c.arc(x1,y1,3.1,0,Math.PI*2); c.restore(); }, draw(s,d,r){ const E=d.E,U=r.U,c=d.ctx2d; U.uClose=s.k(1,0,2.75,E.io3); U.uShot=s.k(1,2.35,3.22,E.out3); U.uSpace=s.k(2,.14,3.48,E.io3); U.uFar=s.k(3,0,5,E.io3); U.uMouse[0]=s.mouse.x;U.uMouse[1]=s.mouse.y; r.bg.draw(U); const bowAlpha=1-s.k(1,.14,1.56); if(bowAlpha>.001){ c.save(); c.globalAlpha=bowAlpha; c.translate(751-U.uMouse[0]*10-75*U.uClose,540-U.uMouse[1]*5); c.rotate(.023+.006*Math.sin(s.t*.77)); c.lineCap='round'; c.lineJoin='round'; c.beginPath(); c.moveTo(27,-394); c.bezierCurveTo(-57,-357,9,-214,5,-128); c.bezierCurveTo(1,-71,-15,-17,-7,33); c.bezierCurveTo(9,122,-9,216,-31,268); c.lineWidth=17;c.strokeStyle='#2e2119';c.stroke(); c.lineWidth=9;c.strokeStyle='#905d36';c.stroke(); c.save();c.translate(-2,-2);c.lineWidth=3;c.strokeStyle='#cd9b63';c.stroke();c.restore(); c.beginPath();c.moveTo(27,-394);c.lineTo(-197,0);c.lineTo(-31,268); c.lineWidth=1.6;c.strokeStyle='#d7c4a6';c.stroke(); c.beginPath();c.moveTo(-12,-12);c.quadraticCurveTo(-13,12,-6,38); c.lineWidth=19;c.strokeStyle='#41342a';c.stroke(); c.lineWidth=2;c.strokeStyle='#ae9370'; for(let i=0;i<8;i++){ const x=-11+i*.57, y=-9+i*6; c.beginPath();c.moveTo(x-7,y);c.lineTo(x+8,y+2);c.stroke(); } c.beginPath();c.moveTo(-210,0);c.lineTo(153,0); c.lineWidth=3.1;c.strokeStyle='#c7aa80';c.stroke(); c.beginPath();c.moveTo(164,0);c.lineTo(149,-4);c.lineTo(149,4);c.closePath(); c.fillStyle='#d7c8ad';c.fill(); c.beginPath();c.moveTo(-196,0);c.lineTo(-214,-9);c.lineTo(-178,-5);c.lineTo(-168,0); c.lineTo(-182,5);c.lineTo(-205,7);c.closePath(); c.fillStyle='#997454';c.fill(); c.restore(); } d.text('What does\nit want?',{ x:144,y:167,size:105,color:r.paper,show:s.k(0,.28,1.58,E.lin),hide:s.k(1,0,.65,E.lin) }); d.text('Miss by\none degree.',{ x:144,y:167,size:102,color:r.paper,show:s.k(1,.85,2.12,E.lin),hide:s.k(2,0,.65,E.lin) }); const m=s.k(1,3.16,4.2,E.lin)*(1-s.k(2,0,.72,E.lin)); if(m>.001){ const x=1348-U.uMouse[0]*6, y=817-U.uMouse[1]*3; c.save(); c.globalAlpha=.48*m;c.strokeStyle=r.blue;c.lineWidth=1; c.beginPath(); c.moveTo(x,770);c.lineTo(x,y-10); c.moveTo(x+94,770);c.lineTo(x+94,y-10); c.stroke();c.restore(); this.bracket(d,x,y,x+94,y,m); d.text('10 metres: 17 cm',{x:x+47,y:y+25,size:28,align:'center',font:'mono',color:r.paper,alpha:m}); } const lunar=s.k(2,3.57,4.76,E.lin)*(1-s.k(3,0,1.05,E.lin)); if(lunar>.001){ const x=1530, f=U.uFar; const y0=339-116*f-(x-1322)*(.18+.102*f); const y1=548+55*f+(x-1322)*(-.018+.045*f); this.bracket(d,x,y0,x,y1,lunar); d.text('6,700 km',{x:x+23,y:(y0+y1)/2-17,size:33,font:'mono',color:r.paper,alpha:lunar}); } } });