import{TempNode as O,NodeUpdateType as D,RendererUtils as F,QuadMesh as L,NodeMaterial as f}from"./CfobEeQC.js";import{nodeObject as P,uniform as g,texture as c,passTexture as W,Fn as B,luminance as j,smoothstep as q,mix as H,vec4 as m,uniformArray as M,float as b,uv as E,Loop as Q,int as U,add as X}from"./BZQzXWp7.js";import{R as N,H as w,b as x,V as _}from"./C-SOZ1Oi.js";const p=new L,Y=new x,G=new x(1,0),I=new x(0,1);let z;class J extends O{static get type(){return"BloomNode"}constructor(r,t=1,i=0,s=0){super("vec4"),this.inputNode=r,this.strength=g(t),this.radius=g(i),this.threshold=g(s),this.smoothWidth=g(.01),this._renderTargetsHorizontal=[],this._renderTargetsVertical=[],this._nMips=5,this._renderTargetBright=new N(1,1,{depthBuffer:!1,type:w}),this._renderTargetBright.texture.name="UnrealBloomPass.bright",this._renderTargetBright.texture.generateMipmaps=!1;for(let e=0;e{const a=this.inputNode,l=j(a.rgb),d=q(this.threshold,this.threshold.add(this.smoothWidth),l);return H(m(0),a,d)});this._highPassFilterMaterial=this._highPassFilterMaterial||new f,this._highPassFilterMaterial.fragmentNode=t().context(r.getSharedContext()),this._highPassFilterMaterial.name="Bloom_highPass",this._highPassFilterMaterial.needsUpdate=!0;const i=[3,5,7,9,11];for(let a=0;a{const d=b(1.2).sub(a);return H(a,d,l)}).setLayout({name:"lerpBloomFactor",type:"float",inputs:[{name:"factor",type:"float"},{name:"radius",type:"float"}]}),u=B(()=>{const a=o(s.element(0),this.radius).mul(m(e.element(0),1)).mul(this._textureNodeBlur0),l=o(s.element(1),this.radius).mul(m(e.element(1),1)).mul(this._textureNodeBlur1),d=o(s.element(2),this.radius).mul(m(e.element(2),1)).mul(this._textureNodeBlur2),h=o(s.element(3),this.radius).mul(m(e.element(3),1)).mul(this._textureNodeBlur3),n=o(s.element(4),this.radius).mul(m(e.element(4),1)).mul(this._textureNodeBlur4);return a.add(l).add(d).add(h).add(n).mul(this.strength)});return this._compositeMaterial=this._compositeMaterial||new f,this._compositeMaterial.fragmentNode=u().context(r.getSharedContext()),this._compositeMaterial.name="Bloom_comp",this._compositeMaterial.needsUpdate=!0,this._textureOutput}dispose(){for(let r=0;rs.sample(n),d=B(()=>{const n=e.element(0).toVar(),T=l(a).rgb.mul(n).toVar();return Q({start:U(1),end:U(t),type:"int",condition:"<"},({i:V})=>{const R=b(V),v=e.element(V),y=u.mul(o).mul(R),A=l(a.add(y)).rgb,C=l(a.sub(y)).rgb;T.addAssign(X(A,C).mul(v)),n.addAssign(b(2).mul(v))}),m(T.div(n),1)}),h=new f;return h.fragmentNode=d().context(r.getSharedContext()),h.name="Bloom_separable",h.needsUpdate=!0,h.colorTexture=s,h.direction=u,h.invSize=o,h}}const k=(S,r,t,i)=>P(new J(P(S),r,t,i));export{k as bloom,J as default};