/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../ShaderOutputOptions","../Slice.glsl","../Transform.glsl","../attributes/NormalAttribute.glsl","../attributes/TextureCoordinateAttribute.glsl","../attributes/VertexNormal.glsl","../output/OutputDepth.glsl","../output/OutputHighlight.glsl","../shading/VisualVariables.glsl","../util/AlphaDiscard.glsl","../util/View.glsl","../../shaderModules/Float2PassUniform","../../shaderModules/interfaces","../../shaderModules/Texture2DPassUniform"],(function(e,r,t,o,a,l,i,s,d,u,n,c,p,v,m){"use strict";function g(e,g){const h=e.vertex.code,f=e.fragment.code,x=g.hasModelTransformation;g.output!==r.ShaderOutput.Depth&&g.output!==r.ShaderOutput.Shadow||(c.addProjViewLocalOrigin(e,g),e.include(o.Transform,{linearDepth:!0,hasModelTransformation:x}),e.include(l.TextureCoordinateAttribute,g),e.include(u.VisualVariables,g),e.include(s.OutputDepth,g),e.include(t.SliceDraw,g),e.vertex.uniforms.add(new p.Float2PassUniform("nearFar",((e,r)=>r.camera.nearFar))),e.varyings.add("depth","float"),g.hasColorTexture&&e.fragment.uniforms.add(new m.Texture2DPassUniform("tex",(e=>e.texture))),h.add(v.glsl`
      void main(void) {
        vpos = calculateVPos();
        vpos = subtractOrigin(vpos);
        vpos = addVerticalOffset(vpos, localOrigin);
        gl_Position = transformPositionWithDepth(proj, view, ${x?"model,":""} vpos, nearFar, depth);
        forwardTextureCoordinates();
      }
    `),e.include(n.DiscardOrAdjustAlphaPass,g),f.add(v.glsl`
      void main(void) {
        discardBySlice(vpos);
        ${g.hasColorTexture?v.glsl`
        vec4 texColor = texture2D(tex, vuv0);
        discardOrAdjustAlpha(texColor);`:""}
        outputDepth(depth);
      }
    `)),g.output===r.ShaderOutput.Normal&&(c.addProjViewLocalOrigin(e,g),e.include(o.Transform,{linearDepth:!1,hasModelTransformation:x}),e.include(a.NormalAttribute,g),e.include(i.VertexNormal,g),e.include(l.TextureCoordinateAttribute,g),e.include(u.VisualVariables,g),g.hasColorTexture&&e.fragment.uniforms.add(new m.Texture2DPassUniform("tex",(e=>e.texture))),e.varyings.add("vPositionView","vec3"),h.add(v.glsl`
      void main(void) {
        vpos = calculateVPos();
        vpos = subtractOrigin(vpos);
        ${g.normalType===a.NormalAttributeType.Attribute?v.glsl`
        vNormalWorld = dpNormalView(vvLocalNormal(normalModel()));`:""}
        vpos = addVerticalOffset(vpos, localOrigin);
        gl_Position = transformPosition(proj, view, ${x?"model,":""} vpos);
        forwardTextureCoordinates();
      }
    `),e.include(t.SliceDraw,g),e.include(n.DiscardOrAdjustAlphaPass,g),f.add(v.glsl`
      void main() {
        discardBySlice(vpos);
        ${g.hasColorTexture?v.glsl`
        vec4 texColor = texture2D(tex, vuv0);
        discardOrAdjustAlpha(texColor);`:""}

        ${g.normalType===a.NormalAttributeType.ScreenDerivative?v.glsl`
            vec3 normal = screenDerivativeNormal(vPositionView);`:v.glsl`
            vec3 normal = normalize(vNormalWorld);
            if (gl_FrontFacing == false) normal = -normal;`}
        gl_FragColor = vec4(vec3(0.5) + 0.5 * normal, 1.0);
      }
    `)),g.output===r.ShaderOutput.Highlight&&(c.addProjViewLocalOrigin(e,g),e.include(o.Transform,{linearDepth:!1,hasModelTransformation:x}),e.include(l.TextureCoordinateAttribute,g),e.include(u.VisualVariables,g),g.hasColorTexture&&e.fragment.uniforms.add(new m.Texture2DPassUniform("tex",(e=>e.texture))),h.add(v.glsl`
      void main(void) {
        vpos = calculateVPos();
        vpos = subtractOrigin(vpos);
        vpos = addVerticalOffset(vpos, localOrigin);
        gl_Position = transformPosition(proj, view, ${x?"model,":""} vpos);
        forwardTextureCoordinates();
      }
    `),e.include(t.SliceDraw,g),e.include(n.DiscardOrAdjustAlphaPass,g),e.include(d.OutputHighlight),f.add(v.glsl`
      void main() {
        discardBySlice(vpos);
        ${g.hasColorTexture?v.glsl`
        vec4 texColor = texture2D(tex, vuv0);
        discardOrAdjustAlpha(texColor);`:""}
        outputHighlight();
      }
    `))}e.DefaultMaterialAuxiliaryPasses=g,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
