Deck.transition('portal-in', { dur:1.35, frag:`void main(){ if(p<=0.){o=texture(tA,vUv);return;} if(p>=1.){o=texture(tB,vUv);return;} vec2 pivot=vec2(.635,.51); vec2 v=(vUv-pivot)*vec2(uRes.x/uRes.y,1.); float a=p*p*(3.-2.*p), edge=mix(-.08,length(vec2(.66*uRes.x/uRes.y,.53))+.08,a); float h=length(v)-edge, rim=exp(-abs(h)*70.); vec2 warp=(vUv-pivot)*rim*.065*sin(3.14159*p); vec3 old=texture(tA,clamp(vUv+warp,0.,1.)).rgb; vec3 next=texture(tB,clamp(vUv-warp,0.,1.)).rgb; o=vec4(mix(next,old,smoothstep(-.018,.018,h))+vec3(.39,.65,.92)*rim*.31*sin(3.14159*p),1.); }` }); Deck.scene({ id:'pile', title:'You are here', enterWith:'portal-in', post:{tone:'none'}, beats:[{dur:10.9,hold:4},{dur:4.8,hold:5}], notes:[ 'That was the whole talk, on one curve. Now we go back down it. (Wait for the ride to stop.) This is today.', 'Look up. Everything in this talk is in that wall, and the wall starts a few steps in front of us. From down here it still looks flat. That is what the bottom of an exponential looks like.' ], setup(d){ const B=3.35, H=.065, step=2.9; const prim=g=>Math.hypot(1,g)+Math.log(g/(1+Math.hypot(1,g))); const origin=prim(H/B); const height=z=>.04+H*Math.exp(z/B); const zAt=l=>{ let lo=-12, hi=23; for(let i=0;i<25;i++){ const z=(lo+hi)*.5; if(B*(prim(H/B*Math.exp(z/B))-origin)=hi)return -1.; float f0=field(ro,rd,lo),f1=field(ro,rd,hi); if(f0*f1>0.){ if(f0>0. || rd.y*rd.z<=0.)return -1.; float tip=(B*log(B*rd.y/(H*rd.z))-ro.z)/rd.z; if(tip<=lo || tip>=hi || field(ro,rd,tip)<0.)return -1.; hi=tip; } for(int j=0;j<17;j++){ float m=(lo+hi)*.5; if(field(ro,rd,m)*f0>0.)lo=m; else hi=m; } return (lo+hi)*.5; } vec3 air(vec3 v){ float y=max(v.y,0.); vec3 blue=mix(vec3(.69,.84,.93),vec3(.16,.43,.73),smoothstep(-.04,.68,y)); vec2 a=v.xz/(y+.27)*1.6+vec2(.09,-.05)*uTime*.07; float n=vnoise(a)*.57+vnoise(a*2.07+8.)*.29+vnoise(a*4.3-3.)*.14; float cloud=smoothstep(.52,.69,n)*smoothstep(.02,.21,y); vec3 white=mix(vec3(.70,.80,.90),vec3(.98,.97,.93),smoothstep(.57,.77,n)); return mix(blue,white,cloud*.94); } float hill(vec2 p,float y,float skew){ return smoothstep(y-.005,y+.005,p.y+.055*sin(p.x*10.+skew)+.023*sin(p.x*23.+skew)); } vec3 land(vec2 p,vec3 sky,vec3 farCol,vec3 nearCol,float k){ vec3 c=mix(sky,farCol,hill(p,.57,k)); return mix(c,nearCol,hill(p,.74,k+2.)); } vec3 card(vec2 p,float ix){ vec3 c=vec3(.93,.94,.96); if(ix==1. || ix==13.){ c=vec3(.974,.975,.96); float bars=printEdge(sdBox(p-vec2(.5,.89),vec2(.5,.013))); float ink=printEdge(sdBox(p-vec2(.5,.41),vec2(ix==1.?.23:.14,.032))); float sub=printEdge(sdBox(p-vec2(.5,.52),vec2(.085,.011))); c=mix(c,vec3(.16,.21,.28),ink*.85+sub*.66); if(ix==1.){ float rows=printEdge(sdBox(p-vec2(.30,.68),vec2(.095,.008)))+ printEdge(sdBox(p-vec2(.30,.74),vec2(.095,.008))); float line=printEdge(abs(p.y-.69+.47*(p.x-.62))-.006)*step(.60,p.x)*step(p.x,.80); c=mix(c,vec3(.35,.46,.67),sat(rows+line)); } return mix(c,vec3(.24,.44,.75),bars); } if(ix==2.){ c=land(p,vec3(.85,.59,.39),vec3(.72,.45,.33),vec3(.82,.69,.58),2.); c=mix(c,vec3(1.,.88,.61),printEdge(length((p-vec2(.67,.48))*vec2(1.78,1.))-.14)); c=mix(c,vec3(.30,.25,.26),printEdge(sdBox(p-vec2(.55,.47),vec2(.048,.31)))); }else if(ix==3.){ c=land(p,vec3(.27,.36,.44),vec3(.16,.27,.34),vec3(.12,.23,.30),1.); float wave=.5+.5*sin(p.y*87.+p.x*9.+1.5*sin(p.x*24.)); c+=vec3(.21,.28,.31)*pow(wave,10.)*smoothstep(.53,.93,p.y); float hull=printEdge(sdBox(vec2(p.x-.57,p.y-.63+(p.x-.57)*.1),vec2(.16,.024))); float mast=printEdge(sdBox(p-vec2(.57,.52),vec2(.007,.105))); c=mix(c,vec3(.82,.75,.61),max(hull,mast)); }else if(ix==4.){ c=vec3(.92,.82,.65); vec2 g=(p-vec2(.52,.5))*vec2(1.55,1.); float loopD=abs(length(g)-.285)-.056; c=mix(c,vec3(.74,.25,.20),printEdge(loopD)); c=mix(c,vec3(.19,.37,.41),printEdge(abs(length(g)-.285)-.018)); }else if(ix==5.){ c=vec3(.09,.13,.18); vec2 g=vec2(p.x*34.,p.y*18.); float l=step(.31,hash12(floor(g)))*printEdge(length(fract(g)-.5)-.12); c+=vec3(.75,.79,.80)*l*smoothstep(.30,.70,p.y); }else if(ix==6.){ c=vec3(.55,.63,.49)+p.y*.1; float row=p.x*9.; vec2 g=vec2(fract(row)-.5,p.y-.52-.023*floor(row)); c=mix(c,vec3(.93,.88,.71),printEdge(sdBox(rot2(.33)*g,vec2(.31,.13)))); }else if(ix==7.){ c=vec3(.55,.38,.33); float sheet=printEdge(sdBox(p-vec2(.53,.51),vec2(.29,.34))); vec2 g=fract((p-vec2(.23,.30))*vec2(12.,10.))-.5; float cells=printEdge(sdBox(g,vec2(.34,.28)))*step(.36,p.y); c=mix(c,mix(vec3(.96,.91,.79),vec3(.74,.68,.59),cells*.6),sheet); c=mix(c,vec3(.71,.24,.23),printEdge(sdBox(p-vec2(.53,.24),vec2(.29,.07)))); }else if(ix==8.){ vec2 g=(p-vec2(.61,.46))*vec2(1.78,1.); c=vec3(.12,.10,.12)+vec3(.65,.33,.11)*exp(-length(g)*5.); c=mix(c,vec3(.95,.68,.30),printEdge(length(g*vec2(1.7,.78))-.065)); }else if(ix==9.){ vec2 g=(p-vec2(.56,.81))*vec2(1.78,1.); c=vec3(.09,.14,.24); c=mix(c,vec3(.29,.58,.73)+vnoise(p*18.)*.15,printEdge(length(g)-.46)); c+=vec3(.21,.37,.55)*exp(-abs(length(g)-.46)*83.); }else if(ix==10.){ c=vec3(.28,.30,.30); c=mix(c,vec3(.72,.68,.54),printEdge(sdBox(p-vec2(.68,.43),vec2(.17,.29)))); c=mix(c,vec3(.96,.79,.53),printEdge(abs(p.y-.68+.05*p.x)-.012)); }else if(ix==11.){ c=p.x<.5?land(p,vec3(.56,.74,.82),vec3(.35,.54,.56),vec3(.25,.47,.38),1.): land(p,vec3(.80,.55,.41),vec3(.55,.35,.35),vec3(.36,.25,.31),1.); float seam=printEdge(abs(p.x-.5)-.004); for(int j=0;j<3;j++){ seam=max(seam,printEdge(length((p-vec2(.5,.20+.30*float(j)))*vec2(1.78,1.))-(j==1?.027:.017))); } c=mix(c,vec3(.32,.69,1.),seam); }else{ c=land(p,vec3(.39,.66,.86),vec3(.75,.86,.92),vec3(.81,.85,.85),1.); float ribbon=.33+.34*exp(-max(p.y-.10,0.)*7.); c=mix(c,vec3(.97,.95,.88),printEdge(abs(p.x-ribbon)-.06)); } return c; } vec3 paper(vec3 hit,vec3 rd,float t){ float l=run(hit.z), ix=floor(l/STRIDE+.5); vec2 f=vec2(hit.x,l-ix*STRIDE); vec2 bounds=vec2(2.16,1.215); float dist=sdBox(f,bounds); float aa=max(.003,t*.0011); float frame=1.-smoothstep(-aa,aa,dist); float line=1.-smoothstep(.010,.016+aa,abs(dist)); vec3 tint=vec3(.953,.938,.895)+.032*exp(-pow((hit.x+.40)/1.9,2.)); bool printed=ix>=1. && ix<=13.; if(printed && frame>.001)tint=mix(tint,card(clamp(.5-f*vec2(-1.,1.)/(2.*bounds),0.,1.),ix),frame); tint=mix(tint,vec3(.60,.68,.72),line*(printed?.22:.44)); float edge=exp(-abs(abs(hit.x)-2.46)*135.); tint=mix(tint,vec3(.69,.73,.73),edge*.58); vec3 normal=normalize(vec3(0.,1.,-(lift(hit.z)-.04)/B)); tint*=.87+.13*dot(normal,normalize(vec3(-.32,.73,-.54))); tint+=.015*(vnoise(vec2(hit.x,l)*49.)-.5); vec3 haze=air(normalize(vec3(rd.x,max(.15,rd.y),rd.z))); return mix(tint,haze,1.-exp(-max(t-6.,0.)*.013-max(hit.y-23.,0.)*.088)); } void main(){ vec2 q=design(vUv), k=(q-uCenter)*vec2(1.,-1.)/1080.; vec3 rd=normalize(vec3(k.x,0.,0.)+k.y*uUp+1.04*uDir); vec3 c=air(rd); float tg=rd.y<-.0001?-uEye.y/rd.y:1e4; float hit=paperHit(uEye,rd,min(tg,130.)); if(hit>0.){ c=paper(uEye+rd*hit,rd,hit); }else if(tg<190.){ vec3 g=uEye+tg*rd, rr=vec3(rd.x,-rd.y,rd.z); vec3 skyReflection=air(rr); float broad=vnoise(g.xz*.24); c=mix(vec3(.83,.85,.84),skyReflection,.30+.32*pow(1.-rr.y,3.)); c+=.045*(broad-.43); c+=.017*(hash12(floor(g.xz*120.))-.5)*exp(-tg*.025); float shadow=1.-smoothstep(2.1,3.4,abs(g.x-.22*min(lift(min(g.z,17.)),3.))); c-=vec3(.15,.13,.10)*shadow*smoothstep(-9.5,-8.2,g.z)*(1.-smoothstep(10.,18.,g.z)); if(tg<60.){ float tr=paperHit(g,rr,64.); if(tr>0.){ vec3 mir=paper(g+rr*tr,rr,tr+tg); c=mix(c,mir,.24*exp(-tr*.024)); } } c=mix(c,air(normalize(vec3(rd.x,.045,rd.z))),smoothstep(32.,185.,tg)); } float depth=hit>0.?hit:tg; for(int i=0;i<7;i++){ float j=float(i), time=uTime*.33+j*2.19; float z=4.+j*2.12+sin(time*.47)*.75; float side=mod(j,2.)==0.?1.:-1.; vec3 center=vec3(side*(3.1+.46*mod(j,3.))+.45*sin(time),1.37+j*j*.43+.36*cos(time),z); vec3 ax=normalize(vec3(cos(time*.8),.24*sin(time),sin(time*.8))); vec3 ay=normalize(cross(ax,vec3(.15*cos(time),1.,.67*sin(time*.54)))); vec3 nn=cross(ax,ay); float denom=dot(nn,rd); if(abs(denom)>.001){ float ts=dot(nn,center-uEye)/denom; if(ts>.1 && ts.01){ vec3 sheet=mix(vec3(.77,.84,.89),vec3(.99,.964,.89),abs(dot(nn,vec3(-.3,.83,-.45)))); c=mix(c,mix(sheet,air(rd),1.-exp(-ts*.012)),a); if(a>.5)depth=ts; } } } } float left=(1.-smoothstep(610.,1050.,q.x))*(1.-smoothstep(490.,710.,q.y)); c=mix(c,mix(c,vec3(.12,.27,.46),.58),left*uTilt); c+=(hash12(floor(q*1.27))-.5)*.014; o=vec4(clamp(c,0.,1.),1.); }`,'The printed curve') }; }, draw(s,d,r){ const E=d.E, U=r.U; const t=s.k(0,0,10,E.lin); const ride=t*t*(3-2*t); const look=s.k(1,0,4.8,E.io3); const z=r.zAt(11*r.step*(1-ride)), y=r.height(z); const slope=(y-.04)/3.35, norm=Math.hypot(1,slope); const distance=6.9+.65*Math.sin(Math.PI*t); const pointer=1-.83*s.k(0,9,10); U.uEye[0]=.17*s.mouse.x*pointer+.19*s.mouse.x*look; U.uEye[1]=y+distance/norm+(2.18-y-distance/norm)*look+.12*s.mouse.y*look; U.uEye[2]=z-distance*slope/norm-4.3*look; const square=-Math.atan2(1,slope); const angle=square+(.405-square)*look+.12*Math.sin(Math.PI*t)+.023*s.mouse.y*(pointer+look); U.uDir[1]=Math.sin(angle); U.uDir[2]=Math.cos(angle); U.uUp[1]=U.uDir[2]; U.uUp[2]=-U.uDir[1]; U.uCenter[0]=1210-96*look; U.uCenter[1]=534+62*look; U.uTilt=s.k(1,.36,1.95); r.bg.draw(U); const arrive=s.k(0,9.65,10.9,E.lin), hide=s.k(1,0,.56,E.lin); const box=s.k(0,9.6,10.44,E.lin)*(1-hide); if(box>0){ let x0=Infinity,x1=-Infinity,y0=Infinity,y1=-Infinity; for(let i=0;i<4;i++){ const zc=r.zAt(i&2?1.215:-1.215), yy=r.height(zc)-U.uEye[1], zz=zc-U.uEye[2]; const f=1123.2/(yy*U.uDir[1]+zz*U.uDir[2]); const x=U.uCenter[0]+((i&1?2.16:-2.16)-U.uEye[0])*f; const y=U.uCenter[1]-(yy*U.uUp[1]+zz*U.uUp[2])*f; x0=Math.min(x0,x); x1=Math.max(x1,x); y0=Math.min(y0,y); y1=Math.max(y1,y); } d.select(x0-9,y0-9,x1-x0+18,y1-y0+18,{a:box}); } const headline=d.text('You are here.',{ x:146,y:210,size:89,color:'#10263e',show:arrive,hide }); d.text(r.date,{ x:150,y:headline.y+headline.h+22,size:32,font:'mono',color:'#263f57', style:'fade',show:s.k(0,10.03,10.9,E.lin),hide }); d.text('This is\nthe flat part.',{ x:146,y:200,size:103,color:'#ffffff',show:s.k(1,.88,2.27,E.lin) }); } });