/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../chunks/_rollupPluginBabelHelpers","../core/shaderModules/BooleanPassUniform","../core/shaderModules/Float4Uniform","../core/shaderModules/interfaces","../core/shaderModules/ShaderBuilder","../core/shaderModules/Texture2DUniform","../lib/VertexAttribute"],(function(e,r,a,o,t,n,l,i){"use strict";let s=function(e){function a(){var r;return(r=e.apply(this,arguments)||this).maskEnabled=!1,r.overlayEnabled=!1,r}return r._inheritsLoose(a,e),a}(t.NoParameters);function u(){const e=new n.ShaderBuilder;return e.attributes.add(i.VertexAttribute.POSITION,"vec2"),e.vertex.uniforms.add(new o.Float4Uniform("drawPosition")),e.varyings.add("vUV","vec2"),e.vertex.code.add(t.glsl`void main(void) {
vUV = position;
gl_Position = vec4(drawPosition.xy + vec2(position - 0.5) * drawPosition.zw, 0.0, 1.0);
}`),e.fragment.uniforms.add(new l.Texture2DUniform("textureInput")),e.fragment.uniforms.add(new l.Texture2DUniform("textureMask")),e.fragment.uniforms.add(new l.Texture2DUniform("textureOverlay")),e.fragment.uniforms.add(new a.BooleanPassUniform("maskEnabled",(e=>e.maskEnabled))),e.fragment.uniforms.add(new a.BooleanPassUniform("overlayEnabled",(e=>e.overlayEnabled))),e.fragment.code.add(t.glsl`const float barrelFactor = 1.1;
vec2 barrel(vec2 uv) {
vec2 uvn = uv * 2.0 - 1.0;
if (uvn.x == 0.0 && uvn.y == 0.0) {
return vec2(0.5, 0.5);
}
float theta = atan(uvn.y, uvn.x);
float r = pow(length(uvn), barrelFactor);
return r * vec2(cos(theta), sin(theta)) * 0.5 + 0.5;
}
void main() {
float mask = maskEnabled ? texture2D(textureMask, vUV).a : 1.0;
vec4 inputColor = texture2D(textureInput, barrel(vUV)) * mask;
vec4 overlayColor = overlayEnabled ? texture2D(textureOverlay, vUV) : vec4(0);
gl_FragColor = overlayColor + (1.0 - overlayColor.a) * inputColor;
}`),e}e.MagnifierPassParameters=s,e.build=u,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
