Deck.scene({ id:'lamp', title:'How far you can see', enterWith:'fade', post:{bloom:1.,threshold:1.,vignette:.3,grain:.035}, beats:[{dur:2.5,hold:5},{dur:8.5,hold:5},{dur:6,hold:6}], notes:[ 'Forget test scores. Intelligence is how far you can see. This is one person, with one lantern, in the dark. Everything inside the pool you can think about. Everything outside it is not there.', 'Now light the brightest lantern anyone ever carried. Einstein. Look at how much more of the field he lights. Almost nothing. Now everyone alive, all eight billion of us, together. It is beautiful. It is also still night.', 'So what does it look like when the sun comes up? All of this was always here. What we called the world was one small fold in it.'], setup(d){ const U={uRo:[0,1.3,0],uHz:.1,uEin:0,uAll:0,uDay:0,uYou:[0,0],uEinP:[0,0]}; // same camera maths as the shader: world point -> centred screen coords const proj=(X,Y,Z,out)=>{ const o=U.uRo,a=Math.atan(U.uHz/1.3),sa=Math.sin(a),ca=Math.cos(a),dx=X-o[0],dy=Y-o[1],dz=Z-o[2],cz=-dy*sa+dz*ca; out[0]=1.3*dx/cz; out[1]=1.3*(dy*ca+dz*sa)/cz; }; return { U, proj, cream:'#f6ead2', sky:d.pass(`uniform vec3 uRo; uniform float uHz,uEin,uAll,uDay; uniform vec2 uYou,uEinP; const float F=1.3; const vec3 FL=vec3(1.2,1.45,3.6); const vec3 EL=vec3(8.,1.6,9.); const vec3 AMB=vec3(1.,.45,.1); vec3 lampLight(vec3 X){ vec3 d1=X-FL; float a1=dot(d1,d1), fl=.92+.08*sin(uTime*9.)*sin(uTime*5.3); vec3 l=vec3(1.,.5,.16)*fl*3.5/(1.+.3*a1)*exp(-sqrt(a1)*.12); vec3 d2=X-EL; float a2=dot(d2,d2); l+=vec3(1.,.6,.25)*uEin*9./(1.+.25*a2)*exp(-sqrt(a2)*.1); return l; } vec3 dayPic(vec2 pp){ float y=pp.y-uHz, x=pp.x; vec2 sp=vec2(.24,mix(0.,.165,uDay)); float sd=length(vec2(x,y)-sp); vec3 mist=vec3(.78,.76,.8); vec3 c=mix(vec3(1.,.86,.66),vec3(.22,.42,.78),pow(sat(y*1.6),.6)); c+=vec3(1.,.9,.75)*(.012/(sd*sd+.006))+vec3(1.,.97,.9)*14.*smoothstep(.02,.017,sd); if(y<0.){ float z=1./(-y+.03); float wv=fbm(vec2(x*z*4.,z*6.+uTime*.4)); c=mix(vec3(.1,.26,.42),mist,exp(y*9.)*.85)*(.85+.3*wv); c+=vec3(1.,.9,.7)*smoothstep(.55,.85,wv)*exp(-abs(x-sp.x)*7.)*1.5; } for(int i=0;i<5;i++){ float fi=float(i), t=fi/4.; float wd=mix(.07,.62,pow(t,1.4)), top=mix(.05,.34,t), cx=mix(.22,.15,t), s=.25+.75*t, base=-mix(.012,.7,t*t); float n=fbm(vec2(y*9./s+fi*5.,x*9./s))-.5; float dx=x-cx+n*.05*s, yy=y+n*.03*s; float f=pow(abs(dx)/wd,3.)+pow(max(yy,0.)/top,3.); float ridge=i<4?top*1.1+n*.04*s:10.; float m=smoothstep(1.,1.06,f)*smoothstep(ridge,ridge-.004,y)*smoothstep(base,base+.004,y); float b=sin(y*70./s+n*8.+fi*2.); vec3 col=mix(vec3(.5,.17,.08),vec3(.8,.42,.2),.5+.5*b); col=mix(col,vec3(.85,.65,.45),smoothstep(.9,1.,sin(y*23./s+n*5.))); col*=mix(.9,.38,t); col+=vec3(1.,.55,.25)*.35*smoothstep(1.5,1.,f)*(1.-.5*t); col=mix(col,mist*vec3(1.,.92,.9),(1.-t)*.8); col=mix(col,mist,exp(-(y-base)*14./s)*.6); c=mix(c,col,m); } vec2 dv=vec2(x,y)-sp; float ry=fbm(dv/(sd+1e-4)*3.+uTime*.03); c+=vec3(1.,.85,.6)*ry*ry*exp(-sd*2.2)*.5*uDay; for(int i=0;i<5;i++){ float fi=float(i); vec2 bp=vec2(-.1+fract(fi*.37+uTime*.012)*.6,.2+.03*sin(fi*2.4)+.01*sin(uTime*.5+fi)); vec2 bq=(vec2(x,y)-bp)/(.012+.003*fi); float bd=abs(bq.y-abs(bq.x)*(.3+.5*sin(uTime*5.+fi*2.))); c=mix(c,vec3(.05,.04,.05),smoothstep(.22,.08,bd)*smoothstep(1.,.8,abs(bq.x))*.9); } return c; } void main(){ vec2 q=design(vUv); vec2 p=(q-vec2(960.,540.))*vec2(1.,-1.)/1080.; float a=atan(uHz/F); vec3 w=vec3(0.,-sin(a),cos(a)), v=vec3(0.,cos(a),sin(a)); vec3 rd=normalize(vec3(p.x,0.,0.)+p.y*v+F*w); float t=-uRo.y/min(rd.y,-.0015); vec2 P=uRo.xz+rd.xz*t; vec2 g=P/1.6; float aa=max(fwidth(g.x),fwidth(g.y)); // ground in the lantern's pool float det=exp(-t*.04); vec3 alb=vec3(.34,.25,.12)*mix(.9,.4+1.1*fbm(P*vec2(3.,7.)),det); float rk=smoothstep(.7,.78,vnoise(P*1.2+3.))*det; alb=mix(alb,vec3(.3,.29,.28)*(.5+vnoise(P*8.)),rk); float pd=sdBox(rot2(.5)*(P-vec2(.3,4.2)),vec2(.17,.24)); alb=mix(alb,vec3(.85,.8,.68),smoothstep(.01,0.,pd)*det); vec3 cn=alb*(lampLight(vec3(P.x,0.,P.y))+vec3(.004,.006,.012)); // eight billion embers vec2 id=floor(g); float rnd=hash12(id); float rv=fbm(P*.011+2.); float dens=sat(.05+smoothstep(.07,0.,abs(rv-.5))*.9+smoothstep(.5,.72,fbm(P*.03+7.))*.7); float lit=step(hash12(id+3.7),dens); vec2 off=(vec2(hash12(id+1.3),hash12(id+8.1))-.5)*.6; float dd=length(fract(g)-.5-off), rr=.13+aa*.5; float far=min(length(P-FL.xz)/900.,1.)*.85; float wv=uAll*1.15-far-rnd*.2, on=smoothstep(0.,.04,wv); vec3 em=AMB*lit*on*exp(-dd*dd/(rr*rr))*(1.2+4.*rnd)*(.13/rr)*(.85+.15*sin(uTime*2.+rnd*40.)); em=mix(em,AMB*dens*.35*sat((uAll*1.15-far)*6.),sat(aa*1.2-.5)); cn+=em*exp(-t*.0012); if(rd.y>0.) cn=vec3(.004,.005,.009)+AMB*.1*uAll*uAll*exp(-rd.y*16.); // grass rows as upright planes, lantern between them for(int i=0;i<7;i++){ float fi=float(i), zk=6.1-.8*fi, tk=(zk-uRo.z)/rd.z; vec3 h=uRo+rd*tk; if(i==4){ float tl=(FL.z-uRo.z)/rd.z; vec3 hl=uRo+rd*tl; vec2 lq=hl.xy-vec2(FL.x,0.); float lv=smoothstep(45.,18.,tl), e=fwidth(lq.y)*1.2+1e-4; float dm=sdBox(lq-vec2(-.38,.95),vec2(.02,.95)); vec2 hq=lq-vec2(-.19,1.9); dm=min(dm,max(abs(length(hq)-.19)-.018,-hq.y)); dm=min(dm,sdBox(lq-vec2(0.,1.83),vec2(.01,.07))); dm=min(dm,sdBox(lq-vec2(0.,1.745),vec2(.1,.03))); dm=min(dm,sdBox(lq-vec2(0.,1.31),vec2(.11,.035))); dm=min(dm,sdBox(vec2(abs(lq.x)-.088,lq.y-1.53),vec2(.007,.19))); float dg=sdBox(lq-vec2(0.,1.53),vec2(.085,.19)); vec2 fq=lq-vec2(0.,1.45); float fd=length(vec2((fq.x+.05*fq.y*sin(uTime*10.))*2.7,fq.y-.01))-.075; cn+=vec3(1.,.5,.15)*.012/(dot(fq,fq)+.01)*lv; cn=mix(cn,vec3(1.,.5,.15)*(.25+.5*exp(-dot(fq,fq)*40.)),smoothstep(e,0.,dg)*lv*.8); cn=mix(cn,vec3(1.,.8,.4)*9.,smoothstep(e,0.,fd)*lv); cn=mix(cn,vec3(.06,.04,.025)+vec3(1.,.5,.2)*.3*exp(-length(fq)*4.),smoothstep(e,0.,dm)*lv); for(int j=0;j<4;j++){ float fj=float(j); vec2 mp=vec2(sin(uTime*(1.1+.3*fj)+fj*2.)*(.2+.05*fj),.05+cos(uTime*(1.7+.2*fj)+fj)*.16); cn+=vec3(1.,.8,.55)*smoothstep(.022,.008,length(fq-mp))*(.5+.5*sin(uTime*30.+fj*3.))*1.2*lv; } } float vis=step(0.,tk)*smoothstep(45.,18.,tk); float xs=h.x*20.+fi*7.3+h.y*h.y*.8*sin(uTime*.7+h.x*1.3+fi*2.); float idx=floor(xs), fx=fract(xs)-.5, r=hash12(vec2(idx,fi)), bh=.3+.65*r, tt=h.y/bh; float lean=(hash12(vec2(idx,fi+9.))-.5)*.6; float clr=smoothstep(.45,1.,length(vec2(h.x-.3,zk-4.2)))*smoothstep(.3,.7,length(vec2(h.x-1.2,zk-3.6))); float wdt=.4*(1.-tt), ax=fwidth(xs)*1.2+.02; float m=smoothstep(wdt,wdt-ax,abs(fx-lean*tt))*step(0.,h.y)*step(tt,1.)*step(.3,hash12(vec2(idx,fi+4.))); vec3 col=vec3(.55,.42,.18)*(.5+.7*r)*(.35+.65*sat(tt))*(lampLight(vec3(h.x,h.y,zk))*(zk<3.6?.35:1.)+vec3(.003,.004,.008)); cn=mix(cn,col,m*vis*clr); } // far-view points for the two named lanterns vec2 e1=p-uYou; cn+=AMB*3.*exp(-dot(e1,e1)*5e4)*smoothstep(15.,50.,length(FL-uRo)); vec2 e2=p-uEinP; cn+=vec3(1.,.6,.25)*uEin*(5.*exp(-dot(e2,e2)*3e4)+.4*exp(-dot(e2,e2)*1500.)); cn*=1.-.75*smoothstep(1150.,700.,q.x)*smoothstep(380.,260.,q.y); vec3 c=cn*(1.-smoothstep(.15,.7,uDay)); if(uDay>0.){ vec3 dc=dayPic(p)*pow(uDay,1.3)*mix(vec3(1.,.55,.35),vec3(1.),uDay); dc*=1.-.42*smoothstep(1500.,900.,q.x)*smoothstep(320.,220.,q.y); c+=dc; } c*=1.-.65*smoothstep(-640.,-300.,q.x-uView.x-uView.z)*smoothstep(-270.,-160.,q.y-uView.y-uView.w); o=vec4(c,1.); }`,'lamp field') }; }, draw(s,d,r){ const E=d.E, L=E.lin, U=r.U, kA=s.k(1,0,3), kB=s.k(1,3,7.5), kD=s.k(2,0,3.5); const sw=.04*Math.sin(s.t*.2)+s.mouse.x*.06; U.uRo[0]=3*kA+kB+sw*(1+6*kB); U.uRo[1]=1.3+7.7*kA+51*kB+s.mouse.y*.03; U.uRo[2]=-16*kA-144*kB; U.uHz=.1+.2*kA-.38*kD; U.uEin=s.k(1,1.6,3.2); U.uAll=s.k(1,3.6,8.5); U.uDay=s.k(2,.6,6); r.proj(1.2,1.45,3.6,U.uYou); r.proj(8,1.6,9,U.uEinP); r.sky.draw(U); const c=r.cream, lx=960+1080*U.uYou[0], ly=540-1080*U.uYou[1]; const la=s.k(0,1,2,L)*(1-s.k(1,0,.5,L)); d.rect(lx+62,ly-1,46,2,c,la*.8); d.text('You',{x:lx+122,y:ly-28,size:44,color:c,style:'fade',show:s.k(0,1,2,L),hide:s.k(1,0,.5,L)}); d.text('Intelligence is\nhow far you can see.',{x:150,y:150,size:96,color:c,show:s.k(0,.3,1.8,L),hide:s.k(1,0,.6,L)}); d.text('Everyone alive',{x:150,y:120,size:110,color:c,show:s.k(1,4.2,5.6,L),hide:s.k(2,0,.6,L)}); const rise=s.k(2,1.5,3.5,E.out3); d.text('Superintelligence',{x:150,y:90+(1-rise)*(d.view.y1-50),size:110,color:'#fff6e6',alpha:s.k(2,1.5,2.2,L)}); const x=d.view.x1-110, y=d.view.y1; d.text('1.6 × 10^19',{x,y:y-200,size:64,font:'mono',color:c,align:'right',style:'fade',show:s.k(0,.8,1.8,L),hide:s.k(1,3.4,4,L)}); d.text('1.3 × 10^29',{x,y:y-200,size:64,font:'mono',color:c,align:'right',style:'fade',show:s.k(1,4.2,5.2,L),hide:s.k(2,0,.6,L)}); d.text('> 10^40',{x,y:y-200,size:64,font:'mono',color:c,align:'right',style:'fade',show:s.k(2,2.5,3.5,L)}); d.text('illustration',{x,y:y-112,size:24,font:'mono',color:'#b9b3a6',align:'right',style:'fade',show:s.k(0,.8,1.8,L)}); } });