diff --git a/demo/README.md b/demo/README.md
new file mode 100644
index 000000000..1768a9ced
--- /dev/null
+++ b/demo/README.md
@@ -0,0 +1,4 @@
+The goal of this empty directory is to maintain backward-compatibility with old URLs. For example:
+
+* `pixijs.io/filters/demo` => `pixijs.io/filters/examples`
+* `filters.pixijs.download/main/demo/index.html` => `filters.pixijs.download/main/examples/index.html`
\ No newline at end of file
diff --git a/demo/index.html b/demo/index.html
new file mode 100644
index 000000000..3999053aa
--- /dev/null
+++ b/demo/index.html
@@ -0,0 +1,13 @@
+
+
+
+
+ PixiJS Filters - Redirecting...
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dist/pixi-filters.js b/dist/pixi-filters.js
new file mode 100644
index 000000000..32a3fa237
--- /dev/null
+++ b/dist/pixi-filters.js
@@ -0,0 +1,4290 @@
+/*!
+ * pixi-filters - v6.0.0
+ * Compiled Thu, 07 Mar 2024 01:51:58 UTC
+ *
+ * pixi-filters is licensed under the MIT License.
+ * http://www.opensource.org/licenses/mit-license
+ *
+ * Copyright 2024, undefined, All Rights Reserved
+ */this.PIXI=this.PIXI||{},this.PIXI.filters=function(s,i){"use strict";var c=`in vec2 aPosition;
+out vec2 vTextureCoord;
+
+uniform vec4 uInputSize;
+uniform vec4 uOutputFrame;
+uniform vec4 uOutputTexture;
+
+vec4 filterVertexPosition( void )
+{
+ vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
+
+ position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
+ position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
+
+ return vec4(position, 0.0, 1.0);
+}
+
+vec2 filterTextureCoord( void )
+{
+ return aPosition * (uOutputFrame.zw * uInputSize.zw);
+}
+
+void main(void)
+{
+ gl_Position = filterVertexPosition();
+ vTextureCoord = filterTextureCoord();
+}
+`,m=`struct GlobalFilterUniforms {
+ uInputSize:vec4,
+ uInputPixel:vec4,
+ uInputClamp:vec4,
+ uOutputFrame:vec4,
+ uGlobalFrame:vec4,
+ uOutputTexture:vec4,
+};
+
+@group(0) @binding(0) var gfu: GlobalFilterUniforms;
+
+struct VSOutput {
+ @builtin(position) position: vec4,
+ @location(0) uv : vec2
+ };
+
+fn filterVertexPosition(aPosition:vec2) -> vec4
+{
+ var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
+
+ position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
+ position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
+
+ return vec4(position, 0.0, 1.0);
+}
+
+fn filterTextureCoord( aPosition:vec2 ) -> vec2
+{
+ return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
+}
+
+fn globalTextureCoord( aPosition:vec2 ) -> vec2
+{
+ return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
+}
+
+fn getSize() -> vec2
+{
+ return gfu.uGlobalFrame.zw;
+}
+
+@vertex
+fn mainVertex(
+ @location(0) aPosition : vec2,
+) -> VSOutput {
+ return VSOutput(
+ filterVertexPosition(aPosition),
+ filterTextureCoord(aPosition)
+ );
+}`,wt=`in vec2 vTextureCoord;
+out vec4 finalColor;
+
+uniform sampler2D uTexture;
+uniform float uGamma;
+uniform float uContrast;
+uniform float uSaturation;
+uniform float uBrightness;
+uniform vec4 uColor;
+
+void main()
+{
+ vec4 c = texture(uTexture, vTextureCoord);
+
+ if (c.a > 0.0) {
+ c.rgb /= c.a;
+
+ vec3 rgb = pow(c.rgb, vec3(1. / uGamma));
+ rgb = mix(vec3(.5), mix(vec3(dot(vec3(.2125, .7154, .0721), rgb)), rgb, uSaturation), uContrast);
+ rgb.r *= uColor.r;
+ rgb.g *= uColor.g;
+ rgb.b *= uColor.b;
+ c.rgb = rgb * uBrightness;
+
+ c.rgb *= c.a;
+ }
+
+ finalColor = c * uColor.a;
+}
+`,At=`struct AdjustmentUniforms {
+ uGamma: f32,
+ uContrast: f32,
+ uSaturation: f32,
+ uBrightness: f32,
+ uColor: vec4,
+};
+
+@group(0) @binding(1) var uTexture: texture_2d;
+@group(0) @binding(2) var uSampler: sampler;
+@group(1) @binding(0) var adjustmentUniforms : AdjustmentUniforms;
+
+@fragment
+fn mainFragment(
+ @location(0) uv: vec2,
+ @builtin(position) position: vec4
+) -> @location(0) vec4 {
+ var sample = textureSample(uTexture, uSampler, uv);
+ let color = adjustmentUniforms.uColor;
+
+ if (sample.a > 0.0)
+ {
+ sample = vec4(sample.rgb / sample.a, sample.a);
+ var rgb: vec3 = pow(sample.rgb, vec3(1. / adjustmentUniforms.uGamma));
+ rgb = mix(vec3(.5), mix(vec3(dot(vec3(.2125, .7154, .0721), rgb)), rgb, adjustmentUniforms.uSaturation), adjustmentUniforms.uContrast);
+ rgb.r *= color.r;
+ rgb.g *= color.g;
+ rgb.b *= color.b;
+ sample = vec4(rgb.rgb * adjustmentUniforms.uBrightness, sample.a);
+ sample = vec4(sample.rgb * sample.a, sample.a);
+ }
+
+ return sample * color.a;
+}`,It=Object.defineProperty,Ve=Object.getOwnPropertySymbols,Ut=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable,j=(r,e,n)=>e in r?It(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,Xe=(r,e)=>{for(var n in e||(e={}))Ut.call(e,n)&&j(r,n,e[n]);if(Ve)for(var n of Ve(e))_t.call(e,n)&&j(r,n,e[n]);return r},Ye=(r,e,n)=>(j(r,typeof e!="symbol"?e+"":e,n),n);const Ke=class Qr extends i.Filter{constructor(e){e=Xe(Xe({},Qr.DEFAULT_OPTIONS),e);const n=i.GpuProgram.from({vertex:{source:m,entryPoint:"mainVertex"},fragment:{source:At,entryPoint:"mainFragment"}}),t=i.GlProgram.from({vertex:c,fragment:wt,name:"adjustment-filter"});super({gpuProgram:n,glProgram:t,resources:{adjustmentUniforms:{uGamma:{value:e.gamma,type:"f32"},uContrast:{value:e.contrast,type:"f32"},uSaturation:{value:e.saturation,type:"f32"},uBrightness:{value:e.brightness,type:"f32"},uColor:{value:[e.red,e.green,e.blue,e.alpha],type:"vec4"}}}}),Ye(this,"uniforms"),this.uniforms=this.resources.adjustmentUniforms.uniforms}get gamma(){return this.uniforms.uGamma}set gamma(e){this.uniforms.uGamma=e}get contrast(){return this.uniforms.uContrast}set contrast(e){this.uniforms.uContrast=e}get saturation(){return this.uniforms.uSaturation}set saturation(e){this.uniforms.uSaturation=e}get brightness(){return this.uniforms.uBrightness}set brightness(e){this.uniforms.uBrightness=e}get red(){return this.uniforms.uColor[0]}set red(e){this.uniforms.uColor[0]=e}get green(){return this.uniforms.uColor[1]}set green(e){this.uniforms.uColor[1]=e}get blue(){return this.uniforms.uColor[2]}set blue(e){this.uniforms.uColor[2]=e}get alpha(){return this.uniforms.uColor[3]}set alpha(e){this.uniforms.uColor[3]=e}};Ye(Ke,"DEFAULT_OPTIONS",{gamma:1,contrast:1,saturation:1,brightness:1,red:1,green:1,blue:1,alpha:1});let Rt=Ke;var Dt=`
+in vec2 vTextureCoord;
+out vec4 finalColor;
+
+uniform sampler2D uTexture;
+uniform vec2 uOffset;
+
+void main(void)
+{
+ vec4 color = vec4(0.0);
+
+ // Sample top left pixel
+ color += texture(uTexture, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y));
+
+ // Sample top right pixel
+ color += texture(uTexture, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y));
+
+ // Sample bottom right pixel
+ color += texture(uTexture, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y));
+
+ // Sample bottom left pixel
+ color += texture(uTexture, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y));
+
+ // Average
+ color *= 0.25;
+
+ finalColor = color;
+}`,$t=`struct KawaseBlurUniforms {
+ uOffset:vec2,
+};
+
+@group(0) @binding(1) var uTexture: texture_2d;
+@group(0) @binding(2) var uSampler: sampler;
+@group(1) @binding(0) var kawaseBlurUniforms : KawaseBlurUniforms;
+
+@fragment
+fn mainFragment(
+ @builtin(position) position: vec4,
+ @location(0) uv : vec2
+) -> @location(0) vec4 {
+ let uOffset = kawaseBlurUniforms.uOffset;
+ var color: vec4 = vec4(0.0);
+
+ // Sample top left pixel
+ color += textureSample(uTexture, uSampler, vec2(uv.x - uOffset.x, uv.y + uOffset.y));
+ // Sample top right pixel
+ color += textureSample(uTexture, uSampler, vec2(uv.x + uOffset.x, uv.y + uOffset.y));
+ // Sample bottom right pixel
+ color += textureSample(uTexture, uSampler, vec2(uv.x + uOffset.x, uv.y - uOffset.y));
+ // Sample bottom left pixel
+ color += textureSample(uTexture, uSampler, vec2(uv.x - uOffset.x, uv.y - uOffset.y));
+ // Average
+ color *= 0.25;
+
+ return color;
+}`,Gt=`
+precision highp float;
+in vec2 vTextureCoord;
+out vec4 finalColor;
+
+uniform sampler2D uTexture;
+uniform vec2 uOffset;
+
+uniform vec4 uInputClamp;
+
+void main(void)
+{
+ vec4 color = vec4(0.0);
+
+ // Sample top left pixel
+ color += texture(uTexture, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y), uInputClamp.xy, uInputClamp.zw));
+
+ // Sample top right pixel
+ color += texture(uTexture, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y), uInputClamp.xy, uInputClamp.zw));
+
+ // Sample bottom right pixel
+ color += texture(uTexture, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y), uInputClamp.xy, uInputClamp.zw));
+
+ // Sample bottom left pixel
+ color += texture(uTexture, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y), uInputClamp.xy, uInputClamp.zw));
+
+ // Average
+ color *= 0.25;
+
+ finalColor = color;
+}
+`,Mt=`struct KawaseBlurUniforms {
+ uOffset:vec2,
+};
+
+struct GlobalFilterUniforms {
+ uInputSize:vec4,
+ uInputPixel:vec4,
+ uInputClamp:vec4,
+ uOutputFrame:vec4,
+ uGlobalFrame:vec4,
+ uOutputTexture:vec4,
+};
+
+@group(0) @binding(0) var gfu: GlobalFilterUniforms;
+
+@group(0) @binding(1) var uTexture: texture_2d;
+@group(0) @binding(2) var uSampler: sampler;
+@group(1) @binding(0) var kawaseBlurUniforms : KawaseBlurUniforms;
+
+@fragment
+fn mainFragment(
+ @builtin(position) position: vec4,
+ @location(0) uv : vec2
+) -> @location(0) vec4 {
+ let uOffset = kawaseBlurUniforms.uOffset;
+ var color: vec4 = vec4(0.0);
+
+ // Sample top left pixel
+ color += textureSample(uTexture, uSampler, clamp(vec2(uv.x - uOffset.x, uv.y + uOffset.y), gfu.uInputClamp.xy, gfu.uInputClamp.zw));
+ // Sample top right pixel
+ color += textureSample(uTexture, uSampler, clamp(vec2(uv.x + uOffset.x, uv.y + uOffset.y), gfu.uInputClamp.xy, gfu.uInputClamp.zw));
+ // Sample bottom right pixel
+ color += textureSample(uTexture, uSampler, clamp(vec2(uv.x + uOffset.x, uv.y - uOffset.y), gfu.uInputClamp.xy, gfu.uInputClamp.zw));
+ // Sample bottom left pixel
+ color += textureSample(uTexture, uSampler, clamp(vec2(uv.x - uOffset.x, uv.y - uOffset.y), gfu.uInputClamp.xy, gfu.uInputClamp.zw));
+ // Average
+ color *= 0.25;
+
+ return color;
+}`,Et=Object.defineProperty,We=Object.getOwnPropertySymbols,Lt=Object.prototype.hasOwnProperty,kt=Object.prototype.propertyIsEnumerable,H=(r,e,n)=>e in r?Et(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,qe=(r,e)=>{for(var n in e||(e={}))Lt.call(e,n)&&H(r,n,e[n]);if(We)for(var n of We(e))kt.call(e,n)&&H(r,n,e[n]);return r},T=(r,e,n)=>(H(r,typeof e!="symbol"?e+"":e,n),n);const je=class Jr extends i.Filter{constructor(...e){var n,t,o;let u=(n=e[0])!=null?n:{};(typeof u=="number"||Array.isArray(u))&&(i.deprecation("6.0.0","KawaseBlurFilter constructor params are now options object. See params: { strength, quality, clamp, pixelSize }"),u={strength:u},e[1]!==void 0&&(u.quality=e[1]),e[2]!==void 0&&(u.clamp=e[2])),u=qe(qe({},Jr.DEFAULT_OPTIONS),u);const l=i.GpuProgram.from({vertex:{source:m,entryPoint:"mainVertex"},fragment:{source:u!=null&&u.clamp?Mt:$t,entryPoint:"mainFragment"}}),a=i.GlProgram.from({vertex:c,fragment:u!=null&&u.clamp?Gt:Dt,name:"kawase-blur-filter"});super({gpuProgram:l,glProgram:a,resources:{kawaseBlurUniforms:{uOffset:{value:new Float32Array(2),type:"vec2"}}}}),T(this,"uniforms"),T(this,"_pixelSize",{x:0,y:0}),T(this,"_clamp"),T(this,"_kernels",[]),T(this,"_blur"),T(this,"_quality"),this.uniforms=this.resources.kawaseBlurUniforms.uniforms,this.pixelSize=(t=u.pixelSize)!=null?t:{x:1,y:1},Array.isArray(u.strength)?this.kernels=u.strength:typeof u.strength=="number"&&(this._blur=u.strength,this.quality=(o=u.quality)!=null?o:3),this._clamp=!!u.clamp}apply(e,n,t,o){const u=this.pixelSizeX/n.source.width,l=this.pixelSizeY/n.source.height;let a;if(this._quality===1||this._blur===0)a=this._kernels[0]+.5,this.uniforms.uOffset[0]=a*u,this.uniforms.uOffset[1]=a*l,e.applyFilter(this,n,t,o);else{const p=i.TexturePool.getSameSizeTexture(n);let v=n,h=p,R;const D=this._quality-1;for(let $=0;$0?(this._kernels=e,this._quality=e.length,this._blur=Math.max(...e)):(this._kernels=[0],this._quality=1)}get pixelSize(){return this._pixelSize}set pixelSize(e){if(typeof e=="number"){this.pixelSizeX=this.pixelSizeY=e;return}if(Array.isArray(e)){this.pixelSizeX=e[0],this.pixelSizeY=e[1];return}this._pixelSize=e}get pixelSizeX(){return this.pixelSize.x}set pixelSizeX(e){this.pixelSize.x=e}get pixelSizeY(){return this.pixelSize.y}set pixelSizeY(e){this.pixelSize.y=e}get clamp(){return this._clamp}_updatePadding(){this.padding=Math.ceil(this._kernels.reduce((e,n)=>e+n+.5,0))}_generateKernels(){const e=this._blur,n=this._quality,t=[e];if(e>0){let o=e;const u=e/n;for(let l=1;l;
+@group(0) @binding(2) var uSampler: sampler;
+@group(1) @binding(0) var advancedBloomUniforms : AdvancedBloomUniforms;
+@group(1) @binding(1) var uMapTexture: texture_2d;
+
+@fragment
+fn mainFragment(
+ @builtin(position) position: vec4,
+ @location(0) uv : vec2
+) -> @location(0) vec4 {
+ var color = textureSample(uTexture, uSampler, uv);
+ color = vec4(color.rgb * advancedBloomUniforms.uBrightness, color.a);
+
+ var bloomColor = vec4(textureSample(uMapTexture, uSampler, uv).rgb, 0.0);
+ bloomColor = vec4(bloomColor.rgb * advancedBloomUniforms.uBloomScale, bloomColor.a);
+
+ return color + bloomColor;
+}
+`,Vt=`
+in vec2 vTextureCoord;
+out vec4 finalColor;
+
+uniform sampler2D uTexture;
+uniform float uThreshold;
+
+void main() {
+ vec4 color = texture(uTexture, vTextureCoord);
+
+ // A simple & fast algorithm for getting brightness.
+ // It's inaccuracy , but good enought for this feature.
+ float _max = max(max(color.r, color.g), color.b);
+ float _min = min(min(color.r, color.g), color.b);
+ float brightness = (_max + _min) * 0.5;
+
+ if(brightness > uThreshold) {
+ finalColor = color;
+ } else {
+ finalColor = vec4(0.0, 0.0, 0.0, 0.0);
+ }
+}
+`,Xt=`struct ExtractBrightnessUniforms {
+ uThreshold: f32,
+};
+
+@group(0) @binding(1) var uTexture: texture_2d;
+@group(0) @binding(2) var uSampler: sampler;
+@group(1) @binding(0) var extractBrightnessUniforms : ExtractBrightnessUniforms;
+
+@fragment
+fn mainFragment(
+ @builtin(position) position: vec4,
+ @location(0) uv : vec2
+) -> @location(0) vec4 {
+ let color: vec4 = textureSample(uTexture, uSampler, uv);
+
+ // A simple & fast algorithm for getting brightness.
+ // It's inaccurate, but good enough for this feature.
+ let max: f32 = max(max(color.r, color.g), color.b);
+ let min: f32 = min(min(color.r, color.g), color.b);
+ let brightness: f32 = (max + min) * 0.5;
+
+ return select(vec4(0.), color, brightness > extractBrightnessUniforms.uThreshold);
+}
+`,Yt=Object.defineProperty,He=Object.getOwnPropertySymbols,Kt=Object.prototype.hasOwnProperty,Wt=Object.prototype.propertyIsEnumerable,Q=(r,e,n)=>e in r?Yt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,Ze=(r,e)=>{for(var n in e||(e={}))Kt.call(e,n)&&Q(r,n,e[n]);if(He)for(var n of He(e))Wt.call(e,n)&&Q(r,n,e[n]);return r},Qe=(r,e,n)=>(Q(r,typeof e!="symbol"?e+"":e,n),n);const Je=class et extends i.Filter{constructor(e){e=Ze(Ze({},et.DEFAULT_OPTIONS),e);const n=i.GpuProgram.from({vertex:{source:m,entryPoint:"mainVertex"},fragment:{source:Xt,entryPoint:"mainFragment"}}),t=i.GlProgram.from({vertex:c,fragment:Vt,name:"extract-brightness-filter"});super({gpuProgram:n,glProgram:t,resources:{extractBrightnessUniforms:{uThreshold:{value:e.threshold,type:"f32"}}}}),Qe(this,"uniforms"),this.uniforms=this.resources.extractBrightnessUniforms.uniforms}get threshold(){return this.uniforms.uThreshold}set threshold(e){this.uniforms.uThreshold=e}};Qe(Je,"DEFAULT_OPTIONS",{threshold:.5});let qt=Je;var jt=Object.defineProperty,en=Object.getOwnPropertySymbols,Ht=Object.prototype.hasOwnProperty,Zt=Object.prototype.propertyIsEnumerable,J=(r,e,n)=>e in r?jt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,nn=(r,e)=>{for(var n in e||(e={}))Ht.call(e,n)&&J(r,n,e[n]);if(en)for(var n of en(e))Zt.call(e,n)&&J(r,n,e[n]);return r},w=(r,e,n)=>(J(r,typeof e!="symbol"?e+"":e,n),n);const rn=class nt extends i.Filter{constructor(e){var n;e=nn(nn({},nt.DEFAULT_OPTIONS),e);const t=i.GpuProgram.from({vertex:{source:m,entryPoint:"mainVertex"},fragment:{source:Nt,entryPoint:"mainFragment"}}),o=i.GlProgram.from({vertex:c,fragment:Bt,name:"advanced-bloom-filter"});super({gpuProgram:t,glProgram:o,resources:{advancedBloomUniforms:{uBloomScale:{value:e.bloomScale,type:"f32"},uBrightness:{value:e.brightness,type:"f32"}},uMapTexture:i.Texture.WHITE}}),w(this,"uniforms"),w(this,"bloomScale",1),w(this,"brightness",1),w(this,"_extractFilter"),w(this,"_blurFilter"),this.uniforms=this.resources.advancedBloomUniforms.uniforms,this._extractFilter=new qt({threshold:e.threshold}),this._blurFilter=new Z({strength:(n=e.kernels)!=null?n:e.blur,quality:e.kernels?void 0:e.quality}),Object.assign(this,e)}apply(e,n,t,o){const u=i.TexturePool.getSameSizeTexture(n);this._extractFilter.apply(e,n,u,!0);const l=i.TexturePool.getSameSizeTexture(n);this._blurFilter.apply(e,u,l,!0),this.uniforms.uBloomScale=this.bloomScale,this.uniforms.uBrightness=this.brightness,this.resources.uMapTexture=l.source,e.applyFilter(this,n,t,o),i.TexturePool.returnTexture(l),i.TexturePool.returnTexture(u)}get threshold(){return this._extractFilter.threshold}set threshold(e){this._extractFilter.threshold=e}get kernels(){return this._blurFilter.kernels}set kernels(e){this._blurFilter.kernels=e}get blur(){return this._blurFilter.strength}set blur(e){this._blurFilter.strength=e}get quality(){return this._blurFilter.quality}set quality(e){this._blurFilter.quality=e}get pixelSize(){return this._blurFilter.pixelSize}set pixelSize(e){typeof e=="number"&&(e={x:e,y:e}),Array.isArray(e)&&(e={x:e[0],y:e[1]}),this._blurFilter.pixelSize=e}get pixelSizeX(){return this._blurFilter.pixelSizeX}set pixelSizeX(e){this._blurFilter.pixelSizeX=e}get pixelSizeY(){return this._blurFilter.pixelSizeY}set pixelSizeY(e){this._blurFilter.pixelSizeY=e}};w(rn,"DEFAULT_OPTIONS",{threshold:.5,bloomScale:1,brightness:1,blur:8,quality:4,pixelSize:{x:1,y:1}});let Qt=rn;var Jt=`precision highp float;
+in vec2 vTextureCoord;
+out vec4 finalColor;
+
+uniform sampler2D uTexture;
+uniform float uSize;
+uniform vec3 uColor;
+uniform float uReplaceColor;
+
+uniform vec4 uInputSize;
+
+vec2 mapCoord( vec2 coord )
+{
+ coord *= uInputSize.xy;
+ coord += uInputSize.zw;
+
+ return coord;
+}
+
+vec2 unmapCoord( vec2 coord )
+{
+ coord -= uInputSize.zw;
+ coord /= uInputSize.xy;
+
+ return coord;
+}
+
+vec2 pixelate(vec2 coord, vec2 size)
+{
+ return floor(coord / size) * size;
+}
+
+vec2 getMod(vec2 coord, vec2 size)
+{
+ return mod(coord, size) / size;
+}
+
+float character(float n, vec2 p)
+{
+ p = floor(p*vec2(4.0, 4.0) + 2.5);
+
+ if (clamp(p.x, 0.0, 4.0) == p.x)
+ {
+ if (clamp(p.y, 0.0, 4.0) == p.y)
+ {
+ if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0;
+ }
+ }
+ return 0.0;
+}
+
+void main()
+{
+ vec2 coord = mapCoord(vTextureCoord);
+
+ // get the grid position
+ vec2 pixCoord = pixelate(coord, vec2(uSize));
+ pixCoord = unmapCoord(pixCoord);
+
+ // sample the color at grid position
+ vec4 color = texture(uTexture, pixCoord);
+
+ // brightness of the color as it's perceived by the human eye
+ float gray = 0.3 * color.r + 0.59 * color.g + 0.11 * color.b;
+
+ // determine the character to use
+ float n = 65536.0; // .
+ if (gray > 0.2) n = 65600.0; // :
+ if (gray > 0.3) n = 332772.0; // *
+ if (gray > 0.4) n = 15255086.0; // o
+ if (gray > 0.5) n = 23385164.0; // &
+ if (gray > 0.6) n = 15252014.0; // 8
+ if (gray > 0.7) n = 13199452.0; // @
+ if (gray > 0.8) n = 11512810.0; // #
+
+ // get the mod..
+ vec2 modd = getMod(coord, vec2(uSize));
+
+ finalColor = (uReplaceColor > 0.5 ? vec4(uColor, 1.) : color) * character( n, vec2(-1.0) + modd * 2.0);
+}
+`,eo=`struct AsciiUniforms {
+ uSize: f32,
+ uColor: vec3,
+ uReplaceColor: f32,
+};
+
+struct GlobalFilterUniforms {
+ uInputSize:vec4,
+ uInputPixel:vec4,
+ uInputClamp:vec4,
+ uOutputFrame:vec4,
+ uGlobalFrame:vec4,
+ uOutputTexture:vec4,
+};
+
+@group(0) @binding(0) var gfu: GlobalFilterUniforms;
+
+@group(0) @binding(1) var uTexture: texture_2d;
+@group(0) @binding(2) var uSampler: sampler;
+@group(1) @binding(0) var asciiUniforms : AsciiUniforms;
+
+@fragment
+fn mainFragment(
+ @location(0) uv: vec2,
+ @builtin(position) position: vec4
+) -> @location(0) vec4 {
+ let pixelSize: f32 = asciiUniforms.uSize;
+ let coord: vec2 = mapCoord(uv);
+
+ // get the rounded color..
+ var pixCoord: vec2 = pixelate(coord, vec2(pixelSize));
+ pixCoord = unmapCoord(pixCoord);
+
+ var color = textureSample(uTexture, uSampler, pixCoord);
+
+ // determine the character to use
+ let gray: f32 = 0.3 * color.r + 0.59 * color.g + 0.11 * color.b;
+
+ var n: f32 = 65536.0; // .
+ if (gray > 0.2) {
+ n = 65600.0; // :
+ }
+ if (gray > 0.3) {
+ n = 332772.0; // *
+ }
+ if (gray > 0.4) {
+ n = 15255086.0; // o
+ }
+ if (gray > 0.5) {
+ n = 23385164.0; // &
+ }
+ if (gray > 0.6) {
+ n = 15252014.0; // 8
+ }
+ if (gray > 0.7) {
+ n = 13199452.0; // @
+ }
+ if (gray > 0.8) {
+ n = 11512810.0; // #
+ }
+
+ // get the mod..
+ let modd: vec2 = getMod(coord, vec2(pixelSize));
+ return select(color, vec4(asciiUniforms.uColor, 1.), asciiUniforms.uReplaceColor > 0.5) * character(n, vec2(-1.0) + modd * 2.0);
+}
+
+fn pixelate(coord: vec2, size: vec2) -> vec2
+{
+ return floor( coord / size ) * size;
+}
+
+fn getMod(coord: vec2, size: vec2) -> vec2
+{
+ return moduloVec2( coord , size) / size;
+}
+
+fn character(n: f32, p: vec2) -> f32
+{
+ var q: vec2 = floor(p*vec2(4.0, 4.0) + 2.5);
+
+ if (clamp(q.x, 0.0, 4.0) == q.x)
+ {
+ if (clamp(q.y, 0.0, 4.0) == q.y)
+ {
+ if (i32(modulo(n/exp2(q.x + 5.0*q.y), 2.0)) == 1)
+ {
+ return 1.0;
+ }
+ }
+ }
+
+ return 0.0;
+}
+
+fn modulo(x: f32, y: f32) -> f32
+{
+ return x - y * floor(x/y);
+}
+
+fn moduloVec2(x: vec2, y: vec2) -> vec2
+{
+ return x - y * floor(x/y);
+}
+
+fn mapCoord(coord: vec2 ) -> vec2
+{
+ var mappedCoord: vec2 = coord;
+ mappedCoord *= gfu.uInputSize.xy;
+ mappedCoord += gfu.uOutputFrame.xy;
+ return mappedCoord;
+}
+
+fn unmapCoord(coord: vec2 ) -> vec2
+{
+ var mappedCoord: vec2 = coord;
+ mappedCoord -= gfu.uOutputFrame.xy;
+ mappedCoord /= gfu.uInputSize.xy;
+ return mappedCoord;
+}`,no=Object.defineProperty,tn=Object.getOwnPropertySymbols,ro=Object.prototype.hasOwnProperty,to=Object.prototype.propertyIsEnumerable,ee=(r,e,n)=>e in r?no(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,on=(r,e)=>{for(var n in e||(e={}))ro.call(e,n)&&ee(r,n,e[n]);if(tn)for(var n of tn(e))to.call(e,n)&&ee(r,n,e[n]);return r},ne=(r,e,n)=>(ee(r,typeof e!="symbol"?e+"":e,n),n);const un=class rt extends i.Filter{constructor(...e){var n,t;let o=(n=e[0])!=null?n:{};typeof o=="number"&&(i.deprecation("6.0.0","AsciiFilter constructor params are now options object. See params: { size, color, replaceColor }"),o={size:o});const u=(o==null?void 0:o.color)&&o.replaceColor!==!1;o=on(on({},rt.DEFAULT_OPTIONS),o);const l=i.GpuProgram.from({vertex:{source:m,entryPoint:"mainVertex"},fragment:{source:eo,entryPoint:"mainFragment"}}),a=i.GlProgram.from({vertex:c,fragment:Jt,name:"ascii-filter"});super({gpuProgram:l,glProgram:a,resources:{asciiUniforms:{uSize:{value:o.size,type:"f32"},uColor:{value:new Float32Array(3),type:"vec3"},uReplaceColor:{value:Number(u),type:"f32"}}}}),ne(this,"uniforms"),ne(this,"_color"),this.uniforms=this.resources.asciiUniforms.uniforms,this._color=new i.Color,this.color=(t=o.color)!=null?t:16777215}get size(){return this.uniforms.uSize}set size(e){this.uniforms.uSize=e}get color(){return this._color.value}set color(e){this._color.setValue(e);const[n,t,o]=this._color.toArray();this.uniforms.uColor[0]=n,this.uniforms.uColor[1]=t,this.uniforms.uColor[2]=o}get replaceColor(){return this.uniforms.uReplaceColor>.5}set replaceColor(e){this.uniforms.uReplaceColor=e?1:0}};ne(un,"DEFAULT_OPTIONS",{size:8,color:16777215,replaceColor:!1});let oo=un;var io=`precision highp float;
+in vec2 vTextureCoord;
+out vec4 finalColor;
+
+uniform sampler2D uTexture;
+uniform sampler2D uBackground;
+
+void main(void){
+ vec4 front = texture(uTexture, vTextureCoord);
+ vec4 back = texture(uBackground, vTextureCoord);
+
+ if (front.a == 0.0) {
+ discard;
+ }
+
+ vec3 color = mix(back.rgb, front.rgb / front.a, front.a);
+
+ finalColor = vec4(color, 1.0);
+}`,uo=`@group(0) @binding(1) var uTexture: texture_2d;
+@group(0) @binding(2) var uSampler: sampler;
+@group(1) @binding(0) var uBackground: texture_2d;
+
+@fragment
+fn mainFragment(
+ @builtin(position) position: vec4,
+ @location(0) uv : vec2
+) -> @location(0) vec4 {
+ var front: vec4 = textureSample(uTexture, uSampler, uv);
+ var back: vec4 = textureSample(uBackground, uSampler, uv);
+
+ if (front.a == 0.0) {
+ discard;
+ }
+
+ var color: vec3 = mix(back.rgb, front.rgb / front.a, front.a);
+
+ return vec4(color, 1.0);
+}`,lo=Object.defineProperty,ao=(r,e,n)=>e in r?lo(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,so=(r,e,n)=>(ao(r,typeof e!="symbol"?e+"":e,n),n);class fo extends i.BlurFilter{constructor(e){super(e),so(this,"_blendPass"),this.blendRequired=!0,this.padding=0,this._blendPass=new i.Filter({gpuProgram:i.GpuProgram.from({vertex:{source:m,entryPoint:"mainVertex"},fragment:{source:uo,entryPoint:"mainFragment"}}),glProgram:i.GlProgram.from({vertex:c,fragment:io,name:"drop-shadow-filter"}),resources:{uBackground:i.Texture.EMPTY}})}apply(e,n,t,o){const u=e._activeFilterData.backTexture,l=i.TexturePool.getSameSizeTexture(n);super.apply(e,u,l,!0),this._blendPass.resources.uBackground=l.source,this._blendPass.apply(e,n,t,o),i.TexturePool.returnTexture(l)}updatePadding(){this.padding=0}}var co=`precision highp float;
+in vec2 vTextureCoord;
+out vec4 finalColor;
+
+uniform sampler2D uTexture;
+uniform vec2 uTransform;
+uniform vec3 uLightColor;
+uniform float uLightAlpha;
+uniform vec3 uShadowColor;
+uniform float uShadowAlpha;
+
+uniform vec4 uInputSize;
+
+void main(void) {
+ vec2 transform = vec2(1.0 / uInputSize) * vec2(uTransform.x, uTransform.y);
+ vec4 color = texture(uTexture, vTextureCoord);
+ float light = texture(uTexture, vTextureCoord - transform).a;
+ float shadow = texture(uTexture, vTextureCoord + transform).a;
+
+ color.rgb = mix(color.rgb, uLightColor, clamp((color.a - light) * uLightAlpha, 0.0, 1.0));
+ color.rgb = mix(color.rgb, uShadowColor, clamp((color.a - shadow) * uShadowAlpha, 0.0, 1.0));
+ finalColor = vec4(color.rgb * color.a, color.a);
+}
+`,mo=`struct BevelUniforms {
+ uLightColor: vec3,
+ uLightAlpha: f32,
+ uShadowColor: vec3,
+ uShadowAlpha: f32,
+ uTransform: vec2,
+};
+
+struct GlobalFilterUniforms {
+ uInputSize:vec4,
+ uInputPixel:vec4,
+ uInputClamp:vec4,
+ uOutputFrame:vec4,
+ uGlobalFrame:vec4,
+ uOutputTexture:vec4,
+};
+
+@group(0) @binding(0) var gfu: GlobalFilterUniforms;
+
+@group(0) @binding(1) var uTexture: texture_2d;
+@group(0) @binding(2) var uSampler: sampler;
+@group(1) @binding(0) var bevelUniforms : BevelUniforms;
+
+@fragment
+fn mainFragment(
+ @builtin(position) position: vec4,
+ @location(0) uv : vec2
+) -> @location(0) vec4 {
+ let transform = vec2(1.0 / gfu.uInputSize.xy) * vec2(bevelUniforms.uTransform.x, bevelUniforms.uTransform.y);
+ var color: vec4 = textureSample(uTexture, uSampler, uv);
+ let lightSample: f32 = textureSample(uTexture, uSampler, uv - transform).a;
+ let shadowSample: f32 = textureSample(uTexture, uSampler, uv + transform).a;
+
+ let light = vec4(bevelUniforms.uLightColor, bevelUniforms.uLightAlpha);
+ let shadow = vec4(bevelUniforms.uShadowColor, bevelUniforms.uShadowAlpha);
+
+ color = vec4(mix(color.rgb, light.rgb, clamp((color.a - lightSample) * light.a, 0.0, 1.0)), color.a);
+ color = vec4(mix(color.rgb, shadow.rgb, clamp((color.a - shadowSample) * shadow.a, 0.0, 1.0)), color.a);
+
+ return vec4(color.rgb * color.a, color.a);
+}`,po=Object.defineProperty,ln=Object.getOwnPropertySymbols,vo=Object.prototype.hasOwnProperty,go=Object.prototype.propertyIsEnumerable,re=(r,e,n)=>e in r?po(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,an=(r,e)=>{for(var n in e||(e={}))vo.call(e,n)&&re(r,n,e[n]);if(ln)for(var n of ln(e))go.call(e,n)&&re(r,n,e[n]);return r},A=(r,e,n)=>(re(r,typeof e!="symbol"?e+"":e,n),n);const sn=class tt extends i.Filter{constructor(e){var n,t,o;e=an(an({},tt.DEFAULT_OPTIONS),e);const u=((n=e.rotation)!=null?n:45)*i.DEG_TO_RAD,l=i.GpuProgram.from({vertex:{source:m,entryPoint:"mainVertex"},fragment:{source:mo,entryPoint:"mainFragment"}}),a=i.GlProgram.from({vertex:c,fragment:co,name:"bevel-filter"});super({gpuProgram:l,glProgram:a,resources:{bevelUniforms:{uLightColor:{value:new Float32Array(3),type:"vec3"},uLightAlpha:{value:e.lightAlpha,type:"f32"},uShadowColor:{value:new Float32Array(3),type:"vec3"},uShadowAlpha:{value:e.shadowAlpha,type:"f32"},uTransform:{value:new Float32Array(2),type:"vec2"}}},padding:1}),A(this,"uniforms"),A(this,"_thickness"),A(this,"_rotation"),A(this,"_lightColor"),A(this,"_shadowColor"),this.uniforms=this.resources.bevelUniforms.uniforms,this._lightColor=new i.Color,this._shadowColor=new i.Color,this.lightColor=(t=e.lightColor)!=null?t:16777215,this.shadowColor=(o=e.shadowColor)!=null?o:0,Object.assign(this,e,{rotation:u})}get rotation(){return this._rotation/i.DEG_TO_RAD}set rotation(e){this._rotation=e*i.DEG_TO_RAD,this._updateTransform()}get thickness(){return this._thickness}set thickness(e){this._thickness=e,this._updateTransform()}get lightColor(){return this._lightColor.value}set lightColor(e){this._lightColor.setValue(e);const[n,t,o]=this._lightColor.toArray();this.uniforms.uLightColor[0]=n,this.uniforms.uLightColor[1]=t,this.uniforms.uLightColor[2]=o}get lightAlpha(){return this.uniforms.uLightAlpha}set lightAlpha(e){this.uniforms.uLightAlpha=e}get shadowColor(){return this._shadowColor.value}set shadowColor(e){this._shadowColor.setValue(e);const[n,t,o]=this._shadowColor.toArray();this.uniforms.uShadowColor[0]=n,this.uniforms.uShadowColor[1]=t,this.uniforms.uShadowColor[2]=o}get shadowAlpha(){return this.uniforms.uShadowAlpha}set shadowAlpha(e){this.uniforms.uShadowAlpha=e}_updateTransform(){this.uniforms.uTransform[0]=this.thickness*Math.cos(this._rotation),this.uniforms.uTransform[1]=this.thickness*Math.sin(this._rotation)}};A(sn,"DEFAULT_OPTIONS",{rotation:45,thickness:2,lightColor:16777215,lightAlpha:.7,shadowColor:0,shadowAlpha:.7});let ho=sn;var xo=Object.defineProperty,yo=Object.defineProperties,So=Object.getOwnPropertyDescriptors,fn=Object.getOwnPropertySymbols,bo=Object.prototype.hasOwnProperty,Co=Object.prototype.propertyIsEnumerable,te=(r,e,n)=>e in r?xo(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,G=(r,e)=>{for(var n in e||(e={}))bo.call(e,n)&&te(r,n,e[n]);if(fn)for(var n of fn(e))Co.call(e,n)&&te(r,n,e[n]);return r},cn=(r,e)=>yo(r,So(e)),M=(r,e,n)=>(te(r,typeof e!="symbol"?e+"":e,n),n);const mn=class ot extends i.AlphaFilter{constructor(...e){var n;let t=(n=e[0])!=null?n:{};if(typeof t=="number"||Array.isArray(t)||"x"in t&&"y"in t){i.deprecation("6.0.0","BloomFilter constructor params are now options object. See params: { strength, quality, resolution, kernelSize }");let o=t;Array.isArray(o)&&(o={x:o[0],y:o[1]}),t={strength:o},e[1]!==void 0&&(t.quality=e[1]),e[2]!==void 0&&(t.resolution=e[2]),e[3]!==void 0&&(t.kernelSize=e[3])}t=G(G({},ot.DEFAULT_OPTIONS),t),super(),M(this,"_blurXFilter"),M(this,"_blurYFilter"),M(this,"_strength"),this._strength={x:2,y:2},t.strength&&(typeof t.strength=="number"?(this._strength.x=t.strength,this._strength.y=t.strength):(this._strength.x=t.strength.x,this._strength.y=t.strength.y)),this._blurXFilter=new i.BlurFilterPass(cn(G({},t),{horizontal:!0,strength:this.strengthX})),this._blurYFilter=new i.BlurFilterPass(cn(G({},t),{horizontal:!1,strength:this.strengthY})),this._blurYFilter.blendMode="screen",Object.assign(this,t)}apply(e,n,t,o){const u=i.TexturePool.getSameSizeTexture(n);e.applyFilter(this,n,t,o),this._blurXFilter.apply(e,n,u,!0),this._blurYFilter.apply(e,u,t,!1),i.TexturePool.returnTexture(u)}get strength(){return this._strength}set strength(e){this._strength=typeof e=="number"?{x:e,y:e}:e,this._updateStrength()}get strengthX(){return this.strength.x}set strengthX(e){this.strength.x=e,this._updateStrength()}get strengthY(){return this.strength.y}set strengthY(e){this.strength.y=e,this._updateStrength()}_updateStrength(){this._blurXFilter.blur=this.strengthX,this._blurYFilter.blur=this.strengthY}get blur(){return i.deprecation("6.0.0","BloomFilter.blur is deprecated, please use BloomFilter.strength instead"),this.strengthX}set blur(e){i.deprecation("6.0.0","BloomFilter.blur is deprecated, please use BloomFilter.strength instead"),this.strength=e}get blurX(){return i.deprecation("6.0.0","BloomFilter.blurX is deprecated, please use BloomFilter.strengthX instead"),this.strengthX}set blurX(e){i.deprecation("6.0.0","BloomFilter.blurX is deprecated, please use BloomFilter.strengthX instead"),this.strengthX=e}get blurY(){return i.deprecation("6.0.0","BloomFilter.blurY is deprecated, please use BloomFilter.strengthY instead"),this.strengthY}set blurY(e){i.deprecation("6.0.0","BloomFilter.blurY is deprecated, please use BloomFilter.strengthY instead"),this.strengthY=e}};M(mn,"DEFAULT_OPTIONS",{strength:{x:2,y:2},quality:4,resolution:1,kernelSize:5});let To=mn;var Po=`precision highp float;
+in vec2 vTextureCoord;
+out vec4 finalColor;
+
+uniform sampler2D uTexture;
+uniform vec2 uDimensions;
+uniform vec2 uCenter;
+uniform float uRadius;
+uniform float uStrength;
+
+uniform vec4 uInputSize;
+uniform vec4 uInputClamp;
+
+void main()
+{
+ vec2 coord = vTextureCoord * uInputSize.xy;
+ coord -= uCenter * uDimensions.xy;
+ float distance = length(coord);
+
+ if (distance < uRadius) {
+ float percent = distance / uRadius;
+ if (uStrength > 0.0) {
+ coord *= mix(1.0, smoothstep(0.0, uRadius / distance, percent), uStrength * 0.75);
+ } else {
+ coord *= mix(1.0, pow(percent, 1.0 + uStrength * 0.75) * uRadius / distance, 1.0 - percent);
+ }
+ }
+
+ coord += uCenter * uDimensions.xy;
+ coord /= uInputSize.xy;
+ vec2 clampedCoord = clamp(coord, uInputClamp.xy, uInputClamp.zw);
+ vec4 color = texture(uTexture, clampedCoord);
+
+ if (coord != clampedCoord) {
+ color *= max(0.0, 1.0 - length(coord - clampedCoord));
+ }
+
+ finalColor = color;
+}
+`,Oo=`struct BulgePinchUniforms {
+ uDimensions: vec2,
+ uCenter: vec2,
+ uRadius: f32,
+ uStrength: f32,
+};
+
+struct GlobalFilterUniforms {
+ uInputSize:vec4,
+ uInputPixel:vec4,
+ uInputClamp:vec4,
+ uOutputFrame:vec4,
+ uGlobalFrame:vec4,
+ uOutputTexture:vec4,
+};
+
+@group(0) @binding(0) var gfu: GlobalFilterUniforms;
+
+@group(0) @binding(1) var uTexture: texture_2d;
+@group(0) @binding(2) var uSampler: sampler;
+@group(1) @binding(0) var bulgePinchUniforms : BulgePinchUniforms;
+
+@fragment
+fn mainFragment(
+ @builtin(position) position: vec4,
+ @location(0) uv : vec2
+) -> @location(0) vec4 {
+ let dimensions: vec2 = bulgePinchUniforms.uDimensions;
+ let center: vec2 = bulgePinchUniforms.uCenter;
+ let radius: f32 = bulgePinchUniforms.uRadius;
+ let strength: f32 = bulgePinchUniforms.uStrength;
+ var coord: vec2 = (uv * gfu.uInputSize.xy) - center * dimensions.xy;
+
+ let distance: f32 = length(coord);
+
+ if (distance < radius) {
+ let percent: f32 = distance / radius;
+ if (strength > 0.0) {
+ coord *= mix(1.0, smoothstep(0.0, radius / distance, percent), strength * 0.75);
+ } else {
+ coord *= mix(1.0, pow(percent, 1.0 + strength * 0.75) * radius / distance, 1.0 - percent);
+ }
+ }
+ coord += (center * dimensions.xy);
+ coord /= gfu.uInputSize.xy;
+
+ let clampedCoord: vec2 = clamp(coord, gfu.uInputClamp.xy, gfu.uInputClamp.zw);
+ var color: vec4 = textureSample(uTexture, uSampler, clampedCoord);
+ if (coord.x != clampedCoord.x && coord.y != clampedCoord.y) {
+ color *= max(0.0, 1.0 - length(coord - clampedCoord));
+ }
+
+ return color;
+}
+
+fn compareVec2(x: vec2, y: vec2) -> bool
+{
+ if (x.x == y.x && x.y == y.y)
+ {
+ return true;
+ }
+
+ return false;
+}`,zo=Object.defineProperty,pn=Object.getOwnPropertySymbols,Fo=Object.prototype.hasOwnProperty,wo=Object.prototype.propertyIsEnumerable,oe=(r,e,n)=>e in r?zo(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,vn=(r,e)=>{for(var n in e||(e={}))Fo.call(e,n)&&oe(r,n,e[n]);if(pn)for(var n of pn(e))wo.call(e,n)&&oe(r,n,e[n]);return r},gn=(r,e,n)=>(oe(r,typeof e!="symbol"?e+"":e,n),n);const dn=class it extends i.Filter{constructor(e){e=vn(vn({},it.DEFAULT_OPTIONS),e);const n=i.GpuProgram.from({vertex:{source:m,entryPoint:"mainVertex"},fragment:{source:Oo,entryPoint:"mainFragment"}}),t=i.GlProgram.from({vertex:c,fragment:Po,name:"bulge-pinch-filter"});super({gpuProgram:n,glProgram:t,resources:{bulgePinchUniforms:{uDimensions:{value:[0,0],type:"vec2"},uCenter:{value:e.center,type:"vec2"},uRadius:{value:e.radius,type:"f32"},uStrength:{value:e.strength,type:"f32"}}}}),gn(this,"uniforms"),this.uniforms=this.resources.bulgePinchUniforms.uniforms,Object.assign(this,e)}apply(e,n,t,o){this.uniforms.uDimensions[0]=n.frame.width,this.uniforms.uDimensions[1]=n.frame.height,e.applyFilter(this,n,t,o)}get center(){return this.uniforms.uCenter}set center(e){typeof e=="number"&&(e={x:e,y:e}),Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uCenter=e}get centerX(){return this.uniforms.uCenter.x}set centerX(e){this.uniforms.uCenter.x=e}get centerY(){return this.uniforms.uCenter.y}set centerY(e){this.uniforms.uCenter.y=e}get radius(){return this.uniforms.uRadius}set radius(e){this.uniforms.uRadius=e}get strength(){return this.uniforms.uStrength}set strength(e){this.uniforms.uStrength=e}};gn(dn,"DEFAULT_OPTIONS",{center:{x:.5,y:.5},radius:100,strength:1});let Ao=dn;var Io=`precision highp float;
+in vec2 vTextureCoord;
+in vec2 vFilterCoord;
+out vec4 finalColor;
+
+const int TYPE_LINEAR = 0;
+const int TYPE_RADIAL = 1;
+const int TYPE_CONIC = 2;
+const int MAX_STOPS = 32;
+
+uniform sampler2D uTexture;
+uniform vec4 uOptions;
+uniform vec2 uCounts;
+uniform vec3 uColors[MAX_STOPS];
+uniform vec4 uStops[MAX_STOPS];
+
+const float PI = 3.1415926538;
+const float PI_2 = PI*2.;
+
+struct ColorStop {
+ float offset;
+ vec3 color;
+ float alpha;
+};
+
+mat2 rotate2d(float angle){
+ return mat2(cos(angle), -sin(angle),
+ sin(angle), cos(angle));
+}
+
+float projectLinearPosition(vec2 pos, float angle){
+ vec2 center = vec2(0.5);
+ vec2 result = pos - center;
+ result = rotate2d(angle) * result;
+ result = result + center;
+ return clamp(result.x, 0., 1.);
+}
+
+float projectRadialPosition(vec2 pos) {
+ float r = distance(pos, vec2(0.5));
+ return clamp(2.*r, 0., 1.);
+}
+
+float projectAnglePosition(vec2 pos, float angle) {
+ vec2 center = pos - vec2(0.5);
+ float polarAngle=atan(-center.y, center.x);
+ return mod(polarAngle + angle, PI_2) / PI_2;
+}
+
+float projectPosition(vec2 pos, int type, float angle) {
+ if (type == TYPE_LINEAR) {
+ return projectLinearPosition(pos, angle);
+ } else if (type == TYPE_RADIAL) {
+ return projectRadialPosition(pos);
+ } else if (type == TYPE_CONIC) {
+ return projectAnglePosition(pos, angle);
+ }
+
+ return pos.y;
+}
+
+void main(void) {
+ int uType = int(uOptions[0]);
+ float uAngle = uOptions[1];
+ float uAlpha = uOptions[2];
+ float uReplace = uOptions[3];
+
+ int uNumStops = int(uCounts[0]);
+ float uMaxColors = uCounts[1];
+
+ // current/original color
+ vec4 currentColor = texture(uTexture, vTextureCoord);
+
+ // skip calculations if gradient alpha is 0
+ if (0.0 == uAlpha) {
+ finalColor = currentColor;
+ return;
+ }
+
+ // project position
+ float y = projectPosition(vFilterCoord, int(uType), radians(uAngle));
+
+ // check gradient bounds
+ float offsetMin = uStops[0][0];
+ float offsetMax = 0.0;
+
+ int numStops = int(uNumStops);
+
+ for (int i = 0; i < MAX_STOPS; i++) {
+ if (i == numStops-1){ // last index
+ offsetMax = uStops[i][0];
+ }
+ }
+
+ if (y < offsetMin || y > offsetMax) {
+ finalColor = currentColor;
+ return;
+ }
+
+ // limit colors
+ if (uMaxColors > 0.) {
+ float stepSize = 1./uMaxColors;
+ float stepNumber = float(floor(y/stepSize));
+ y = stepSize * (stepNumber + 0.5);// offset by 0.5 to use color from middle of segment
+ }
+
+ // find color stops
+ ColorStop from;
+ ColorStop to;
+
+ for (int i = 0; i < MAX_STOPS; i++) {
+ if (y >= uStops[i][0]) {
+ from = ColorStop(uStops[i][0], uColors[i], uStops[i][1]);
+ to = ColorStop(uStops[i+1][0], uColors[i+1], uStops[i+1][1]);
+ }
+
+ if (i == numStops-1){ // last index
+ break;
+ }
+ }
+
+ // mix colors from stops
+ vec4 colorFrom = vec4(from.color * from.alpha, from.alpha);
+ vec4 colorTo = vec4(to.color * to.alpha, to.alpha);
+
+ float segmentHeight = to.offset - from.offset;
+ float relativePos = y - from.offset;// position from 0 to [segmentHeight]
+ float relativePercent = relativePos / segmentHeight;// position in percent between [from.offset] and [to.offset].
+
+ float gradientAlpha = uAlpha * currentColor.a;
+ vec4 gradientColor = mix(colorFrom, colorTo, relativePercent) * gradientAlpha;
+
+ if (uReplace < 0.5) {
+ // mix resulting color with current color
+ finalColor = gradientColor + currentColor*(1.-gradientColor.a);
+ } else {
+ // replace with gradient color
+ finalColor = gradientColor;
+ }
+}
+`,Uo=`in vec2 aPosition;
+out vec2 vTextureCoord;
+out vec2 vFilterCoord;
+
+uniform vec4 uInputSize;
+uniform vec4 uOutputFrame;
+uniform vec4 uOutputTexture;
+
+vec4 filterVertexPosition( void )
+{
+ vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
+
+ position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
+ position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
+
+ return vec4(position, 0.0, 1.0);
+}
+
+vec2 filterTextureCoord( void )
+{
+ return aPosition * (uOutputFrame.zw * uInputSize.zw);
+}
+
+void main(void)
+{
+ gl_Position = filterVertexPosition();
+ vTextureCoord = filterTextureCoord();
+ vFilterCoord = vTextureCoord * uInputSize.xy / uOutputFrame.zw;
+}
+`,hn=`struct BaseUniforms {
+ uOptions: vec4,
+ uCounts: vec2,
+};
+
+struct StopsUniforms {
+ uColors: array, MAX_STOPS>,
+ uStops: array, MAX_STOPS>,
+};
+
+struct GlobalFilterUniforms {
+ uInputSize:vec4,
+ uInputPixel:vec4,
+ uInputClamp:vec4,
+ uOutputFrame:vec4,
+ uGlobalFrame:vec4,
+ uOutputTexture:vec4,
+};
+
+@group(0) @binding(0) var gfu: GlobalFilterUniforms;
+
+@group(0) @binding(1) var uTexture: texture_2d;
+@group(0) @binding(2) var uSampler: sampler;
+@group(1) @binding(0) var baseUniforms : BaseUniforms;
+@group(1) @binding(1) var stopsUniforms : StopsUniforms;
+
+struct VSOutput {
+ @builtin(position) position: vec4,
+ @location(0) uv : vec2,
+ @location(1) coord : vec2
+};
+
+fn filterVertexPosition(aPosition:vec2) -> vec4
+{
+ var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
+
+ position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
+ position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
+
+ return vec4(position, 0.0, 1.0);
+}
+
+fn filterTextureCoord( aPosition:vec2 ) -> vec2
+{
+ return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
+}
+
+fn filterCoord( vTextureCoord:vec2 ) -> vec2
+{
+ return vTextureCoord * gfu.uInputSize.xy / gfu.uOutputFrame.zw;
+}
+
+fn globalTextureCoord( aPosition:vec2 ) -> vec2
+{
+ return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
+}
+
+fn getSize() -> vec2
+{
+ return gfu.uGlobalFrame.zw;
+}
+
+@vertex
+fn mainVertex(
+ @location(0) aPosition : vec2,
+) -> VSOutput {
+ let vTextureCoord: vec2 = filterTextureCoord(aPosition);
+ return VSOutput(
+ filterVertexPosition(aPosition),
+ vTextureCoord,
+ filterCoord(vTextureCoord),
+ );
+}
+
+struct ColorStop {
+ offset: f32,
+ color: vec3,
+ alpha: f32,
+};
+
+fn rotate2d(angle: f32) -> mat2x2{
+ return mat2x2(cos(angle), -sin(angle),
+ sin(angle), cos(angle));
+}
+
+fn projectLinearPosition(pos: vec2, angle: f32) -> f32 {
+ var center: vec2 = vec2(0.5);
+ var result: vec2 = pos - center;
+ result = rotate2d(angle) * result;
+ result = result + center;
+ return clamp(result.x, 0.0, 1.0);
+}
+
+fn projectRadialPosition(pos: vec2) -> f32 {
+ var r: f32 = distance(pos, vec2(0.5));
+ return clamp(2.0 * r, 0.0, 1.0);
+}
+
+fn projectAnglePosition(pos: vec2, angle: f32) -> f32 {
+ var center: vec2 = pos - vec2(0.5, 0.5);
+ var polarAngle: f32 = atan2(-center.y, center.x);
+ return ((polarAngle + angle) % PI_2) / PI_2;
+}
+
+fn projectPosition(pos: vec2, gradientType: i32, angle: f32) -> f32 {
+ if (gradientType == TYPE_LINEAR) {
+ return projectLinearPosition(pos, angle);
+ } else if (gradientType == TYPE_RADIAL) {
+ return projectRadialPosition(pos);
+ } else if (gradientType == TYPE_CONIC) {
+ return projectAnglePosition(pos, angle);
+ }
+
+ return pos.y;
+}
+
+@fragment
+fn mainFragment(
+ @builtin(position) position: vec4,
+ @location(0) uv : vec2,
+ @location(1) coord : vec2
+) -> @location(0) vec4 {
+ let uType: i32 = i32(baseUniforms.uOptions[0]);
+ let uAngle: f32 = baseUniforms.uOptions[1];
+ let uAlpha: f32 = baseUniforms.uOptions[2];
+ let uReplace: f32 = baseUniforms.uOptions[3];
+
+ let uNumStops: i32 = i32(baseUniforms.uCounts[0]);
+ let uMaxColors: f32 = baseUniforms.uCounts[1];
+
+ // current/original color
+ var currentColor: vec4 = textureSample(uTexture, uSampler, uv);
+
+ // skip calculations if gradient alpha is 0
+ if (uAlpha == 0.0) { return currentColor; }
+
+ // project position
+ var y: f32 = projectPosition(coord, uType, radians(uAngle));
+
+ // check gradient bounds
+ var offsetMin: f32 = stopsUniforms.uStops[0][0];
+ var offsetMax: f32 = 0.0;
+
+ let numStops: i32 = uNumStops;
+
+ for (var i: i32 = 0; i < MAX_STOPS; i = i + 1) {
+ if (i == numStops - 1) { // last index
+ offsetMax = stopsUniforms.uStops[i][0];
+ }
+ }
+
+ if (y < offsetMin || y > offsetMax) { return currentColor; }
+
+ // limit colors
+ if (uMaxColors > 0.0) {
+ var stepSize: f32 = 1.0 / uMaxColors;
+ var stepNumber: f32 = floor(y / stepSize);
+ y = stepSize * (stepNumber + 0.5); // offset by 0.5 to use color from middle of segment
+ }
+
+ // find color stops
+ var stopFrom: ColorStop;
+ var stopTo: ColorStop;
+
+ for (var i: i32 = 0; i < MAX_STOPS; i = i + 1) {
+ if (y >= stopsUniforms.uStops[i][0]) {
+ stopFrom = ColorStop(stopsUniforms.uStops[i][0], stopsUniforms.uColors[i], stopsUniforms.uStops[i][1]);
+ stopTo = ColorStop(stopsUniforms.uStops[i + 1][0], stopsUniforms.uColors[i + 1], stopsUniforms.uStops[i + 1][1]);
+ }
+
+ if (i == numStops - 1) { // last index
+ break;
+ }
+ }
+
+ // mix colors from stops
+ var colorFrom: vec4 = vec4(stopFrom.color * stopFrom.alpha, stopFrom.alpha);
+ var colorTo: vec4 = vec4(stopTo.color * stopTo.alpha, stopTo.alpha);
+
+ var segmentHeight: f32 = stopTo.offset - stopFrom.offset;
+ var relativePos: f32 = y - stopFrom.offset; // position from 0 to [segmentHeight]
+ var relativePercent: f32 = relativePos / segmentHeight; // position in percent between [from.offset] and [to.offset].
+
+ var gradientAlpha: f32 = uAlpha * currentColor.a;
+ var gradientColor: vec4 = mix(colorFrom, colorTo, relativePercent) * gradientAlpha;
+
+ if (uReplace < 0.5) {
+ // mix resulting color with current color
+ return gradientColor + currentColor * (1.0 - gradientColor.a);
+ } else {
+ // replace with gradient color
+ return gradientColor;
+ }
+}
+
+const PI: f32 = 3.14159265358979323846264;
+const PI_2: f32 = PI * 2.0;
+
+const TYPE_LINEAR: i32 = 0;
+const TYPE_RADIAL: i32 = 1;
+const TYPE_CONIC: i32 = 2;
+const MAX_STOPS: i32 = 32;`,Ql=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Jl(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function ea(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function na(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")&&Object.keys(r).length===1?r.default:r}function ra(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var n=function t(){if(this instanceof t){var o=[null];o.push.apply(o,arguments);var u=Function.bind.apply(e,o);return new u}return e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(r).forEach(function(t){var o=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:function(){return r[t]}})}),n}var xn={},P=P||{};P.stringify=function(){var r={"visit_linear-gradient":function(e){return r.visit_gradient(e)},"visit_repeating-linear-gradient":function(e){return r.visit_gradient(e)},"visit_radial-gradient":function(e){return r.visit_gradient(e)},"visit_repeating-radial-gradient":function(e){return r.visit_gradient(e)},visit_gradient:function(e){var n=r.visit(e.orientation);return n&&(n+=", "),e.type+"("+n+r.visit(e.colorStops)+")"},visit_shape:function(e){var n=e.value,t=r.visit(e.at),o=r.visit(e.style);return o&&(n+=" "+o),t&&(n+=" at "+t),n},"visit_default-radial":function(e){var n="",t=r.visit(e.at);return t&&(n+=t),n},"visit_extent-keyword":function(e){var n=e.value,t=r.visit(e.at);return t&&(n+=" at "+t),n},"visit_position-keyword":function(e){return e.value},visit_position:function(e){return r.visit(e.value.x)+" "+r.visit(e.value.y)},"visit_%":function(e){return e.value+"%"},visit_em:function(e){return e.value+"em"},visit_px:function(e){return e.value+"px"},visit_literal:function(e){return r.visit_color(e.value,e)},visit_hex:function(e){return r.visit_color("#"+e.value,e)},visit_rgb:function(e){return r.visit_color("rgb("+e.value.join(", ")+")",e)},visit_rgba:function(e){return r.visit_color("rgba("+e.value.join(", ")+")",e)},visit_color:function(e,n){var t=e,o=r.visit(n.length);return o&&(t+=" "+o),t},visit_angular:function(e){return e.value+"deg"},visit_directional:function(e){return"to "+e.value},visit_array:function(e){var n="",t=e.length;return e.forEach(function(o,u){n+=r.visit(o),u0&&n("Invalid input not EOF"),f}function o(){return K(u)}function u(){return l("linear-gradient",r.linearGradient,p)||l("repeating-linear-gradient",r.repeatingLinearGradient,p)||l("radial-gradient",r.radialGradient,R)||l("repeating-radial-gradient",r.repeatingRadialGradient,R)}function l(f,g,d){return a(g,function(C){var Zr=d();return Zr&&(b(r.comma)||n("Missing comma before color stops")),{type:f,orientation:Zr,colorStops:K(Yl)}})}function a(f,g){var d=b(f);if(d){b(r.startCall)||n("Missing (");var C=g(d);return b(r.endCall)||n("Missing )"),C}}function p(){return v()||h()}function v(){return x("directional",r.sideOrCorner,1)}function h(){return x("angular",r.angleValue,1)}function R(){var f,g=D(),d;return g&&(f=[],f.push(g),d=e,b(r.comma)&&(g=D(),g?f.push(g):e=d)),f}function D(){var f=$()||Vl();if(f)f.at=Kr();else{var g=Ne();if(g){f=g;var d=Kr();d&&(f.at=d)}else{var C=Wr();C&&(f={type:"default-radial",at:C})}}return f}function $(){var f=x("shape",/^(circle)/i,0);return f&&(f.style=jr()||Ne()),f}function Vl(){var f=x("shape",/^(ellipse)/i,0);return f&&(f.style=W()||Ne()),f}function Ne(){return x("extent-keyword",r.extentKeywords,1)}function Kr(){if(x("position",/^at/,0)){var f=Wr();return f||n("Missing positioning value"),f}}function Wr(){var f=Xl();if(f.x||f.y)return{type:"position",value:f}}function Xl(){return{x:W(),y:W()}}function K(f){var g=f(),d=[];if(g)for(d.push(g);b(r.comma);)g=f(),g?d.push(g):n("One extra comma");return d}function Yl(){var f=Kl();return f||n("Expected color definition"),f.length=W(),f}function Kl(){return ql()||Hl()||jl()||Wl()}function Wl(){return x("literal",r.literalColor,0)}function ql(){return x("hex",r.hexColor,1)}function jl(){return a(r.rgbColor,function(){return{type:"rgb",value:K(qr)}})}function Hl(){return a(r.rgbaColor,function(){return{type:"rgba",value:K(qr)}})}function qr(){return b(r.number)[1]}function W(){return x("%",r.percentageValue,1)||Zl()||jr()}function Zl(){return x("position-keyword",r.positionKeywords,1)}function jr(){return x("px",r.pixelValue,1)||x("em",r.emValue,1)}function x(f,g,d){var C=b(g);if(C)return{type:f,value:C[d]}}function b(f){var g,d;return d=/^[\n\r\t\s]+/.exec(e),d&&Hr(d[0].length),g=f.exec(e),g&&Hr(g[0].length),g}function Hr(f){e=e.substr(f)}return function(f){return e=f.toString(),t()}}();var _o=xn.parse=P.parse,ta=xn.stringify=P.stringify;function yn(r){const e=_o(zn(r));if(e.length===0)throw new Error("Invalid CSS gradient.");if(e.length!==1)throw new Error("Unsupported CSS gradient (multiple gradients is not supported).");const n=e[0],t=Sn(n.type),o=bn(n.colorStops),u=Pn(n.orientation);return{type:t,stops:o,angle:u}}function Sn(r){const e={"linear-gradient":0,"radial-gradient":1};if(!(r in e))throw new Error(`Unsupported gradient type "${r}"`);return e[r]}function bn(r){const e=Tn(r),n=[],t=new i.Color;for(let o=0;o{for(let u=o;u6?parseFloat(r.toString().substring(0,6)):r}function Pn(r){if(typeof r=="undefined")return 0;if("type"in r&&"value"in r)switch(r.type){case"angular":return parseFloat(r.value);case"directional":return On(r.value)}return 0}function On(r){const e={left:270,top:0,bottom:180,right:90,"left top":315,"top left":315,"left bottom":225,"bottom left":225,"right top":45,"top right":45,"right bottom":135,"bottom right":135};if(!(r in e))throw new Error(`Unsupported directional value "${r}"`);return e[r]}function zn(r){let e=r.replace(/\s{2,}/gu," ");return e=e.replace(/;/g,""),e=e.replace(/ ,/g,","),e=e.replace(/\( /g,"("),e=e.replace(/ \)/g,")"),e.trim()}var Do=Object.defineProperty,$o=Object.defineProperties,Go=Object.getOwnPropertyDescriptors,Fn=Object.getOwnPropertySymbols,Mo=Object.prototype.hasOwnProperty,Eo=Object.prototype.propertyIsEnumerable,ie=(r,e,n)=>e in r?Do(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,ue=(r,e)=>{for(var n in e||(e={}))Mo.call(e,n)&&ie(r,n,e[n]);if(Fn)for(var n of Fn(e))Eo.call(e,n)&&ie(r,n,e[n]);return r},Lo=(r,e)=>$o(r,Go(e)),O=(r,e,n)=>(ie(r,typeof e!="symbol"?e+"":e,n),n);const le=90;function ko(r){return[...r].sort((e,n)=>e.offset-n.offset)}const I=class q extends i.Filter{constructor(e){var n,t,o;if(e&&"css"in e?e=Lo(ue({},yn(e.css||"")),{alpha:(n=e.alpha)!=null?n:q.defaults.alpha,maxColors:(t=e.maxColors)!=null?t:q.defaults.maxColors}):e=ue(ue({},q.defaults),e),!e.stops||e.stops.length<2)throw new Error("ColorGradientFilter requires at least 2 color stops.");const u=i.GpuProgram.from({vertex:{source:hn,entryPoint:"mainVertex"},fragment:{source:hn,entryPoint:"mainFragment"}}),l=i.GlProgram.from({vertex:Uo,fragment:Io,name:"color-gradient-filter"}),a=32;super({gpuProgram:u,glProgram:l,resources:{baseUniforms:{uOptions:{value:[e.type,(o=e.angle)!=null?o:le,e.alpha,e.replace?1:0],type:"vec4"},uCounts:{value:[e.stops.length,e.maxColors],type:"vec2"}},stopsUniforms:{uColors:{value:new Float32Array(a*3),type:"vec3",size:a},uStops:{value:new Float32Array(a*4),type:"vec4",size:a}}}}),O(this,"baseUniforms"),O(this,"stopsUniforms"),O(this,"_stops",[]),this.baseUniforms=this.resources.baseUniforms.uniforms,this.stopsUniforms=this.resources.stopsUniforms.uniforms,Object.assign(this,e)}get stops(){return this._stops}set stops(e){const n=ko(e),t=new i.Color;let o,u,l;for(let a=0;a.5}set replace(e){this.baseUniforms.uOptions[3]=e?1:0}};O(I,"LINEAR",0),O(I,"RADIAL",1),O(I,"CONIC",2),O(I,"defaults",{type:I.LINEAR,stops:[{offset:0,color:16711680,alpha:1},{offset:1,color:255,alpha:1}],alpha:1,angle:90,maxColors:0,replace:!1});let Bo=I;var No=`in vec2 vTextureCoord;
+out vec4 finalColor;
+
+uniform sampler2D uTexture;
+uniform sampler2D uMapTexture;
+uniform float uMix;
+uniform float uSize;
+uniform float uSliceSize;
+uniform float uSlicePixelSize;
+uniform float uSliceInnerSize;
+
+void main() {
+ vec4 color = texture(uTexture, vTextureCoord.xy);
+ vec4 adjusted;
+
+ if (color.a > 0.0) {
+ color.rgb /= color.a;
+ float innerWidth = uSize - 1.0;
+ float zSlice0 = min(floor(color.b * innerWidth), innerWidth);
+ float zSlice1 = min(zSlice0 + 1.0, innerWidth);
+ float xOffset = uSlicePixelSize * 0.5 + color.r * uSliceInnerSize;
+ float s0 = xOffset + (zSlice0 * uSliceSize);
+ float s1 = xOffset + (zSlice1 * uSliceSize);
+ float yOffset = uSliceSize * 0.5 + color.g * (1.0 - uSliceSize);
+ vec4 slice0Color = texture(uMapTexture, vec2(s0,yOffset));
+ vec4 slice1Color = texture(uMapTexture, vec2(s1,yOffset));
+ float zOffset = fract(color.b * innerWidth);
+ adjusted = mix(slice0Color, slice1Color, zOffset);
+
+ color.rgb *= color.a;
+ }
+
+ finalColor = vec4(mix(color, adjusted, uMix).rgb, color.a);
+
+}`,Vo=`struct ColorMapUniforms {
+ uMix: f32,
+ uSize: f32,
+ uSliceSize: f32,
+ uSlicePixelSize: f32,
+ uSliceInnerSize: f32,
+};
+
+@group(0) @binding(1) var uTexture: texture_2d;
+@group(0) @binding(2) var uSampler: sampler;
+@group(1) @binding(0) var colorMapUniforms : ColorMapUniforms;
+@group(1) @binding(1) var uMapTexture: texture_2d;
+@group(1) @binding(2) var uMapSampler: sampler;
+
+@fragment
+fn mainFragment(
+ @builtin(position) position: vec4,
+ @location(0) uv : vec2
+) -> @location(0) vec4 {
+ var color:vec4 = textureSample(uTexture, uSampler, uv);
+
+ var adjusted: vec4;
+
+ var altColor: vec4 = vec4(color.rgb / color.a, color.a);
+ let innerWidth: f32 = colorMapUniforms.uSize - 1.0;
+ let zSlice0: f32 = min(floor(color.b * innerWidth), innerWidth);
+ let zSlice1: f32 = min(zSlice0 + 1.0, innerWidth);
+ let xOffset: f32 = colorMapUniforms.uSlicePixelSize * 0.5 + color.r * colorMapUniforms.uSliceInnerSize;
+ let s0: f32 = xOffset + (zSlice0 * colorMapUniforms.uSliceSize);
+ let s1: f32 = xOffset + (zSlice1 * colorMapUniforms.uSliceSize);
+ let yOffset: f32 = colorMapUniforms.uSliceSize * 0.5 + color.g * (1.0 - colorMapUniforms.uSliceSize);
+ let slice0Color: vec4 = textureSample(uMapTexture, uMapSampler, vec2(s0,yOffset));
+ let slice1Color: vec4 = textureSample(uMapTexture, uMapSampler, vec2(s1,yOffset));
+ let zOffset: f32 = fract(color.b * innerWidth);
+ adjusted = mix(slice0Color, slice1Color, zOffset);
+ altColor = vec4(color.rgb * color.a, color.a);
+
+ let realColor: vec4 = select(color, altColor, color.a > 0.0);
+
+ return vec4(mix(realColor, adjusted, colorMapUniforms.uMix).rgb, realColor.a);
+}`,Xo=Object.defineProperty,wn=Object.getOwnPropertySymbols,Yo=Object.prototype.hasOwnProperty,Ko=Object.prototype.propertyIsEnumerable,ae=(r,e,n)=>e in r?Xo(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,An=(r,e)=>{for(var n in e||(e={}))Yo.call(e,n)&&ae(r,n,e[n]);if(wn)for(var n of wn(e))Ko.call(e,n)&&ae(r,n,e[n]);return r},S=(r,e,n)=>(ae(r,typeof e!="symbol"?e+"":e,n),n);const In=class ut extends i.Filter{constructor(...e){var n;let t=(n=e[0])!=null?n:{};if((t instanceof i.Texture||t instanceof i.TextureSource)&&(i.deprecation("6.0.0","ColorMapFilter constructor params are now options object. See params: { colorMap, nearest, mix }"),t={colorMap:t},e[1]!==void 0&&(t.nearest=e[1]),e[2]!==void 0&&(t.mix=e[2])),t=An(An({},ut.DEFAULT_OPTIONS),t),!t.colorMap)throw Error("No color map texture source was provided to ColorMapFilter");const o=i.GpuProgram.from({vertex:{source:m,entryPoint:"mainVertex"},fragment:{source:Vo,entryPoint:"mainFragment"}}),u=i.GlProgram.from({vertex:c,fragment:No,name:"color-map-filter"});super({gpuProgram:o,glProgram:u,resources:{colorMapUniforms:{uMix:{value:t.mix,type:"f32"},uSize:{value:0,type:"f32"},uSliceSize:{value:0,type:"f32"},uSlicePixelSize:{value:0,type:"f32"},uSliceInnerSize:{value:0,type:"f32"}},uMapTexture:t.colorMap.source,uMapSampler:t.colorMap.source.style}}),S(this,"uniforms"),S(this,"_size",0),S(this,"_sliceSize",0),S(this,"_slicePixelSize",0),S(this,"_sliceInnerSize",0),S(this,"_nearest",!1),S(this,"_scaleMode","linear"),S(this,"_colorMap"),this.uniforms=this.resources.colorMapUniforms.uniforms,Object.assign(this,t)}get mix(){return this.uniforms.uMix}set mix(e){this.uniforms.uMix=e}get colorSize(){return this._size}get colorMap(){return this._colorMap}set colorMap(e){if(!e||e===this.colorMap)return;const n=e instanceof i.Texture?e.source:e;n.style.scaleMode=this._scaleMode,n.autoGenerateMipmaps=!1,this._size=n.height,this._sliceSize=1/this._size,this._slicePixelSize=this._sliceSize/this._size,this._sliceInnerSize=this._slicePixelSize*(this._size-1),this.uniforms.uSize=this._size,this.uniforms.uSliceSize=this._sliceSize,this.uniforms.uSlicePixelSize=this._slicePixelSize,this.uniforms.uSliceInnerSize=this._sliceInnerSize,this.resources.uMapTexture=n,this._colorMap=e}get nearest(){return this._nearest}set nearest(e){this._nearest=e,this._scaleMode=e?"nearest":"linear";const n=this._colorMap;n&&n.source&&(n.source.scaleMode=this._scaleMode,n.source.autoGenerateMipmaps=!1,n.source.style.update(),n.source.update())}updateColorMap(){const e=this._colorMap;e!=null&&e.source&&(e.source.update(),this.colorMap=e)}destroy(){var e;(e=this._colorMap)==null||e.destroy(),super.destroy()}};S(In,"DEFAULT_OPTIONS",{colorMap:i.Texture.WHITE,nearest:!1,mix:1});let Wo=In;var qo=`in vec2 vTextureCoord;
+out vec4 finalColor;
+
+uniform sampler2D uTexture;
+uniform vec3 uColor;
+uniform float uAlpha;
+
+void main(void) {
+ vec4 c = texture(uTexture, vTextureCoord);
+ finalColor = vec4(mix(c.rgb, uColor.rgb, c.a * uAlpha), c.a);
+}
+`,jo=`struct ColorOverlayUniforms {
+ uColor: vec3,
+ uAlpha: f32,
+};
+
+@group(0) @binding(1) var uTexture: texture_2d;
+@group(0) @binding(2) var uSampler: sampler;
+@group(1) @binding(0) var colorOverlayUniforms : ColorOverlayUniforms;
+
+@fragment
+fn mainFragment(
+ @builtin(position) position: vec4