Deck.transition('portal-in',{dur:1.2,frag:`void main(){ vec2 q=(vUv-.5)*vec2(uRes.x/uRes.y,1.); float r=length(q), e=p*p*(3.-2.*p), R=e*2.4; float m=1.-smoothstep(R-.03,R,r); vec3 A=texture(tA,.5+(vUv-.5)*(1.-.25*e)).rgb, B=texture(tB,.5+(vUv-.5)*(.55+.45*e)).rgb; float rim=exp(-abs(r-R)*30.)*sin(3.14159*p); o=vec4(mix(A,B,m)+vec3(.5,.75,1.)*rim,1.); }`}); Deck.scene({ id:'pile', title:'You are here', enterWith:'portal-in', post:{bloom:.5,threshold:1.1,vignette:.18,grain:.025}, beats:[{dur:10.8,hold:4},{dur:4.5,hold:6}], 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 A=Math.exp(-6), fd=x=>A*Math.exp(Math.min(x,12)); const arc=x=>{const u=fd(x),q=Math.sqrt(1+u*u);return q+Math.log(u/(1+q));}; const xOf=s=>{let lo=-8,hi=12;for(let i=0;i<48;i++){const m=(lo+hi)/2;if(arc(m){const x=xOf(s),u=fd(x),q=Math.sqrt(1+u*u);P.x=x;P.y=.02+u;P.nx=-u/q;P.ny=1/q;P.fl=1/(q*q);return P;}; const xC=xOf(-5); const date=new Date().toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric'}); const U={uRo:[0,0,0],uTa:[0,0,0],uF:1.4}, q=[0,0,0]; const project=(x,y,z)=>{ const o=U.uRo,t=U.uTa; let wx=t[0]-o[0],wy=t[1]-o[1],wz=t[2]-o[2],l=Math.hypot(wx,wy,wz); wx/=l;wy/=l;wz/=l; l=Math.hypot(wx,wz); const ux=-wz/l,uz=wx/l, vx=-uz*wy,vy=uz*wx-ux*wz,vz=ux*wy; x-=o[0];y-=o[1];z-=o[2]; const cz=x*wx+y*wy+z*wz; q[0]=960+1080*U.uF*(x*ux+z*uz)/cz; q[1]=540-1080*U.uF*(x*vx+y*vy+z*vz)/cz; q[2]=cz; return q }; return { U, pt, xC, date, project, sky:d.pass(`uniform vec3 uRo,uTa; uniform float uF; const float A=.00247875; const float SF=-4.; const vec3 S=vec3(-.5666,.7026,.4306); float fd(float x){ return A*exp(min(x,12.)); } float arcl(float x){ float u=fd(x), q=sqrt(1.+u*u); return q+log(u/(1.+q)); } float gF(vec3 ro,vec3 rd,float t){ vec3 q=ro+rd*t; return q.y-.02-fd(q.x); } vec3 skyc(vec3 rd){ float y=max(rd.y,0.); vec3 c=mix(vec3(.55,.68,.85),vec3(.12,.28,.7),pow(y,.6)); float sd=max(dot(rd,S),0.); c+=vec3(1.,.9,.7)*(.15*pow(sd,8.)+20.*smoothstep(.9996,.9998,sd)); float cl=fbm(rd.xz/(y+.15)*1.2+vec2(uTime*.01,0.)); return mix(c,vec3(.85,.88,.92),smoothstep(.5,.8,cl)*smoothstep(0.,.25,rd.y)*.8); } vec3 pal(float i){ return .45+.35*cos(6.283*(i*.37+vec3(0.,.33,.67))); } void main(){ vec2 p=(design(vUv)-vec2(960.,540.))*vec2(1.,-1.)/1080.; vec3 w=normalize(uTa-uRo),u=normalize(cross(w,vec3(0.,1.,0.))),v=cross(u,w),rd=normalize(p.x*u+p.y*v+uF*w),ro=uRo; float tg=rd.y<0.?-ro.y/rd.y:1e4, th=1e4, ta=0.; for(int i=1;i<=40;i++){ float fi=float(i)/40., tb=90.*fi*fi; if(gF(ro,rd,tb)<0.){ float lo=ta,hi=tb; for(int j=0;j<14;j++){ float m=.5*(lo+hi); if(gF(ro,rd,m)>0.)lo=m; else hi=m; } th=.5*(lo+hi); vec3 h=ro+rd*th; if(abs(h.z)>1.||h.x<-4.5) th=1e4; break; } ta=tb; } vec3 c=skyc(rd); float t=min(th,tg); if(t<1e4){ vec3 q=ro+rd*t; if(th-.5&&fi<10.5){ al=vv<-.2?pal(fi+.5)*.5:pal(fi); if(fi<.5){ al=vec3(.92); if(abs(vv-.4)<.12&&abs(ww)<.6) al=vec3(.05); } if(fi>9.5){ al=ww<0.?vec3(.25,.45,.2):vec3(.45,.4,.35); if(abs(ww)<.02) al=vec3(.1,.3,1.); } } else if(fi>-7.&&fi<17.&&max(abs(ww)-.97,abs(vv)-.95)>0.) al*=.6; } c=al*(vec3(1.,.95,.85)*max(dot(n,S),0.)+vec3(.4,.5,.7)*.5); } else{ vec3 rf=reflect(rd,vec3(0.,1.,0.)); rf.xz+=(fbm(q.xz*.5)-.5)*.05; c=mix(vec3(.6,.63,.68)*(.75+.25*fbm(q.xz*.3)),skyc(normalize(rf)),.4); c*=.7+.3*smoothstep(1.,1.4,abs(q.z+.15)); } c=mix(c,skyc(normalize(vec3(rd.x,.02,rd.z))),1.-exp(-t*.012)); } for(int i=0;i<6;i++){ float fi=float(i); vec3 ce=vec3(1.5+fi*1.2+.4*sin(uTime*.13+fi*2.1),1.2+fi*1.2+.35*sin(uTime*.21+fi*1.3),(mod(fi,2.)*2.-1.)*(1.8+.25*fi)); float a=uTime*.35+fi*1.7, b=.7+.6*sin(uTime*.27+fi*3.); vec3 n=vec3(sin(b)*cos(a),cos(b),sin(b)*sin(a)), e1=normalize(cross(n,vec3(.31,.17,.93))), e2=cross(n,e1); float den=dot(rd,n); if(abs(den)<1e-4) continue; float ts=dot(ce-ro,n)/den; if(ts<.05||ts>t) continue; vec3 l=ro+rd*ts-ce; if(abs(dot(l,e1))<.2&&abs(dot(l,e2))<.14){ t=ts; c=vec3(.85,.85,.82)*(.55+.6*abs(dot(n,S))); } } o=vec4(c,1.); }`,'pile sky') } }, draw(s,d,r){ const U=r.U, E=d.E, ride=s.k(0,.3,10.3,E.io3), k2=s.k(1,0,4.5,E.io3); const P=r.pt(6-11*ride), D=2.4-1.1*P.fl, sw=.05*Math.sin(s.t*.2)+s.mouse.x*.15; const tx=P.x+.3*P.fl, ty=P.y; U.uRo[0]=P.x+P.nx*D-2.2*P.fl; U.uRo[1]=P.y+P.ny*D-.6*k2+s.mouse.y*.08; U.uRo[2]=sw; U.uTa[0]=tx+(8.2-tx)*k2; U.uTa[1]=ty+(6.5-ty)*k2; U.uTa[2]=0; U.uF=1.4-.45*k2; r.sky.draw(U); const a=s.k(0,9.8,10.6,E.lin)*(1-s.k(1,0,.8,E.lin)); if(a>0){ let x0=1e9,y0=1e9,x1=-1e9,y1=-1e9,ok=true; for(let i=0;i<4;i++){ const q=r.project(r.xC+(i&1?.405:-.405),.02,i&2?.72:-.72); if(q[2]<=0) ok=false; x0=Math.min(x0,q[0]); y0=Math.min(y0,q[1]); x1=Math.max(x1,q[0]); y1=Math.max(y1,q[1]); } if(ok) d.select(x0,y0,x1-x0,y1-y0,{a}); } const sh=s.k(0,9.4,10.6,E.lin), hd=s.k(1,0,.6,E.lin); const h=d.text('You are here.',{x:150,y:120,size:110,color:'#14233d',show:sh,hide:hd}); d.text(r.date,{x:150,y:h.y+h.h+30,size:40,font:'mono',color:'#14233d',style:'fade',show:s.k(0,10,10.8,E.lin),hide:hd}); d.text('This is\nthe flat part.',{x:150,y:120,size:110,color:'#ffffff',show:s.k(1,1,2.4,E.lin)}); } });