Deck.transition('line',{dur:1.2,frag:`void main(){ float w=smoothstep(0.,.4,p)*smoothstep(1.,.6,p); float yy=.5+.006*sin(vUv.x*38.); float d=abs(vUv.y-yy); float col=.9*exp(-d*30.)*w; vec3 a=texture(tA,vec2(vUv.x,mix(vUv.y,.5,col))).rgb; vec3 b=texture(tB,vUv).rgb; vec3 c=mix(a,b,smoothstep(.3,.8,p)); float l=exp(-d*220.)*w; c+=vec3(1.,.86,.62)*(l*1.5+exp(-d*26.)*w*.25); o=vec4(c,1.); }`}); Deck.scene({ id:'aim', title:'Aim', enterWith:'line', post:{bloom:.9,threshold:1,vignette:.28,grain:.035}, beats:[{dur:5,hold:4},{dur:5,hold:5},{dur:6,hold:5},{dur:5,hold:6}], 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.', 'So the question is not whether it can hit a target. It is where the line points when nobody is checking. One degree is all it takes, and one degree is exactly what we will not notice.' ], setup(d){ return { hall:d.pass(`uniform float uCam,uBeam,uSpace,uMoon,uLine,uReticle,uStar,uLabel; uniform vec2 uM; void main(){ vec2 q=design(vUv); q+=uM*vec2(9.,5.); vec2 C=vec2(1180.,620.); float k=1.+.45*uCam; vec2 g=C+(q-C)/k; // ---------------- the hall ---------------- float floorY=900.; vec3 wall=mix(vec3(.075,.056,.043),vec3(.23,.17,.115),sat((g.x-120.)/1150.)); wall*=.72+.48*sat(g.y/900.); vec3 c=wall; for(int i=0;i<4;i++){ float cx=900.+250.*float(i); float dx=g.x-cx; float body=sdBox(vec2(dx,g.y-520.),vec2(88.,280.)); float arch=length(vec2(dx,g.y-240.))-88.; float m=smoothstep(2.5,-2.5,min(body,arch)); if(m>0.001){ float gx=abs(fract(dx/44.)-.5)*44.; float gy=abs(fract(g.y/62.)-.5)*62.; float bars=max(smoothstep(4.,1.5,gx),smoothstep(4.,1.5,gy)); vec3 lc=vec3(1.35,.88,.48)*(.42+.8*sat((720.-g.y)/620.)); lc*=.90+.18*fbm(g*.05); c=mix(c,mix(lc,vec3(.055,.042,.032),bars),m); } } vec2 sdir=normalize(vec2(-.42,1.)); for(int i=0;i<4;i++){ float cx=900.+250.*float(i); vec2 a0=vec2(cx,640.); float t=dot(g-a0,sdir); vec2 perp=g-a0-sdir*t; float b=exp(-dot(perp,perp)/(2.*120.*120.))*smoothstep(-200.,200.,t)*smoothstep(1250.,400.,t); c+=vec3(1.,.72,.42)*.10*b; } float fl=smoothstep(floorY-2.,floorY+2.,g.y); vec3 flr=vec3(.185,.112,.060); float bd=abs(fract((g.y-floorY)/54.)-.5)*54.; flr*=.78+.4*smoothstep(22.,0.,bd); float seam=abs(fract(g.x/230.)-.5)*230.; flr*=.86+.24*smoothstep(16.,0.,seam); c=mix(c,flr,fl); // the paper target on its stand vec2 tc=vec2(1180.,620.); float R=170.; float dr=length(g-tc); c*=1.-.5*exp(-pow(dr/280.,2.)); float post=sdBox(vec2(g.x-1180.,g.y-845.),vec2(13.,56.)); float bs=sdBox(vec2(g.x-1180.,g.y-898.),vec2(95.,14.)); c=mix(c,vec3(.095,.062,.040),smoothstep(2.,-2.,min(post,bs))); float paper=smoothstep(2.5,-2.5,dr-R); float band=fract(dr/R*3.4+.5); vec3 pc=mix(vec3(.88,.84,.72),vec3(.60,.14,.10),step(.45,band)); pc=mix(vec3(.95,.86,.56),pc,smoothstep(.28,.33,dr/R)); pc*=.88+.2*fbm(g*.4); c=mix(c,pc,paper); c=mix(c,vec3(.20,.14,.10),smoothstep(3.,0.,abs(dr-R))*.7); // the shot's path, beat 2: lands on the first red ring, right of the gold float by=abs(g.y-620.); float beam=exp(-by*by/55.)*step(g.x,1274.)*step(0.,g.x); c+=vec3(1.,.80,.46)*beam*.62*uBeam; vec2 imp=vec2(1274.,620.); c+=vec3(1.,.86,.58)*exp(-length(g-imp)*.10)*1.15*uBeam; c+=vec3(1.,.95,.80)*exp(-length(g-imp)*.45)*.9*uBeam; c*=mix(.55,1.,sat((g.x-60.)/900.)); // ---------------- space ---------------- vec3 sp=vec3(.004,.005,.011)+vec3(.020,.026,.046)*sat(1.-abs(q.y-620.)/430.); sp+=vec3(.026,.030,.055)*fbm(q*.0025); vec2 sg=q*.25; vec2 sid=floor(sg); vec2 sf=fract(sg)-.5; float rn=hash12(sid); float st=step(.945,rn)*smoothstep(.45,.0,length(sf)); sp+=vec3(.85,.90,1.)*st*(.7+.8*sin(uTime*1.6+rn*70.)); float slope=.15; vec2 O=vec2(180.,620.); vec2 dA=normalize(vec2(1.,slope)); float yA=O.y+slope*(q.x-O.x); float dI=abs(q.y-O.y); float dAl=abs(q.y-yA)/sqrt(1.+slope*slope); float onR=step(O.x,q.x); float stopI=step(q.x,O.x+1340.+180.*uStar); float coreI=exp(-dI*dI/2.)*onR*stopI; float glowI=exp(-dI*dI/260.)*onR*stopI; float coreA=exp(-dAl*dAl/2.)*onR; float glowA=exp(-dAl*dAl/260.)*onR; sp+=vec3(.45,.70,1.)*(coreI*1.8+glowI*.32)*uLine; sp+=vec3(1.,.60,.25)*(coreA*1.7+glowA*.32)*uLine; // the Moon the actual line passes vec2 mc=O+dA*700.; float mr=length(q-mc); float moon=smoothstep(1.5,-1.5,mr-82.); vec3 mcol=vec3(.32,.30,.28)*(.70+.5*fbm(q*.08)); mcol*=1.-.45*smoothstep(95.,18.,length(q-(mc+vec2(-30.,-30.)))); for(int i=0;i<5;i++){ float fi=float(i); vec2 cp=mc+vec2(sin(fi*2.3),cos(fi*1.7))*40.; float cr=length(q-cp)-(7.+6.*fract(fi*.61)); mcol*=1.-.40*smoothstep(2.,0.,cr); } mcol+=vec3(.34,.33,.29)*smoothstep(45.,82.,mr); sp=mix(sp,mcol,moon*uMoon); // the reticle the intended line ends on vec2 rc=O+vec2(1340.,0.); float rr2=length(q-rc); float ring=smoothstep(2.,0.,abs(rr2-70.)); float ticks=0.; for(int i=0;i<4;i++){ float a=float(i)*1.5708; vec2 tp=rc+vec2(cos(a),sin(a))*70.; ticks+=smoothstep(2.,0.,length(q-tp)-15.); } sp+=vec3(.45,.70,1.)*(ring*.9+ticks*.85)*uReticle; // the nearest star, at the end of the intended line vec2 sc=vec2(1700.,620.); float dsv=length(q-sc); float star=exp(-dsv*dsv/3.5)*3.2+exp(-dsv/34.)*.95+exp(-dsv/150.)*.16; star+=exp(-abs(q.y-sc.y)*11.)*exp(-abs(q.x-sc.x)/110.)*.50; sp+=vec3(1.,.92,.78)*star*uStar; c=mix(c,sp,uSpace); // calm patch behind the beat 2 label plate vec2 lp=(q-vec2(1240.,300.))/vec2(330.,120.); c*=1.-.45*uLabel*exp(-dot(lp,lp)); o=vec4(c,1.); }`,'aim hall') }; }, draw(s,d,r){ const E=d.E,c=d.ctx2d,L=E.lin; const close=s.k(1,0,2.4,E.io3); const cam=close*(1-s.k(2,0,1.0,L)); const beam=s.k(1,1.0,2.6,E.io3)*(1-s.k(2,0,1.2,L)); const label=s.k(1,1.4,2.8,E.io3)*(1-s.k(2,0,0.8,L)); const space=s.k(2,.3,3.2,E.io3); const lineV=s.k(2,1.0,2.8,E.io3); const moonV=s.k(2,1.6,3.6,E.out3)*(1-.85*s.k(3,0,2.0,E.io3)); const ret=s.k(2,1.4,3.2,E.io3)*(1-s.k(3,0,1.2,L)); const starV=s.k(3,.8,2.6,E.out3); r.hall.draw({uCam:cam,uBeam:beam,uSpace:space,uMoon:moonV,uLine:lineV, uReticle:ret,uStar:starV,uLabel:label,uM:[s.mouse.x,s.mouse.y]}); // the bow, the string and the arrow in the near foreground const bowA=s.k(0,.2,1.8,E.out3)*(1-s.k(1,0,1.0,L)); if(bowA>0.01){ c.save(); c.globalAlpha=bowA; c.lineCap='round'; c.strokeStyle='rgba(130,92,54,0.28)'; c.lineWidth=36; c.beginPath(); c.moveTo(300,518); c.quadraticCurveTo(792,940, 300,1362); c.stroke(); c.strokeStyle='#1d120a'; c.lineWidth=26; c.beginPath(); c.moveTo(300,518); c.quadraticCurveTo(792,940, 300,1362); c.stroke(); c.strokeStyle='rgba(186,136,86,0.55)'; c.lineWidth=6; c.beginPath(); c.moveTo(292,540); c.quadraticCurveTo(770,940, 292,1340); c.stroke(); c.strokeStyle='rgba(236,226,206,0.50)'; c.lineWidth=2.5; c.beginPath(); c.moveTo(300,518); c.lineTo(150,940); c.lineTo(300,1362); c.stroke(); c.strokeStyle='#33200f'; c.lineWidth=7; c.beginPath(); c.moveTo(212,620); c.lineTo(1150,620); c.stroke(); c.fillStyle='rgba(240,232,214,0.75)'; c.beginPath(); c.moveTo(250,614); c.lineTo(300,600); c.lineTo(300,640); c.lineTo(250,626); c.fill(); c.restore(); } // beat 2: bracket span between the gold centre and where the shot lands if(cam>0.02){ const kk=1+.45*cam, cx=1180, ix=1180+94*kk, byy=620-170*kk-58; const mid=1180+47*kk, al=Math.min(1,cam*1.5); c.save(); c.globalAlpha=al; c.strokeStyle='#ffd9a0'; c.lineWidth=5; c.lineCap='butt'; c.beginPath(); c.moveTo(cx,byy); c.lineTo(ix,byy); c.moveTo(cx,byy-22); c.lineTo(cx,byy+22); c.moveTo(ix,byy-22); c.lineTo(ix,byy+22); c.moveTo(cx,byy); c.lineTo(cx,byy+42); c.moveTo(ix,byy); c.lineTo(ix,byy+42); c.stroke(); c.restore(); d.rect(mid-270,byy-98,540,78,'rgba(12,7,4,0.74)',al); d.text('10 metres: 17 cm',{x:mid,y:byy-86,size:46,font:'mono',color:'#ffd9a0',align:'center',show:label}); } // beat 3 and 4 brackets if(space>0.05){ const a1=s.k(2,1.8,3.2,E.io3)*(1-s.k(3,.6,1.6,L)); if(a1>0.01){ const x=1000, y0=620, y1=620+.15*(x-180); c.save(); c.globalAlpha=a1; c.strokeStyle='#8fc0ff'; c.lineWidth=2.5; c.beginPath(); c.moveTo(x,y0); c.lineTo(x,y1); c.moveTo(x-16,y0); c.lineTo(x+16,y0); c.moveTo(x-16,y1); c.lineTo(x+16,y1); c.stroke(); c.restore(); } const a2=s.k(3,1.0,2.6,E.io3); if(a2>0.01){ const x=1640, y0=620, y1=620+.15*(x-180); c.save(); c.globalAlpha=a2; c.strokeStyle='#8fc0ff'; c.lineWidth=3.5; c.beginPath(); c.moveTo(x,y0); c.lineTo(x,y1); c.moveTo(x-22,y0); c.lineTo(x+22,y0); c.moveTo(x-22,y1); c.lineTo(x+22,y1); c.stroke(); c.restore(); } } d.text('What does\nit want?',{x:150,y:150,size:96,font:'display',color:'#f7efe0', show:s.k(0,.4,1.9,L),hide:s.k(1,0,.7,L)}); d.text('Miss by\none degree.',{x:150,y:150,size:96,font:'display',color:'#f7efe0', show:s.k(1,.9,2.3,L),hide:s.k(2,0,.7,L)}); d.text('One degree is\nall it takes.',{x:150,y:150,size:96,font:'display',color:'#f7efe0', show:s.k(3,1.2,2.8,L)}); d.text('6,700 km',{x:1022,y:636,size:36,font:'mono',color:'#bcd8ff', show:s.k(2,2.0,3.4,E.io3)*(1-s.k(3,0,1.0,L))}); d.text('4,700 AU',{x:1608,y:700,size:38,font:'mono',color:'#bcd8ff',align:'right', show:s.k(3,1.0,2.6,E.io3)}); } });