memoscan
← all memos

Memo 0xe21cfe0a…60b1fa on Ethereum

1:0),A("lineColor","3f",b),A("highlightColor","3f",Pe($e.stroke[0])),A("gridWidth","1f",y),A("gridMarginX","1f",C),A("gridMarginY","1f",D),A("randomValues","1fv",this.randomValues),A("randomValuesLength","1i",this.randomValues.length),A("randomSeed","1f",v),A("drawGrid","1i",po?1:0),A("gridLineWeight","1f",vo),A("drawGridDivisions","1i",go),A("shadingStrength","1f",p),A("waveNoiseMapEnabled","1i",Mt?1:0),A("waveWarpX","1i",Ot?1:0),A("waveWarpY","1i",Ft?1:0),A("waveOffAxisY","1i",Vt?1:0),A("waveOffAxisX","1i",Nt?1:0),A("waveWarpXMult","1f",zt),A("waveWarpYMult","1f",Ut),A("waveWarpDivisor","1f",Tt),A("uvSpiralMap","1fv",Ho)),A("paletteSwapWarpEnabled","1i",Jt?1:0),A("paletteSwapWarpScale","1f",Kt),A("paletteSwapArmWidth","1f",Qt),A("paletteSwapNoiseOffset","1f",Zt),A("paletteSwapInverted","1i",0),A("warpLayer","1i",f?1:0),A("uvWarpScale","1f",Bt),A("uvWarpStrength","1f",Pt),A("uvGlitchEnabled","1i",0),A("uvSpiralizeEnabled","1i",Et?1:0),A("uvSpiralizeStrength","1f",Rt),A("uvSpiralizeNoiseMapEnabled","1i",1),A("uvSpiralizeScale","1f",Wt),A("drawFaces","1i",c?1:0),A("drawOutlines","1i",h?1:0),A("strokeBorder","1i",m?1:0),A("gridBleedThrough","1i",l?1:0),A("depthInScene","1f",s),A("detailSwitch","1i",u),A("detailArray","1iv",d),A("isBackground","1i",g?1:0),A("paletteAccentArray","3fv",r.flat()),A("paletteAccentArrayLength","1i",r.length),A("altPaletteAccentArray","3fv",n.flat()),A("altPaletteAccentArrayLength","1i",n.length);const k=o.reduce(((e,t)=>e+t.length),0),L=new Float32Array(2*k),B=new Uint32Array(2*o.length),P=o.length;let E=0,W=0;for(let t of o){let o=t.flat();L.set(o,E),B.set([e(E/2),e(o.length/2)],W),W+=2,E+=o.length}if(A("polyVertices","2fv",L),A("polyIndices","2uiv",B),A("numPolygons","1i",P),S.drawArrays(S.TRIANGLE_FAN,0,4),this.renderCount%10==0){const e=new Uint8Array(4);S.readPixels(0,0,1,1,S.RGBA,S.UNSIGNED_BYTE,e)}this.renderCount++}}let jo,qo=[],Ho=[],$o=0,{parse:Jo,stringify:Ko}=JSON,Qo=e=>Jo(Ko(e));const Zo=()=>{let e=qo[$o];if(!e)return!0;let t=!1;if(st||vt>0){let o=!1;e:for(let r of e)if("bg"!==r.label){if(st)for(let e of r.poly){const[o,r]=e;let n=ke(ft),i=R(X(o/ft,r/ft,0),n.min,n.max,-Xe*ut,Xe*ut);if(o<ct-tt+i||o>Vo-ct+tt+i||r<0+ct-ot+i||r>No-ct+ot+i||o<ct-tt||o>Vo-ct+tt||r<0+ct-ot||r>No-ct+ot){t=!0;break e}}}else o=!0;t||o||(t=S.bool(vt))}if(0===e.length||t)return $o++,!1;let o=S.bool(ht);const r=j(e.map((e=>e.poly)).flat()),n=S.bool(to)?r:null;let{palette:i,isBackground:s}=Te(e,Ve.base,n),{palette:f,isBackground:c}=Te(e,Ve.alt,n),u=s||c;const d=e.map((e=>e.poly)).map((e=>e.map((e=>[e[0],No-e[1]])))).map((e=>e.map((e=>[E(e[0],1),E(e[1],1)])))),h=function(e,t=0){if(0===e.length)throw new Error("Polygons array cannot be empty.");let o=1/0,r=1/0,n=-1/0,i=-1/0;for(const t of e)for(const[e,s]of t)o=l(o,e),r=l(r,s),n=a(n,e),i=a(i,s);return[[o-t,r-t],[n+t,r-t],[n+t,i+t],[o-t,i+t]]}(d,3*rt);let p=Lt&&$o%1==0;u&&(p=!1);let g=e.map((e=>e.detail));return jo.render({polygons:d,isBackground:u,backgroundColor:We[Ve.base].bg[0],gridBleedThrough:S.bool(mo),shadingStrength:pt,lineColor:We[Ve.base].line[0],paletteByIdx:i,paletteByIdx2:f,outerPolygon:h,details:g,depthInScene:$o/qo.length,warpLayer:p,drawFaces:!0,drawOutlines:o,strokeBorder:at,lineThickness:jt,lineContrast:qt}),$o++,!1},er=()=>{if(Io)return;const t=function*(){jo=new _o(Ro,"#version 300 es\nprecision highp float;precision highp int;\n#define GLSLIFY 1\nin vec2 a_position;uniform vec2 resolution;uniform vec2 scaledResolution;void main(){vec2 rescaledPosition=a_position*(resolution/scaledResolution);vec2 clipSpacePosition=rescaledPosition/(resolution/2.0)-1.0;gl_Position=vec4(clipSpacePosition,.0,1.0);}","#version 300 es\nprecision highp float;precision highp int;\n#define GLSLIFY 1\nuniform vec3 highlightColor;uniform vec3 backgroundColor;uniform vec3 paletteAccentArray[50];uniform int paletteAccentArrayLength;uniform int desaturate;uniform float margin;uniform int numPolygons;uniform vec2 polyVertices[128];uniform uvec2 polyIndices[128];uniform float gridWidth;uniform float gridMarginX;uniform float gridMarginY;uniform int drawGrid;uniform float gridLineWeight;uniform int drawGridDivisions;uniform int gridBleedThrough;uniform int detailArray[50];uniform int warpLayer;uniform float uvWarpScale;uniform float uvWarpStrength;uniform int waveNoiseMapEnabled;uniform int waveWarpX;uniform int waveWarpY;uniform int waveOffAxisY;uniform int waveOffAxisX;uniform float waveWarpXMult;uniform float waveWarpYMult;uniform float waveWarpDivisor;uniform int uvSpiralizeEnabled;uniform int uvSpiralizeNoiseMapEnabled;uniform float uvSpiralizeStrength;uniform float uvSpiralizeScale;uniform float uvSpiralMap[256];uniform int paletteSwapWarpEnabled;uniform int paletteSwapInverted;uniform float paletteSwapWarpScale;uniform float paletteSwapNoiseOffset;uniform float paletteSwapArmWidth;uniform int isBackground;uniform int drawOutlines;uniform int strokeBorder;uniform float shadingStrength;uniform float lineContrast;uniform float lineThickness;uniform vec3 lineColor;uniform float randomValues[256];uniform vec2 resolution;uniform vec2 scaledResolution;uniform vec3 altPaletteAccentArray[50];uniform int altPaletteAccentArrayLength;out vec4 outColor;const float pixelAA=1.5f;vec3 mod289(vec3 x){return x-floor(x*(1.0f/289.0f))*289.0f;}vec2 mod289(vec2 x){return x-floor(x*(1.0f/289.0f))*289.0f;}vec3 permute(vec3 x){return mod289(((x*34.0f)+10.0f)*x);}float snoise2D(vec2 v){const vec4 C=vec4(0.211324865405187f,0.366025403784439f,-0.577350269189626f,0.024390243902439f);vec2 i=floor(v+dot(v,C.yy));vec2 x0=v-i+dot(i,C.xx);vec2 i1;i1=(x0.x>x0.y)? vec2(1.0f,0.0f): vec2(0.0f,1.0f);vec4 x12=x0.xyxy+C.xxzz;x12.xy-=i1;i=mod289(i);vec3 p=permute(permute(i.y+vec3(0.0f,i1.y,1.0f))+i.x+vec3(0.0f,i1.x,1.0f));vec3 m=max(0.5f-vec3(dot(x0,x0),dot(x12.xy,x12.xy),dot(x12.zw,x12.zw)),0.0f);m=m*m;m=m*m;vec3 x=2.0f*fract(p*C.www)-1.0f;vec3 h=abs(x)-0.5f;vec3 ox=floor(x+0.5f);vec3 a0=x-ox;m*=1.79284291400159f-0.85373472095314f*(a0*a0+h*h);vec3 g;g.x=a0.x*x0.x+h.x*x0.y;g.yz=a0.yz*x12.xz+h.yz*x12.yw;return 130.0f*dot(m,g);}const float PI=acos(-1.f);float remap(float t,float a1,float b1,float a2,float b2){return a2+(b2-a2)*((t-a1)/(b1-a1));}float aastep(float threshold,float value){float afwidth=length(vec2(dFdx(value),dFdy(value)))*0.70710678118654757f;return smoothstep(threshold-afwidth,threshold+afwidth,value);}float hue2rgb(float p,float q,float t){if(t<0.0f)t+=1.0f;if(t>1.0f)t-=1.0f;if(t<1.0f/6.0f)return p+(q-p)*6.0f*t;if(t<1.0f/2.0f)return q;if(t<2.0f/3.0f)return p+(q-p)*(2.0f/3.0f-t)*6.0f;return p;}vec3 rgb2hsl(vec3 color){float fmin=min(min(color.r,color.g),color.b);float fmax=max(max(color.r,color.g),color.b);float delta=fmax-fmin;vec3 hsl;hsl.z=(fmax+fmin)/2.0f;if(delta==0.0f){hsl.x=0.0f;hsl.y=0.0f;}else{hsl.y=hsl.z>0.5f ? delta/(2.0f-fmax-fmin): delta/(fmax+fmin);float deltaR=(((fmax-color.r)/6.0f)+(delta/2.0f))/delta;float deltaG=(((fmax-color.g)/6.0f)+(delta/2.0f))/delta;float deltaB=(((fmax-color.b)/6.0f)+(delta/2.0f))/delta;if(color.r==fmax)hsl.x=deltaB-deltaG;else if(color.g==fmax)hsl.x=(1.0f/3.0f)+deltaR-deltaB;else if(color.b==fmax)hsl.x=(2.0f/3.0f)+deltaG-deltaR;if(hsl.x<0.0f)hsl.x+=1.0f;if(hsl.x>1.0f)hsl.x-=1.0f;}return hsl;}vec3 hsl2rgb(vec3 hsl){if(hsl.y==0.0f){return vec3(hsl.z);}else{float q=hsl.z<0.5f ? hsl.z*(1.0f+hsl.y): hsl.z+hsl.y-hsl.z*hsl.y;float p=2.0f*hsl.z-q;return vec3(hue2rgb(p,q,hsl.x+1.0f/3.0f),hue2rgb(p,q,hsl.x),hue2rgb(p,q,hsl.x-1.0f/3.0f));}}float fbm(vec2 v,int octaves,float frequency,float amplitude){float total=0.0f;float maxAmplitude=0.0f;for(int i=0;i<octaves;i++){total+=snoise2D(v*frequency)*amplitude;maxAmplitude+=amplitude;frequency*=2.0f;amplitude*=0.5f;}return total/maxAmplitude;}float pointLineSegSDF(vec2 p,vec2 a,vec2 b){vec2 pa=p-a;vec2 ba=b-a;float t=clamp(dot(pa,ba)/dot(ba,ba),0.0f,1.0f);return length(pa-ba*t);}bool isIntersecting(vec2 point,vec2 p1,vec2 p2){if(p1.y==p2.y){return false;}if(p1.y>point.y&&p2.y>point.y){return false;}if(p1.y<point.y&&p2.y<point.y){return false;}float intersectionX=p1.x+(point.y-p1.y)*(p2.x-p1.x)/(p2.y-p1.y);return intersectionX>point.x;}vec3 drawGridLines(vec2 uv,vec3 color,float gridDivisions,float brightness,vec3 lineBaseColor,bool bleedThrough){if(drawGrid==0)return color;brightness=1.05f-brightness;vec2 bounds=scaledResolution;float intensity=(bleedThrough||isBackground==1)? 0.28f : 0.42f;vec2 pos=uv-vec2(gridMarginX,gridMarginY)+gridLineWeight;float lineWeightNoise=snoise2D((pos+randomValues[10])/50.f)*.07f;float motionNoise=snoise2D((pos+randomValues[12])/9e1f)*.3f;pos+=motionNoise;float opacityNoise=clamp(snoise2D((pos+randomValues[13]))*0.25f,-1.f,0.1f);float offsetNoise=snoise2D((pos+randomValues[11])/20.f)*.1f;pos+=(offsetNoise);float borderDist=min(min(uv.x,bounds.x-uv.x),min(uv.y,bounds.y-uv.y));float lineDist=min(mod(pos.x,gridWidth/gridDivisions),mod(pos.y,gridWidth/gridDivisions));float lineWeight=gridLineWeight-lineWeightNoise;float borderWarp=(snoise2D((pos+randomValues[15])/50.f)-1.f)*40.f;float edgeFactor=smoothstep(30.f-borderWarp,10.f,borderDist);float colorLerp=remap(edgeFactor,0.f,1.f,clamp(0.6f+lineWeightNoise-opacityNoise+intensity+brightness,0.f,1.f),1.f);vec3 lineColor=mix(hsl2rgb(lineBaseColor),hsl2rgb((color)),colorLerp);float lineFactor=aastep(lineWeight*2.f,lineDist);return rgb2hsl(mix(lineColor,hsl2rgb(color),lineFactor));}vec2 pinchUV(vec2 uv){vec2 center=vec2(scaledResolution.x/2.f,scaledResolution.y/2.f);vec2 toCenter=center-uv;float distance=length(toCenter);float influence=remap(pow(distance,1.35f),0.f,scaledResolution.y/2.f,0.001f,.0f);return uv-(toCenter*influence);}vec2 lightBend(vec2 uv){if(isBackground==1)return uv;vec2 warpOffset=vec2(remap(randomValues[18],0.f,1.f,-1e3f,1e3f),remap(randomValues[19],0.f,1.f,-1e3f,1e3f));vec2 warpOffset2=vec2(remap(randomValues[20],0.f,1.f,-1e1f,1e1f),remap(randomValues[21],0.f,1.f,-1e1f,1e1f));vec2 pos=((uv+warpOffset)/1e4f);float direction=snoise2D((pos*4.f)+warpOffset2)*(2.f*PI);vec2 vector=vec2(cos(direction),sin(direction));float warpAmount=randomValues[22]*2.f;pos+=(vector*warpAmount);uv+=pos;return uv;}vec2 warpUvSimple(vec2 uv){float warpStrength=8e1f*uvWarpStrength;vec2 warpSpread=vec2(1.f)*uvWarpScale;vec2 warpOffset=vec2(remap(randomValues[1],0.f,1.f,-2e3f,2e3f),remap(randomValues[2],0.f,1.f,-2e3f,2e3f));float noiseMask=snoise2D((uv/warpSpread+warpOffset)/2.6e2f)+0.2f;float noiseMask2=snoise2D((uv/warpSpread+warpOffset)/6.5e2f);float noiseWarped=snoise2D(vec2(uv.x/3e1f*noiseMask2,uv.y/12e2f*noiseMask));float noiseWarped2=snoise2D(vec2(uv.x/3e2f*noiseMask2,uv.y/12e2f*noiseMask));noiseMask=clamp(noiseMask,0.f,1e10f);float result=((noiseWarped*1.f)*(noiseWarped2*1.f))*noiseMask;uv+=result*warpStrength;return uv;}vec2 warpChoice(vec2 uv){if(isBackground!=1){uv+=(fbm(uv,2,.004f,1.f)*2.f);}if(warpLayer==0)return uv;return warpUvSimple(uv);}vec2 rotateUvs(vec2 uv,vec2 lensCenter,float lensRadius,float magnification,float rotation){if(isBackground==1)return uv;vec2 translated=uv-lensCenter;float dist=length(translated);float normalizedDist=dist/lensRadius;if(normalizedDist>1.f)return uv;float angle=rotation*pow((1.f-normalizedDist),3.f);mat2 rot=mat2(cos(angle),-sin(angle),sin(angle),cos(angle));vec2 rotatedTranslated=(rot*translated)+lensCenter;return rotatedTranslated;}float getColourPaletteSwapWarp(vec2 uv){if(paletteSwapWarpEnabled==0)return 0.f;float warpOffset=remap(randomValues[10],0.f,1.f,-1e4f,1e4f);float noiseOffset=paletteSwapNoiseOffset*1e2f;float noiseMult=snoise2D((uv+warpOffset)/6e1f*paletteSwapWarpScale);float noiseMult2=snoise2D((uv+warpOffset)/(6e1f+noiseOffset)*paletteSwapWarpScale);float warpOffsetNoise=noiseMult*noiseMult2;warpOffsetNoise=smoothstep(0.f,paletteSwapArmWidth,warpOffsetNoise);float result=aastep(0.01f,warpOffsetNoise);if(paletteSwapInverted==1){return result;}else{return 1.f-result;}}vec3 noisePass(vec2 uv,vec3 color,float influence,int index){uv=uv+remap(randomValues[10+index],0.f,1.f,1.f,1e6f);float noiseMask=smoothstep(0.f,0.3f,fbm(uv,3,.01f,1.0f));float noiseMaskLarge=smoothstep(0.f,0.1f,fbm(uv,7,.04f,1.0f));float bigMask=noiseMask*noiseMaskLarge;float genericNoiseDivisor=4.f;float lumDarkDivisor=isBackground==1 ? 40.f : 35.f;float lumLightDivisor=isBackground==1 ? 30.f : 20.f;float subtleLuminanceWarpDark=fbm(uv,10,0.004f,.01f)/lumDarkDivisor;float subtleLuminanceWarpLight=fbm(uv,12,0.003f,.01f)/lumLightDivisor;float detailedLuminanceWarpDark=(fbm(uv,5,0.01f,.00001f)*bigMask)/20.f;float detailedLuminanceWarpLight=(fbm(uv,8,0.02f,.00001f)*bigMask)/25.f;float noisierValueLight=aastep(0.4f,fbm(uv,4,0.28f,1.0f))/11.f;float noisierValueDark=aastep(0.4f,fbm(uv,4,0.24f,1.0f))/15.f;float genericNoiseLight=aastep(0.6f,fbm(uv,6,0.35f,1.0f))/genericNoiseDivisor;float genericNoiseDark=aastep(0.6f,fbm(uv,12,0.33f,1.0f))/(genericNoiseDivisor*2.f);float luminanceShift=-subtleLuminanceWarpDark;luminanceShift-=subtleLuminanceWarpLight;luminanceShift-=detailedLuminanceWarpDark;luminanceShift+=detailedLuminanceWarpLight;luminanceShift+=noisierValueLight;luminanceShift-=noisierValueDark;luminanceShift+=genericNoiseLight;luminanceShift-=genericNoiseDark;float saturationShift=(subtleLuminanceWarpDark/2.f);vec3 outColor=vec3(color.x,color.y+saturationShift,color.z+luminanceShift);vec3 noisyBackground=vec3(backgroundColor.x,backgroundColor.y+saturationShift,backgroundColor.z+luminanceShift);float nastyMarksMoiseMask=smoothstep(0.4f,0.41f,fbm(uv,20,.005f*noiseMask,.0001f));float nastyMarks=aastep(-0.54f,fbm(uv*nastyMarksMoiseMask,12,.04f,0.001f)*nastyMarksMoiseMask);outColor=rgb2hsl(mix(hsl2rgb(noisyBackground),hsl2rgb(outColor),clamp(nastyMarks,0.8f,1.f)));return outColor;}vec3 addMarksAndScratches(vec2 uv,vec3 color,int offset){float warpOffset=remap(randomValues[offset+26],0.f,1.f,0.1f,0.15f);float warpSpread=remap(randomValues[offset+1],0.f,1.f,20.f,30.f);vec3 warpColor=highlightColor;vec2 warpOffsetOffsets=vec2(remap(randomValues[offset+24],0.f,1.f,-1e2f,1e2f),remap(randomValues[offset+28],0.f,1.f,-1e2f,1e2f));float warpSlide=-2.7f;float spreadInfluce=remap(randomValues[offset+27],0.f,1.f,40.f,50.f);float warpOffsetNoiseInfluence=snoise2D((uv+warpOffsetOffsets)/warpSpread/spreadInfluce)-warpSlide;vec2 uvOffset=(uv*warpOffsetNoiseInfluence);float warpOffsetNoise=snoise2D((uvOffset+remap(randomValues[offset+25],0.f,1.f,-1e2f,1e2f))/warpSpread)-warpOffset-(warpSlide/2.f);vec3 colorLerp=mix(hsl2rgb(warpColor),hsl2rgb(color),0.1f);return rgb2hsl(mix(colorLerp,hsl2rgb(color),aastep(.025f,warpOffsetNoise)));}vec2 waveUv(vec2 uv){if(isBackground==1){return uv;}float lookupRemap=remap(randomValues[10],0.f,1.f,-1e3f,1e3f);float influence=clamp(snoise2D((uv+lookupRemap)/1e3f),0.f,1.f);if(waveNoiseMapEnabled==0)influence=.9f+(influence/10.f);float strength=(gridWidth/(waveWarpDivisor*PI)-2.f)*influence;float sinX=sin(waveWarpXMult*PI*((uv.x-gridMarginX)/gridWidth))*strength;float sinY=sin(waveWarpYMult*PI*((uv.y-gridMarginY)/gridWidth))*strength;vec2 result=vec2(uv);if(waveWarpX==1)result.x=uv.x+sinX;if(waveWarpY==1)result.y=uv.y+sinY;if(waveOffAxisY==1)result.y=uv.y+sinX;if(waveOffAxisX==1)result.x=uv.x+sinY;return result;}vec2 spiralizeUV(vec2 uv){if(uvSpiralizeEnabled==0){return uv;}int count=0;bool useMap=uvSpiralizeNoiseMapEnabled==1;for(float x=gridWidth/2.f;x<scaledResolution.x;x+=gridWidth*4.f){for(float y=gridWidth/2.f;y<scaledResolution.y;y+=gridWidth*4.f){vec2 pos=vec2(x+gridMarginX+(gridWidth/2.f),y+gridMarginY+(gridWidth/2.f));float lookup=useMap ? uvSpiralMap[count]: randomValues[count];if(lookup>0.625f){float radius=remap(randomValues[count+2],0.f,1.f,gridWidth*2.f,gridWidth*6.f)*uvSpiralizeScale;float strength=remap(randomValues[count+6],0.f,1.f,-6.f,6.f)*uvSpiralizeStrength;uv=rotateUvs(uv,pos,radius,0.f,strength);}count++;}}return uv;}vec4 mainRender(vec2 screenUv){vec2 uv=warpChoice(screenUv);vec2 px=1.f/resolution*scaledResolution;uv=spiralizeUV(uv);uv=pinchUV(uv);uv=lightBend(uv);uv=waveUv(uv);float minDist=1e20f;float prevPolygonDist=1e20f;float minSelfDist=1e20f;float currDist;float alphaBlend=0.f;int secondClosestPolyEdgeIndex=-1;int closestPolyEdgeIndex=-1;int insidePolyIndex=-1;const float distanceThreshold=1.f/9.f;for(int i=0;i<numPolygons;i++){uvec2 polygonIndicies=polyIndices[i];int offset=int(polygonIndicies.x);int vertexCount=int(polygonIndicies.y);int intersections=0;currDist=1e20f;for(int j=0;j<vertexCount;j++){vec2 lineStart=polyVertices[j+offset];vec2 lineEnd=polyVertices[((j+1)% vertexCount)+offset];currDist=min(currDist,pointLineSegSDF(uv,lineStart,lineEnd));if(isIntersecting(uv,lineStart,lineEnd)){intersections++;}}if(intersections % 2==1){insidePolyIndex=i;minSelfDist=currDist;}if(currDist<minDist+distanceThreshold){prevPolygonDist=minDist;secondClosestPolyEdgeIndex=closestPolyEdgeIndex;minDist=currDist;closestPolyEdgeIndex=i;}}int currPolyIndex=insidePolyIndex % paletteAccentArrayLength;vec3 currentColor=currPolyIndex>=0 ? paletteAccentArray[currPolyIndex]: backgroundColor;vec3 closestOtherColor=closestPolyEdgeIndex>=0 ? paletteAccentArray[closestPolyEdgeIndex % paletteAccentArrayLength]: backgroundColor;vec3 currentColorAlt=insidePolyIndex>=0 ? altPaletteAccentArray[insidePolyIndex % altPaletteAccentArrayLength]: backgroundColor;vec3 closestOtherColorAlt=closestPolyEdgeIndex>=0 ? altPaletteAccentArray[closestPolyEdgeIndex % altPaletteAccentArrayLength]: backgroundColor;int currentDetail=detailArray[insidePolyIndex % numPolygons];int closestOtherDetail=detailArray[closestPolyEdgeIndex % numPolygons];bool skipPolyDraw=currentDetail==3;bool skipPolyDrawClosestOtherDetail=closestOtherDetail==3;float offsetWarp=getColourPaletteSwapWarp(screenUv);currentColor=rgb2hsl(mix(hsl2rgb(currentColor),hsl2rgb(currentColorAlt),offsetWarp));closestOtherColor=rgb2hsl(mix(hsl2rgb(closestOtherColor),hsl2rgb(closestOtherColorAlt),offsetWarp));vec3 color=currentColor;if(skipPolyDraw||isBackground==1){currentColor=backgroundColor;}if(skipPolyDrawClosestOtherDetail||isBackground==1){closestOtherColor=backgroundColor;}bool isInsidePoly=insidePolyIndex>-1;float sdfBlendDist=.1f;float lineWeight=lineThickness+((snoise2D(uv/60.f)+.5f)*.2f);float lineFactor=aastep(lineWeight,minDist);if(isInsidePoly){alphaBlend=1.f;float dist=prevPolygonDist>(minDist+sdfBlendDist)? sdfBlendDist : minSelfDist;float colorBlend=clamp(aastep(sdfBlendDist,dist),0.f,1.f);color=rgb2hsl(mix(hsl2rgb(closestOtherColor),hsl2rgb(currentColor),colorBlend));}else{color=closestOtherColor;alphaBlend=aastep(-(drawOutlines==1 ? 1.f-lineFactor :(px.y*(pixelAA))),-minDist);}if(drawOutlines==1){float lineLerp=clamp(lineContrast+snoise2D(uv/.2f)*0.15f,0.f,1.f);vec3 lineMixRGB=mix(hsl2rgb(color),hsl2rgb(lineColor),lineLerp);color=rgb2hsl(mix(hsl2rgb(color),lineMixRGB,1.f-lineFactor));}if(alphaBlend<=0.f){outColor=vec4(0.f);return outColor;}bool isInMargin=false;if(margin>0.f){float marginLinePos=margin+(lineThickness*2.f);if(strokeBorder==1){if(screenUv.x<marginLinePos||screenUv.x>scaledResolution.x-marginLinePos||screenUv.y<marginLinePos||screenUv.y>scaledResolution.y-marginLinePos){vec3 lineMixRGB=mix(backgroundColor,hsl2rgb(lineColor),lineContrast+0.2f);color=lineMixRGB;}}if(screenUv.x<margin||screenUv.x>scaledResolution.x-margin||screenUv.y<margin||screenUv.y>scaledResolution.y-margin){isInMargin=true;color=backgroundColor;}}float shadeWarp=snoise2D(screenUv/1.5e2f)*8.f;float shadeFactor=minSelfDist==1e20f ? 0.f : minSelfDist;float innerShadeFactor=skipPolyDraw ? 0.f : smoothstep(30.f,0.0f,shadeFactor+shadeWarp);float innerShadeFactorEdges=skipPolyDraw ? 0.f : smoothstep(10.f,0.0f,shadeFactor+(shadeWarp/1.2f));float innerShadeComposite=max(innerShadeFactor*0.1f,innerShadeFactorEdges*0.13f)*shadingStrength;float brightnessOffset=shadingStrength*0.05f;float saturationOffset=-0.025f;color=vec3(color.x,color.y+saturationOffset+(innerShadeComposite*.02f),color.z-(innerShadeComposite)+brightnessOffset);for(int i=0;i<3;i++){if(isBackground!=1&&!isInMargin&&!skipPolyDraw){color=addMarksAndScratches(screenUv,color,i+3);}}int noiseOffsetIndex=margin>0.f||skipPolyDraw ? 0 : currPolyIndex;bool gridBleedThroughEnabled=gridBleedThrough==1||skipPolyDraw;if(drawGridDivisions>0){color=drawGridLines(screenUv,color,1.f,1.f,lineColor,gridBleedThroughEnabled);}if(drawGridDivisions>1){color=drawGridLines(screenUv,color,2.f,.89f,lineColor,gridBleedThroughEnabled);}if(drawGridDivisions>2){color=drawGridLines(screenUv,color,4.f,.84f,lineColor,gridBleedThroughEnabled);}color=noisePass(screenUv,color,minSelfDist,noiseOffsetIndex);return mix(vec4(hsl2rgb(color),0.f),vec4(hsl2rgb(color),1.f),alphaBlend);}float randomNonDet(vec2 st){return fract(sin(dot(st.xy,vec2(12.9898f,78.233f)))*43758.5453123f);}vec4 adjustContrast(vec4 color,float factor){vec3 adjustedColor=(color.rgb-0.5f)*factor+0.5f;return vec4(adjustedColor,color.a);}vec4 desaturateRGBA(vec4 color,float factor){float gray=dot(color.rgb,vec3(0.299f,0.587f,0.114f));vec3 desaturatedColor=mix(color.rgb,vec3(gray),factor);return vec4(desaturatedColor,color.a);}vec4 postProcess(vec4 color){if(desaturate==1){vec4 newColor=color;newColor=desaturateRGBA(newColor,.98f);newColor=adjustContrast(newColor,1.2f);vec3 lumClamp=rgb2hsl(newColor.rgb);lumClamp=clamp(lumClamp,0.f,1.f);lumClamp.z=remap(lumClamp.z,0.f,1.f,0.1f,.95f);newColor=vec4(hsl2rgb(lumClamp),color.a);color=newColor;}else{color=adjustContrast(color,1.025f);}return color;}void main(){const vec2 H2=vec2(0.5698402909980532f,0.7548776662466927f);vec2 px=1.f/resolution*scaledResolution;px*=pixelAA;vec2 uv=gl_FragCoord.xy/resolution*scaledResolution;const float samples=6.f;vec4 sumColour;vec2 d0=vec2(randomNonDet(uv),randomNonDet(uv+1.f));for(float i=0.f;i<samples;i++){vec2 d=fract(i*H2+d0)-.5f;vec4 sampleColor=mainRender(d*px+uv);sampleColor.rgb*=aastep(0.5f,sampleColor.a);sumColour+=sampleColor;}vec4 averageColor=sumColour/samples;if(averageColor.a>0.01f){averageColor.rgb/=averageColor.a;}else{discard;}float gammaRemap=desaturate==1 ? 0.95f : 1.05f;vec4 result=vec4(pow(clamp(averageColor,0.f,1.f),vec4(1.f/gammaRemap)));vec4 postProcssed=clamp(postProcess(result),0.f,1.f);outColor=postProcssed;}");let t=ke(It,100,0),o=0;for(let e=Xe/2;e<Vo;e+=4*Xe)for(let r=Xe/2;r<No;r+=4*Xe)Ho[o]=R(X(e/It,r/It,0),t.min,t.max,0,1),o++;let r=1e8,n=he(qo),l=Ge*Ye,a=B(Z,S.int(0,Q.length-2)),s=[];for(;(l-n.length)/l<Ct/100&&r-- >0;){let t=pe(!0),o=0,r=S.weightedChoice([t.length?8:0,t[o]],[t.length>0?0:1,{pt:[S.int(0,Ge),S.int(0,Ye)],dir:S.choice(Z)}]),i=S.weightedChoice([Yt,fe],[Gt,se],[Xt,ce]),f=250,c=ke(_t,a.length,f),u=a[e(R(X(ne(r.pt[0])/_t,ie(r.pt[1])/_t,f),c.min,c.max,0,a.length-1))%a.length];s[u]?s[qe||u]++:s[qe||u]=1;let d=100,h=ke(Ze,St,d),p=ke(et,10*d),g=E(r.pt[0],1),m=E(r.pt[1],1),v=e(R(X(g/Ze,m/Ze,d),h.min,h.max,1,St)),b=e(R(X(g/et,m/et,10*d),p.min,p.max,1,At)),w={gx:g,gy:m,extrusionDirection:qe||u,extrusionLength:S.weightedChoice(...Ke),gw:v,gh:b,stepCount:S.int(2,kt),stepDirection:He||u};i==ce&&(w.gw=1,w.gh=1),i==se&&(w.gw=2,w.gh=1);let x=i(w),y=[];if(S.bool(xt)){const e=te(S.choice(a),oe(S.choice([2,4])));for(let t=S.int(1,yt),o=0;o<=t;o++){let t=Qo(x);t=t.map((t=>(t.poly=t.poly.map((t=>{const[r,n]=t,[i,l]=e;return[r+i*o,n+l*o]})),t.id=$(),t))),y.push(t)}}[x,...y].map((t=>{if(S.bool(wt)&&t.length>1)for(let o=0;o<e(t.length-1);o++)t.splice(S.int(0,t.length-1),1)})),qo=[...qo,x,...y.reverse()],n=he(qo);let C=(l-n.length)/l;yield C}let f=Object.values(s).reduce(((e,t)=>e+t),0)/Object.keys(s).length;if(s?.upLeft>f&&ho(),nt){let[e,t]=it,o=0,r=0,n=be(qo,J.none,ve.gridCoords,[[0,0],[e,t]]);n=k(n).slice(0,e*t);let l=[];for(let a=o;a<=Ge+i(2*e);a+=e)for(let e=r;e<=Ye+i(2*t);e+=t)B(n,a+e).map((t=>{let o=Qo(t);o.map((t=>(t.poly=t.poly.map((t=>{const[o,r]=t;return[o+oe(a),r+oe(e)]})),t.id=$(),t))),l.push(o)}));qo=l}qo=qo.filter((e=>{for(let t of e)if(ae(t.poly))return!0;return!1})),qo=qo.filter((e=>e.length>0)),ro&&be(qo,J.remove);const c=nt?qo:k(qo);qo=[[le()],...c]}();let o="Computing";Po(0,o);let r=()=>{const e=Fo();let n=!1,i=0;for(;!n&&Fo()-e<50;){const e=t.next();i=e.value||0,n=e.done}n?tr():(Po(W(s(100*i),0,10