0x865e0647…43a7sent to0x32d4be5e…f436·#17,030,811·view on Etherscan
tD=tokenData;var sh_fs="#version 300 es\n#define TX texture\n#define V3 vec3\n#define FF float\nprecision highp FF;out vec4 outColor;in vec2 v_texcoord; uniform sampler2D tex0;uniform sampler2D dtx;uniform vec2 dtxS;uniform int u_numObjects;uniform FF u_time;uniform FF uFrame,aR;uniform int uBW;uniform FF uRndmArr[100];uniform V3 uPosCam;uniform FF uCamFl;uniform V3 uLookAt;uniform FF uICEK;const int MAXMARCHINGSTEPSMAX = 128;uniform int uMaxIter;const FF MIN_DIST = 0.0;const FF MAX_DIST = 100.0;const FF EPSILON = 0.0005;const FF PI = 3.14159265359;const FF PI2 = 1.570796326795;const int COLORITER = 128;uniform int uCi;vec2 uv; FF modm( FF x,FF y) {return x-y*floor(x/y);} FF hash( FF seed) {return fract(sin(seed)*43758.5453);}V3 cD(in FF seed,in V3 nor) {V3 tc = V3(1.0+nor.z-nor.xy*nor.xy,-nor.x*nor.y)/(1.0+nor.z);V3 uu = V3(tc.x,tc.z,-nor.x);V3 vv = V3(tc.z,tc.y,-nor.y); FF u = hash(78.233+seed+uRndmArr[(int(32.+u_time))%45]); FF v = hash(10.873+seed+uRndmArr[(int(15.+u_time))%45]); FF a = 6.283185*v;return sqrt(u)*(cos(a)*uu+sin(a)*vv)+sqrt(1.0-u)*nor;} FF rdn(vec2 st) {return fract(sin(dot(st.xy,vec2(12.9898,78.233)))*43758.5453123);}V3 uniformVector(in FF seed) { FF a = 3.141593*hash(78.233+seed); FF b = 6.283185*hash(10.873+seed);return V3(sin(b)*sin(a),cos(b)*sin(a),cos(a));}mat3 rotateX( FF theta) { FF c = cos(theta); FF s = sin(theta);return mat3(V3(1,0,0),V3(0,c,-s),V3(0,s,c));}mat3 rotateY( FF theta) { FF c = cos(theta); FF s = sin(theta);return mat3(V3(c,0,s),V3(0,1,0),V3(-s,0,c));}mat3 rotateZ( FF theta) { FF c = cos(theta); FF s = sin(theta);return mat3(V3(c,-s,0),V3(s,c,0),V3(0,0,1));}mat3 identity() {return mat3(V3(1,0,0),V3(0,1,0),V3(0,0,1));} FF ssub( FF d1,FF d2) {return max(-d1,d2);}struct SurfaceWithP { FF sd;V3 col;V3 p;};struct Srfc { FF sd;V3 col;};struct SrfcP { FF sd;V3 col;vec4 dim;};Srfc sdB(V3 p,V3 b,V3 ofs,V3 col,mat3 trns) {p = (p-ofs)*trns;V3 q = abs(p)-b; FF d = length(max(q,0.0))+min(max(q.x,max(q.y,q.z)),0.0);return Srfc(d,col);}Srfc sCyl(V3 p,V3 c) {return Srfc(length(p.xz-c.xy)-c.z-0.01,V3(0));}Srfc sdSphere(V3 p,FF d,V3 col) {return Srfc(length(p)-d,col);}Srfc sdPyramid( V3 p,FF h,V3 col){ FF m2 = h*h+0.25; p.xz = abs(p.xz); p.xz = (p.z>p.x) ? p.zx : p.xz; p.xz -= 0.5; V3 q = V3( p.z,h*p.y-0.5*p.x,h*p.x+0.5*p.y); FF s = max(-q.x,0.0); FF t = clamp( (q.y-0.5*p.z)/(m2+0.25),0.0,1.0 ); FF a = m2*(q.x+s)*(q.x+s)+q.y*q.y; FF b = m2*(q.x+0.5*t)*(q.x+0.5*t)+(q.y-m2*t)*(q.y-m2*t); FF d2 = min(q.y,-q.x*m2-q.y*0.5) > 0.0 ? 0.0 : min(a,b); return Srfc(sqrt( (d2+q.z*q.z)/m2 )*sign(max(q.z,-p.y)),col);}Srfc sdTriPrism( V3 p,vec2 h ,V3 col){ V3 q = abs(p); return Srfc(max(q.z-h.y,max(q.x*0.866025+p.y*0.5,-p.y)-h.x*0.5),col);}Srfc sadd(Srfc o1,Srfc o2) {if(o2.sd < o1.sd)return o2;return o1;}V3 opRepLim(V3 p,FF c,V3 l) {V3 q = p-c*clamp(floor(p/c+0.5),-l,l);return q;}Srfc sdWall_3(V3 p,V3 b,V3 ofs,V3 col,mat3 trns) {V3 qq = p;qq = trns*(qq-ofs-V3(0,b.y,0));V3 q = abs(qq)-b; FF d = length(max(q,0.0))+min(max(q.x,max(q.y,q.z)),0.0);return Srfc(d,col);}Srfc sdScene_addPoles(V3 p,Srfc co,vec4 headDim) { FF c = max(0.1,uRndmArr[27]); FF w = uRndmArr[26]; FF L = headDim.x/1.;p -= V3(0,headDim.y,0);p = rotateX(PI2*uRndmArr[47])*rotateY(PI2*uRndmArr[44])*p;V3 l = V3((headDim.z+headDim.w)/c,headDim.x/c,headDim.y/c);V3 repQ = opRepLim(p,c,l*V3(abs(uRndmArr[43])*3.));return sadd(co,sdB(repQ,V3(w,L,w),V3(0,0,0),V3(1.),identity()));}Srfc sdFloor(V3 p,V3 col) { FF d = p.y-0.75 +uRndmArr[97]*(uRndmArr[5]*sin(p.x)+ +uRndmArr[4]*sin(p.z+uRndmArr[2])); return Srfc(d,col);}Srfc cutWholeSceneWithThings(V3 p,Srfc co) { FF c = 2.; FF pSize = uRndmArr[31]*70.;V3 l = V3(pSize,uRndmArr[32]*100.,pSize);V3 cuttingWorld = opRepLim(p-V3(0.,3.,0),c,l);V3 cuttingPlaneSize = V3(pSize,pSize,0.1);Srfc cuttingElements = sdB(cuttingWorld,cuttingPlaneSize,V3(0.),V3(0.),rotateY(uRndmArr[40])*rotateZ(uRndmArr[20])*rotateX(uRndmArr[10]));co = Srfc(ssub(cuttingElements.sd,co.sd),co.col);return co;}Srfc sdSetObjects(V3 p) {V3 pos,c,dim;Srfc co = Srfc(10000.,V3(0.));Srfc tempCo;V3 pt;mat3 rot; FF x,rX,rY;for (int m=0; m<200;m++) {if (m>u_numObjects) break;rX = ( FF(m)*2.+0.5)/dtxS[0];rY = 1.5/dtxS[1];x = TX(dtx,vec2(rX,rY)).r;dim = V3(x,TX(dtx,vec2(( FF(m)*2.+1.5)/ dtxS[0],rY)).r,TX(dtx,vec2(( FF(m)*2.+2.5)/ dtxS[0],rY)).r);rY = 2.5/dtxS[1];c = V3(TX(dtx,vec2(( FF(m)*3.+.5)/ dtxS[0],rY)).r,TX(dtx,vec2(( FF(m)*3.+1.5)/ dtxS[0],rY)).r,TX(dtx,vec2(( FF(m)*3.+2.5)/ dtxS[0],rY)).r);rY = 3.5/dtxS[1];pos = V3(TX(dtx,vec2(( FF(m)*3.+.5)/ dtxS[0],rY)).r,TX(dtx,vec2(( FF(m)*3.+1.5)/ dtxS[0],rY)).r,TX(dtx,vec2(( FF(m)*3.+2.5)/ dtxS[0],rY)).r);rot = rotateX(uRndmArr[int(modm( FF(m),49.))]+uRndmArr[int(modm( FF(m+50),30.))])*rotateY(uRndmArr[int(modm( FF(m)+11.,49.))]+uRndmArr[int(modm( FF(m+32),30.))]);pt = (p-pos)*rot;if (TX(dtx,vec2( FF(m)/ dtxS[0],0)).r == 0.) {co = sadd(co,sdSphere(pt,dim.x,c));} else if (TX(dtx,vec2( FF(m)/ dtxS[0],0)).r == 1.) {co = sadd(co,sdPyramid((pt),dim.x,c));} else if (TX(dtx,vec2( FF(m)/ dtxS[0],0)).r == 2.) {co = sadd(co,sdTriPrism((pt),vec2(dim.x,dim.y),c));}}return co;}Srfc sdScenePartial(V3 p,bool onlyShadows) {p += 0.025*rdn(p.zx);Srfc co = Srfc(10000.,V3(0.));co = sdSetObjects(p);co = sdScene_addPoles(p,co,vec4(0.1,5,0.1,1.));return co;}Srfc sdScene(V3 p,bool onlyShadows) {p += 0.23*uRndmArr[94]*mod(p,5.*uRndmArr[96])*uRndmArr[98];p += 0.5*uRndmArr[93]*fract(p)*uRndmArr[99];Srfc co = Srfc(10000.,V3(0.));co = sadd(co,sdScenePartial(p,onlyShadows)); FF rY = (5.5)/dtxS[1];V3 floorColor = V3(TX(dtx,vec2((.5)/ dtxS[0],rY)).r,TX(dtx,vec2((1.5)/ dtxS[0],rY)).r,TX(dtx,vec2((2.5)/ dtxS[0],rY)).r);co = sadd(co,sdFloor(p,floorColor));if (uRndmArr[1]>0.25){p *= rotateY(uRndmArr[4]*uRndmArr[16]+uRndmArr[4]*uRndmArr[5]);co = sadd(co,sdWall_3(p,V3(0.1,10,0.1),V3(10,0,0),V3(1.),identity())); co = sadd(co,sdWall_3(p,V3(0.1,9,0.1),V3(9,0,0),V3(1.),identity())); co = sadd(co,sdWall_3(p,V3(0.1,8,0.1),V3(8,0,0),V3(1.),identity())); } if (uRndmArr[2]>0.25){p *= rotateY(uRndmArr[1]*uRndmArr[23]+uRndmArr[10]*uRndmArr[6]);co = sadd(co,sdWall_3(p,V3(0.1,10,0.1),V3(10,0,0),V3(1.),identity())); co = sadd(co,sdWall_3(p,V3(0.1,9,0.1),V3(9,0,0),V3(1.),identity())); co = sadd(co,sdWall_3(p,V3(0.1,8,0.1),V3(8,0,0),V3(1.),identity())); } if (uRndmArr[3]>0.75){p *= rotateY(uRndmArr[4]+uRndmArr[16]+uRndmArr[4]+uRndmArr[5]);co = sadd(co,sdWall_3(p,V3(0.1,10,0.1),V3(10,0,0),V3(1.),identity())); co = sadd(co,sdWall_3(p,V3(0.1,9,0.1),V3(9,0,0),V3(1.),identity())); co = sadd(co,sdWall_3(p,V3(0.1,8,0.1),V3(8,0,0),V3(1.),identity())); }if (uRndmArr[4]>0.45){p *= rotateY(uRndmArr[6]*uRndmArr[10]+uRndmArr[5]*uRndmArr[31]);co = sadd(co,sdWall_3(p,V3(0.1,8,0.1),V3(0,0,10),V3(1.),identity())); co = sadd(co,sdWall_3(p,V3(0.1,9,0.1),V3(0,0,9),V3(1.),identity())); co = sadd(co,sdWall_3(p,V3(0.1,10,0.1),V3(0,0,8),V3(1.),identity())); }co = cutWholeSceneWithThings(p,co);return co;}Srfc rayMarch(V3 ro,V3 rd,bool shadow) { FF depth = MIN_DIST;Srfc co;for(int i = 0; i < MAXMARCHINGSTEPSMAX; i++) {if(i > uMaxIter)break;V3 p = ro+depth*rd;co = sdScene(p,shadow);depth += co.sd+0.21;if(co.sd < 0.251*uRndmArr[(i+25)%49]*uRndmArr[i%49]*uRndmArr[(i-9)%49] || depth > MAX_DIST)break;}co.sd = depth;return co;}mat3 camera(V3 cameraPos,V3 lookAtPoint) {V3 cd = normalize(lookAtPoint-cameraPos);V3 cr = normalize(cross(V3(0,1,0),cd));V3 cu = normalize(cross(cd,cr));return mat3(-cr,cu,-cd);}V3 calcNormal(in V3 p,bool shadow) {vec2 e = vec2(1,-1)*EPSILON;return normalize(e.xyy*sdScene(p+e.xyy,shadow).sd+e.yyx*sdScene(p+e.yyx,shadow).sd+e.yxy*sdScene(p+e.yxy,shadow).sd+e.xxx*sdScene(p+e.xxx,shadow).sd);}V3 bC(V3 v,FF b,FF c) {return (v-0.5)*c+0.5+b;}const V3 sunCol = 3.5* V3(1.,0.95,0.94);V3 computeColor(V3 ro,V3 rd,FF sa) {V3 iterCol = V3(0.);V3 accCol = V3(0.);const FF epsilon = 0.0001; FF fdis = 0.;V3 colorMask = V3(1.0); FF rY = 5.5/dtxS[1];V3 lightPosition = V3(TX(dtx,vec2(3.5/ dtxS[0],rY)).r,TX(dtx,vec2(4.5/ dtxS[0],rY)).r,TX(dtx,vec2(5.5/ dtxS[0],rY)).r);for(int m = 0; m < COLORITER; m++) {if(m > uCi)break;rd = normalize(rd);Srfc co = rayMarch(ro,rd,false);if(co.sd > MAX_DIST) {break;} else if(co.sd < 4.*MIN_DIST) {return V3(-1.);} else {if(m == 0)fdis = co.sd;V3 p = ro+rd*co.sd;V3 normal = calcNormal(p,false);colorMask *= co.col;iterCol = V3(0.); FF dif = max(dot(lightPosition,normal),0.0);Srfc sunSha = Srfc(0.,V3(0.3));if(dif > 0.0001)sunSha = rayMarch(p+normal*epsilon*uICEK,lightPosition,true);iterCol += (sunCol*dif*sunSha.sd);accCol += iterCol*colorMask; FF isDif = 0.65;if(hash(sa+1.123+7.7* FF(m)) < isDif) {rd = cD(76.2+73.1* FF(m)+sa+17.7*uFrame,normal);} else { FF glossiness = 0.1;rd = normalize(reflect(rd,normal))+uniformVector(sa+111.123+65.2* FF(m))*glossiness;}ro = p;}}accCol *= exp(-0.1*fdis);return accCol;}void main() {uv = v_texcoord;vec2 uvTex0 = v_texcoord;uv = v_texcoord;uv.y /= aR;uvTex0 = .5*v_texcoord+.5; FF sa = hash(dot(uv,vec2(12.9898,78.233))+1113.1* FF(10.+10.*uFrame/1.));vec4 tI = TX(tex0,vec2(uvTex0.x,uvTex0.y));if(int(uFrame) == 0)tI = vec4(0.0);V3 col = V3(0);V3 lp = uLookAt;V3 camPos = uPosCam;V3 ro = V3(camPos[0],camPos[1],camPos[2]);V3 rd = camera(ro,lp)*normalize(V3(uv,-uCamFl));V3 cC = computeColor(ro,rd,sa);if (cC.x == -1.) {camPos.y *= 0.65;camPos.x *= 0.95;camPos.z *= 1.05;ro = V3(camPos[0],camPos[1],camPos[2]);rd = camera(ro,lp)*normalize(V3(uv,-uCamFl*0.65));cC = computeColor(ro,rd,sa);}col += cC;if(uBW == 1) { FF val = 0.75*col.r+0.52*col.g+0.13*col.y;col = V3(val);}outColor = (vec4(col,1.)+1.*tI);}\n",sh_vs="#version 300 es \nin vec2 a_position;\nout vec2 v_texcoord;\nvoid main() {\n v_texcoord = a_position;\n gl_Position = vec4(v_texcoord, 0, 1);\n}\n",sh_paint_fs="#version 300 es\n#define FF float\nprecision highp FF; out vec4 outColor; in vec2 v_texcoord; uniform vec2 uRes,tS; uniform sampler2D tex; uniform FF iter,u_pA,u_pB,u_pC; uniform int u_time,uF;FF rd(vec2 st) { return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123); }vec3 gB(sampler2D t, vec2 texUV, vec2 sS) { vec3 colOut = vec3(0.0); const int sC = 9; FF gW[sC]; gW[0] = 0.10855; gW[1] = 0.13135; gW[2] = 0.10406; gW[3] = 0.07216; gW[4] = 0.04380; gW[5] = 0.02328; gW[6] = 0.01083; gW[7] = 0.00441; gW[8] = 0.00157; FF gO[sC]; gO[0] = 0.66293; gO[1] = 2.47904; gO[2] = 4.46232; gO[3] = 6.44568; gO[4] = 8.42917; gO[5] = 10.41281; gO[6] = 12.39664; gO[7] = 14.38070; gO[8] = 16.36501; for(int i = 0; i < sC; i++) { vec2 tCO = gO[i] * sS; vec3 col = texture(t, texUV + tCO).xyz + texture(t, texUV - tCO).xyz; col *= gW[i]; colOut += col; } return colOut; }vec3 bC(vec3 v, FF b, FF c) { return (v - 0.5) * c + 0.5 + b; } void main() { vec2 uv= .5*v_texcoord+.5; outColor = texture(tex,uv);FF k1 = pow(FF(uF),0.025); FF rnd = rd(uv * iter); vec3 tN = vec3(0.5, 0.5, 0.5) * rnd; vec3 cOut; vec3 tI = outColor.rgb; vec2 u_dir = vec2(1.,-1.); FF u_br,u_con; u_br = -0.1*k1; u_con = .8759*k1; if(true) { vec3 b1 = gB(tex, uv, tS * u_dir); vec3 b2 = gB(tex, uv, tS*1.15 * vec2(u_dir.x, u_dir.x)); vec3 b3 = gB(tex, uv, tS *0.89* vec2((u_dir.y + u_dir.x) / 2., (u_dir.y + u_dir.x) / 2.)); b1 = 0.6 * b1 + 0.2 * b2 + 0.2 * b3; cOut = 0.75 * bC(tI * (b1 * u_pA + u_pB) + tN * u_pC + 0.03 * tN * (0.5 + b1), u_br, u_con); } else { cOut = 0.99 * tI + tN * u_pC; } outColor = vec4(cOut,1.);outColor = vec4(pow( outColor.rgb, vec3(0.654674545)*k1 ),1.); outColor = outColor*(outColor*2.5953+0.14)/(outColor*(outColor*1.1372+1.934)); outColor = clamp(outColor,vec4(0.),vec4(1.0));}",sh_paint_vs="#version 300 es\nin vec2 a_position;\nout vec2 v_texcoord; \nvoid main() {\n v_texcoord = a_position;\n gl_Position = vec4(v_texcoord, 0, 1);\n}";class Random{constructor(){this.uA=!1;let r=function(r){let e=parseInt(r.substr(0,8),16),t=parseInt(r.substr(8,8),16),o=parseInt(r.substr(16,8),16),a=parseInt(r.substr(24,8),16);return function(){var r=((e|=0)+(t|=0)|0)+(a|=0)|0;return a=a+1|0,e=t^t>>>9,t=(o|=0)+(o<<3)|0,o=(o=o<<21|o>>>11)+r|0,(r>>>0)/4294967296}};this.pA=new r(tD.hash.substr(2,32)),this.pB=new r(tD.hash.substr(34,32));for(let r=0;r<1e6;r+=2)this.pA(),this.pB()}rd(){return this.uA=!this.uA,this.uA?this.pA():this.pB()}rn(r,e){return r+(e-r)*this.rd()}ri(r,e){return Math.floor(this.rn(r,e+1))}rc(r){return r[this.ri(0,r.length-1)]}rmM(r){return this.rn(r[0],r[1])}rSign(){return(-1)**this.rc([0,1])}}let R=new Random;class color{constructor(r,e,t,o=1){this.r=r,this.g=e,this.b=t,this.a=o}}class aVector{constructor(r,e,t){this.x=r,this.y=e,this.z=t}}class aRect{constructor(r,e,t,o,a){this.a=r,this.b=e,this.c=t,this.d=o,this.recursionLevel=a,this.w=Math.abs(this.b.x-this.a.x),this.h=Math.abs(this.c.y-this.a.y),this.cP=cV((this.a.x+this.b.x+this.c.x+this.d.x)/4,(this.a.y+this.b.y+this.c.y+this.d.y)/4),this.ar=this.w*this.h,this.col=R.rc(pltArr)}divide(r,e){let t=this.a,o=this.b,a=this.c,i=this.d;return e>0?[new aRect(t,o,cV(a.x,t.y+this.h*r),cV(i.x,o.y+this.h*r),this.recursionLevel+1),new aRect(cV(a.x,t.y+this.h*r),cV(i.x,o.y+this.h*r),a,i,this.recursionLevel+1)]:[new aRect(t,cV(t.x+this.w*r,o.y),a,cV(a.x+this.w*r,i.y),this.recursionLevel+1),new aRect(cV(t.x+this.w*r,o.y),o,cV(a.x+this.w*r,i.y),i,this.recursionLevel+1)]}}function gC(r,e=255,t="rand",o=0,a=.1,i=!0,n=pltArr){pn=R.rc(r),tp=n[pn],cS="rand"==t?R.rc(tp):tp[o%tp.length];let d=new color(Number("0x"+cS[0]+cS[1])/255,Number("0x"+cS[2]+cS[3])/255,Number("0x"+cS[4]+cS[5])/255,Math.floor(e));return new color(d.r*(1+R.rn(-a,a)),d.g*(1+R.rn(-a,a)),d.b*(1+R.rn(-a,a)),e)}function gCwN(r,e,t){return color(red(r)*(1+R.rn(-e,e)),green(r)*(1+R.rn(-e,e)),blue(r)*(1+R.rn(-e,e)),t)}const pltArr={marine:["e63946","f1faee","a8dadc","457b9d","1d3557","e63946","f1faee","a8dadc","457b9d","1d3557"],gold:["ffdc73","ffcf40","ffbf00","bf9b30","a67c00","FFF9CB","ffdc73","ffcf40","ffbf00","bf9b30","a67c00","FFF9CB"],bw:["fefefe","100702","fefefe","100702","fefefe","100702","fefefe","100702","fefefe","100702","fefefe","100702"],"warm tones":["e53d00","f29300","f9be00","ffe900","fef47c","fcfff7","8fd0cc","21a0a0","046865"],"c-1":["256eff","46237a","3ddc97","9decca","fcfcfc","fea3ac","ff495c"],"c-2":["e6c229","f17105","d11149","6610f2","1a8fe3"],"c-3":["e6c229","f17105","d11111","274d70","0f803d","374007"],"c-4":["e6c229","fffbda","fff4cc","d11111","274d70","0f803d","374007","201510","e6c229","fffbda","fff4cc","d11111","274d70","0f803d","374007","201510"]},bgP={a:["303030","F0E9E1","f2df0b","eb5e28","fe4432","20de50","2D6DD2","CC6205"]};function qt(r,e,t,o,a,i=0,n=[.5]){if(0==t)return[r];if(e>t||R.rd()<a)return[r];let d=[],c=[];if(1==(c=r.divide(n,o)).length)return[r];for(let r=0;r<c.length;r++){let n=[];n=qt(c[r],e+1,t,-o,a,i),d.push(...n)}return d}function cV(r,e,t){return new aVector(r,e,t)}var baseR,dataTexture,dP={},baseGrid=[],objShapes=[],objSizesW=[],objSizesH=[],objColorsR=[],objColorsG=[],objColorsB=[],objPosX=[],objPosY=[],objPosZ=[],objSizes=[],objPos=[],objColors=[],objData=[];function sAP(){for(let r=0;r<100;r++)R.rd();let r;dP.globalResK=1,dP.pd=devicePixelRatio,dP.globalAspectRatio=.7,piAR=dP.globalAspectRatio,innerWidth/innerHeight<=piAR?(dP.sW=innerWidth,dP.sH=innerWidth/piAR):(dP.sH=innerHeight,dP.sW=innerHeight*piAR),dP.baseGridMaxIter=5,dP.baseGridProbSplit=.2325,dP.baseGridProbSkipThis=0,dP.objShapes=[0,1,2],dP.thePalettes=[R.rc(Object.keys(pltArr))],dP.colorSchemeType=R.rd()<.5?"rand":"index",dP.qtT=R.rc([.33,.5,.66]),dP.numRnd=50,baseR=new aRect(cV(0,0),cV(dP.sW,0),cV(0,dP.sH),cV(dP.sW,dP.sH),0),baseGrid=qt(baseR,0,dP.baseGridMaxIter,(-1)**R.rc([0,1]),dP.baseGridProbSplit,dP.baseGridProbSkipThis,dP.qtT),dP.dataTextureWidth=Math.max(dP.numRnd,3*baseGrid.length),dP.dataTextureHeight=6;let e=7+R.rn(-1.5,1.5),t=0*dP.sW/2,o=0;dataTexture=new Float32Array(dP.dataTextureWidth*dP.dataTextureHeight);let a=R.rn(2.25,3);for(let i=0;i<baseGrid.length;i++)objShapes.push(R.rc(dP.objShapes)),dataTexture[i]=R.rc(dP.objShapes),o=1,dataTexture[dP.dataTextureWidth*o+2*i]=(1+.5*R.rd())*baseGrid[i].w/dP.sW,dataTexture[dP.dataTextureWidth*o+2*i+1]=(1+.5*R.rd())*baseGrid[i].h/dP.sW,dataTexture[dP.dataTextureWidth*o+2*i+2]=(1+.5*R.rd())*baseGrid[i].h/dP.sW,r=gC(dP.thePalettes,255,dP.colorSchemeType,i,.1,!0),o=2,dataTexture[dP.dataTextureWidth*o+3*i]=r.r,dataTexture[dP.dataTextureWidth*o+3*i+1]=r.g,dataTexture[dP.dataTextureWidth*o+3*i+2]=r.b,o=3,dataTexture[dP.dataTextureWidth*o+3*i]=e*(baseGrid[i].cP.y-t)/dP.sW,dataTexture[dP.dataTextureWidth*o+3*i+1]=a,dataTexture[dP.dataTextureWidth*o+3*i+2]=e*(baseGrid[i].cP.x-t)/dP.sW,o=4,dataTexture[dP.dataTextureWidth*o+i]=R.rn(-1,1);o=5,r=gC(["a"],255,"rand",0,.1,!0,bgP),dP.debugBGcolor=r;let i=0;dataTexture[dP.dataTextureWidth*o+3*i]=r.r,dataTexture[dP.dataTextureWidth*o+3*i+1]=r.g,dataTexture[dP.dataTextureWidth*o+3*i+2]=r.b,i=1,dataTexture[dP.dataTextureWidth*o+3*i]=R.rSign()*R.rn(2,6),dataTexture[dP.dataTextureWidth*o+3*i+1]=R.rc([.75*a,R.rn(1.5,3)*a,R.rn(1.5,3)*a,R.rn(1.5,3)*a]),dataTexture[dP.dataTextureWidth*o+3*i+2]=R.rSign()*R.rn(2,6),dP.viewOffset=R.rn(-3,3),dP.camPos=[],dP.camPos[0]=cV(e/2+.1+dP.viewOffset,9.5,e/2+dP.viewOffset),dP.rndmArr=[];for(let r=0;r<50;r++)dP.rndmArr.push(R.rd());for(let r=50;r<97;r++)dP.rndmArr.push(R.rn(-1,1));dP.rndmArr.push(R.rc([0,0,1])),dP.rndmArr.push(R.rc([0,0,1])),dP.rndmArr.push(R.rc([0,1,1,1])),dP.uFrame=1,dP.uLookAt=cV(e/2+dP.viewOffset,0,e/2+dP.viewOffset),dP.uMaxIter=R.rc([32,64,96]),dP.uCi=7,dP.uVi=0,dP.uISLK=.15250521,dP.uICEK=.004842021,dP.uISEK=.131000000321,dP.uIVEK=.00196500000421,dP.uGCk=1,dP.uCamFl=1.47569015,dP.uBW=R.rd()<.15,dP.shTSK=1.5,dP.shA=1.095,dP.shB=.645,dP.shC=.4,dP.shDir=[R.rSign()*R.rn(1,3),R.rSign()*R.rn(1,3)],dP.nK=1e5*R.rd(),readURLParams()}const saveBlob=function(){const r=document.createElement("a");return document.body.appendChild(r),r.style.display="none",function(e,t){const o=window.URL.createObjectURL(e);r.href=o,r.download=t,r.click()}}();function createShader(r,e,t){var o=r.createShader(e);if(r.shaderSource(o,t),r.compileShader(o),r.getShaderParameter(o,r.COMPILE_STATUS))return o;r.deleteShader(o)}function createProgram(r,e,t){var o=r.createProgram();if(r.attachShader(o,e),r.attachShader(o,t),r.linkProgram(o),r.getProgramParameter(o,r.LINK_STATUS))return o;r.deleteProgram(o)}function setTexcoords(r){r.bufferData(r.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,0,1]),r.STATIC_DRAW)}var vertexShader,fragmentShader,program,program2,positionAttributeLocation,positionBuffer,positions,vao,imageLocation,uF,u_timeUnLoc,uFrameUnLoc,uCiUnLoc,uMaxIterUnLoc,flipYLocation,iterUnLoc,flipYLocation2,doSave=!1;function init1(){vertexShader=createShader(gl,gl.VERTEX_SHADER,sh_vs),fragmentShader=createShader(gl,gl.FRAGMENT_SHADER,sh_fs),program=createProgram(gl,vertexShader,fragmentShader),positionAttributeLocation=gl.getAttribLocation(program,"a_position"),texCoordAttributeLocation=gl.getAttribLocation(program,"a_texcoord"),positionBuffer=gl.createBuffer(),gl.bindBuffer(gl.ARRAY_BUFFER,positionBuffer),positions=[-1,-1,-1,1,1,-1,1,1],gl.bufferData(gl.ARRAY_BUFFER,new Float32Array(positions),gl.STATIC_DRAW),vao=gl.createVertexArray(),gl.bindVertexArray(vao),gl.enableVertexAttribArray(positionAttributeLocation);var r=gl.FLOAT;gl.vertexAttribPointer(positionAttributeLocation,2,r,!1,0,0)}function init2(){vertexShader=createShader(gl,gl.VERTEX_SHADER,sh_paint_vs),fragmentShader=createShader(gl,gl.FRAGMENT_SHADER,sh_paint_fs),program2=createProgram(gl,vertexShader,fragmentShader),positionAttributeLocation=gl.getAttribLocation(program2,"a_position"),positionBuffer=gl.createBuffer(),gl.bindBuffer(gl.ARRAY_BUFFER,positionBuffer),positions=[-1,-1,-1,1,1,-1,1,1],gl.bufferData(gl.ARRAY_BUFFER,new Float32Array(positions),gl.STATIC_DRAW),vao=gl.createVertexArray(),gl.bindVertexArray(vao),gl.enableVertexAttribArray(positionAttributeLocation);var r=gl.FLOAT;gl.vertexAttribPointer(positionAttributeLocation,2,r,!1,0,0)}function initDataTexture(){var r=gl.createTexture();gl.activeTexture(gl.TEXTURE0),gl.bindTexture(gl.TEXTURE_2D,r);{const r=0,e=gl.R32F,t=dP.dataTextureWidth,o=dP.dataTextureHeight,a=0,i=gl.RED,n=gl.FLOAT;gl.pixelStorei(gl.UNPACK_ALIGNMENT,1),gl.texImage2D(gl.TEXTURE_2D,r,e,t,o,a,i,n,dataTexture),gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.NEAREST),gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,gl.NEAREST),gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.CLAMP_TO_EDGE),gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.CLAMP_TO_EDGE)}}function initDataTextureAsFrameBuffer(){var r=createAndSetupTexture(gl);gl.activeTexture(gl.TEXTURE0+0),gl.bindTexture(gl.TEXTURE_2D,r);var e=gl.R32F,t=gl.RED,o=gl.FLOAT;gl.pixelStorei(gl.UNPACK_ALIGNMENT,1),gl.texImage2D(gl.TEXTURE_2D,0,e,dP.dataTextureWidth,dP.dataTextureHeight,0,t,o,dataTexture);var a=gl.createFramebuffer();gl.bindFramebuffer(gl.FRAMEBUFFER,a);var i=gl.COLOR_ATTACHMENT0;gl.framebufferTexture2D(gl.READ_FRAMEBUFFER,i,gl.TEXTURE_2D,r,0)}function createAndSetupTexture(r){var e=r.createTexture();return r.bindTexture(r.TEXTURE_2D,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),e}function initRenderbuffer(){const r=gl.canvas.width,e=gl.canvas.height;gl.bindTexture(gl.TEXTURE_2D,targetTexture);{const t=0,o=gl.RGBA,a=0,i=gl.RGBA,n=gl.UNSIGNED_BYTE,d=null;gl.texImage2D(gl.TEXTURE_2D,t,o,r,e,a,i,n,d),gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.LINEAR),gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.CLAMP_TO_EDGE),gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.CLAMP_TO_EDGE);const c=gl.createFramebuffer();gl.createFramebuffer();gl.bindFramebuffer(gl.FRAMEBUFFER,c);const s=gl.COLOR_ATTACHMENT0;gl.framebufferTexture2D(gl.FRAMEBUFFER,s,gl.TEXTURE_2D,targetTexture1,t)}}function initUniforms(){var r=gl.getUniformLocation(program,"u_numObjects"),e=gl.getUniformLocation(program,"uRndmArr");uFrameUnLoc=gl.getUniformLocation(program,"uFrame");var t=gl.getUniformLocation(program,"uPosCam"),o=gl.getUniformLocation(program,"uLookAt");uMaxIterUnLoc=gl.getUniformLocation(program,"uMaxIter");var a=gl.getUniformLocation(program,"uISLK"),i=gl.getUniformLocation(program,"uICEK"),n=gl.getUniformLocation(program,"uISEK"),d=gl.getUniformLocation(program,"uIVEK"),c=gl.getUniformLocation(program,"uGCk"),s=gl.getUniformLocation(program,"uCamFl"),u=gl.getUniformLocation(program,"uRes");uCiUnLoc=gl.getUniformLocation(program,"uCi");var l=gl.getUniformLocation(program,"uVi"),m=gl.getUniformLocation(program,"uBW");flipYLocation=gl.getUniformLocation(program,"flipY");var f=gl.getUniformLocation(program,"aR");imageLocation=gl.getUniformLocation(program,"tex0");var g=gl.getUniformLocation(program,"dtx"),h=gl.getUniformLocation(program,"dtxS");gl.uniform1i(r,objShapes.length),gl.uniform1fv(e,new Float32Array(dP.rndmArr)),gl.uniform1f(uFrameUnLoc,dP.uFrame),gl.uniform3f(t,dP.camPos[0].x,dP.camPos[0].y,dP.camPos[0].z),gl.uniform3f(o,dP.uLookAt.x,dP.uLookAt.y,dP.uLookAt.z),gl.uniform1i(uMaxIterUnLoc,dP.uMaxIter),gl.uniform1f(a,dP.uISLK),gl.uniform1f(i,dP.uICEK),gl.uniform1f(n,dP.uISEK),gl.uniform1f(d,dP.uIVEK),gl.uniform1f(c,dP.uGCk),gl.uniform1f(s,dP.uCamFl),gl.uniform2f(u,canvas.width,canvas.height),gl.uniform1i(uCiUnLoc,dP.uCi),gl.uniform1i(l,dP.uVi),gl.uniform1i(m,dP.uBW),gl.uniform2fv(h,new Float32Array([dP.dataTextureWidth,dP.dataTextureHeight])),gl.uniform1i(g,0),gl.uniform1f(f,dP.globalAspectRatio)}function initUniforms2(){var r=gl.getUniformLocation(program2,"uRes"),e=gl.getUniformLocation(program2,"u_pA"),t=gl.getUniformLocation(program2,"u_pB"),o=gl.getUniformLocation(program2,"u_pC"),a=gl.getUniformLocation(program2,"tS"),i=gl.getUniformLocation(program2,"u_dir");uF=gl.getUniformLocation(program2,"uF"),flipYLocation2=gl.getUniformLocation(program2,"u_flipY"),iterUnLoc=gl.getUniformLocation(program2,"iter"),u_timeUnLoc=gl.getUniformLocation(program2,"u_time"),gl.uniform2f(r,canvas.width,canvas.height),gl.uniform1f(e,dP.shA),gl.uniform1f(t,dP.shB),gl.uniform1f(o,dP.shC),gl.uniform2f(a,1*dP.shTSK/canvas.width,1*dP.shTSK/canvas.h