/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","./_rollupPluginBabelHelpers","../core/compilerUtils","../views/3d/webgl-engine/core/shaderLibrary/ScreenSpacePass","../views/3d/webgl-engine/core/shaderModules/FloatPassUniform","../views/3d/webgl-engine/core/shaderModules/IntegerPassUniform","../views/3d/webgl-engine/core/shaderModules/interfaces","../views/3d/webgl-engine/core/shaderModules/ShaderBuilder","../views/3d/webgl-engine/core/shaderModules/Texture2DPassUniform","../views/3d/webgl-engine/shaders/CompositingTechniqueConfiguration"],(function(e,r,o,a,t,n,i,s,c,l){"use strict";let u=function(e){function o(){var r;return(r=e.apply(this,arguments)||this).overlayIndex=0,r.opacity=1,r}return r._inheritsLoose(o,e),o}(i.NoParameters);function d(e){const r=new s.ShaderBuilder;r.include(a.ScreenSpacePass);const u=r.fragment;switch(e.function){case l.CompositingFunction.Standard:u.uniforms.add(new c.Texture2DPassUniform("tex",(e=>e.texture))),e.hasOpacityFactor?(u.uniforms.add(new t.FloatPassUniform("opacity",(e=>e.opacity))),u.code.add(i.glsl`void main() {
gl_FragColor = texture2D(tex, uv) * opacity;
}`)):u.code.add(i.glsl`void main() {
gl_FragColor = texture2D(tex, uv);
}`);break;case l.CompositingFunction.OverlayWithTransparency:u.uniforms.add(new c.Texture2DPassUniform("tex",(e=>e.texture))),u.uniforms.add(new n.IntegerPassUniform("overlayIdx",(e=>e.overlayIndex))),e.hasOpacityFactor&&u.uniforms.add(new t.FloatPassUniform("opacity",(e=>e.opacity))),u.code.add(i.glsl`
        void main() {
          vec2 overlayUV = overlayIdx == 0 ? vec2(uv.x * 0.5, uv.y) : vec2(uv.x * 0.5 + 0.5, uv.y);
          gl_FragColor = texture2D(tex, overlayUV) ${e.hasOpacityFactor?"* opacity":""};
        }`);break;case l.CompositingFunction.TransparentToHUDVisibility:u.uniforms.add(new c.Texture2DPassUniform("tex",(e=>e.texture))),u.code.add(i.glsl`void main() {
gl_FragColor = vec4(1.0 - texture2D(tex, uv).a);
}`);break;case l.CompositingFunction.Transparency:u.uniforms.add([new c.Texture2DPassUniform("colorTexture",(e=>e.colorTexture)),new c.Texture2DPassUniform("alphaTexture",(e=>e.alphaTexture)),new c.Texture2DPassUniform("frontFaceTexture",(e=>e.frontFaceTexture))]),u.code.add(i.glsl`void main() {
vec4 srcColor = texture2D(colorTexture, uv);
if(srcColor.a <= 1e-5){
discard;
}
float srcAlpha = texture2D(alphaTexture, uv).r;
vec4 frontFace = texture2D(frontFaceTexture, uv);
gl_FragColor = vec4(mix(srcColor.rgb/srcColor.a, frontFace.rgb, frontFace.a), 1.0 - srcAlpha);
}`);break;case l.CompositingFunction.COUNT:break;default:o.neverReached(e.function)}return r}const g=Object.freeze(Object.defineProperty({__proto__:null,CompositingPassParameters:u,build:d},Symbol.toStringTag,{value:"Module"}));e.Compositing=g,e.CompositingPassParameters=u,e.build=d}));
