/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as t,__param as e}from"tslib";import{uniform as i,define as r,texture as o,input as l,UniformGroup as s,FragmentOutput as u}from"../../GraphShaderModule.js";import{Vec2 as n,Float as d,Sampler2D as p,texture2D as a,sqrt as y,clamp as m,mix as c,exp as v}from"../../graph/glsl.js";import{PostProcessingFragmentInput as g,PostProcessingShader as f}from"./PostProcessingShader.js";class h extends s{}t([i(n)],h.prototype,"texSize",void 0),t([i(n)],h.prototype,"direction",void 0),t([i(d)],h.prototype,"sigma",void 0);class w extends f{constructor(){super(...arguments),this.type="GaussianBlurShader"}fragment(t){const e=new u,i=new d(1).divide(this.gaussianBlurConfig.texSize),r=this.gaussianBlurConfig.sigma;let o=x(new d(0),r),l=a(this.texture,t.uv).multiply(o);for(let s=1;s<this.kernelRadius;s++){const e=new d(s),u=x(e,r),n=this.gaussianBlurConfig.direction.multiply(i).multiply(e),p=a(this.texture,t.uv.add(n)),y=a(this.texture,t.uv.subtract(n));l=l.add(p.multiply(u)).add(y.multiply(u)),o=o.add(new d(2).multiply(u))}return e.fragColor=l.divide(o),e}}function x(t,e){return new d(.39894).multiply(v(new d(-.5).multiply(t).multiply(t).divide(e.multiply(e))).divide(e))}t([r],w.prototype,"kernelRadius",void 0),t([i(h)],w.prototype,"gaussianBlurConfig",void 0),t([o(p)],w.prototype,"texture",void 0),t([e(0,l(g))],w.prototype,"fragment",null);const B=1,C=2.2,S=[-.08,-.05,-.03,-.02,-.01,.01,.02,.03,.05,.08];class R extends f{constructor(){super(...arguments),this.type="RadialBlurShader"}fragment(t){const e=new u;let i=new d(.5).subtract(t.uv);const r=y(i.x.multiply(i.y).add(i.y.multiply(i.y)));i=i.divide(r);const o=a(this.texture,t.uv);let l=o;for(let u=0;u<10;u++){const e=a(this.texture,t.uv.add(i).multiply(new d(S[u]).multiply(B)));l=l.add(e)}const s=new d(1).divide(new d(11));l=l.multiply(s);let n=r.multiply(C);return n=m(n,new d(0),new d(1)),e.fragColor=c(o,l,n),e}}t([r],R.prototype,"kernelRadius",void 0),t([o(p)],R.prototype,"texture",void 0),t([e(0,l(g))],R.prototype,"fragment",null);export{w as GaussianBlurShader,R as RadialBlurShader};
