/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../views/3d/webgl-engine/core/shaderLibrary/ShaderOutputOptions","../views/3d/webgl-engine/core/shaderLibrary/Slice.glsl","../views/3d/webgl-engine/core/shaderLibrary/Transform.glsl","../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexColor.glsl","../views/3d/webgl-engine/core/shaderLibrary/output/OutputDepth.glsl","../views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl","../views/3d/webgl-engine/core/shaderLibrary/shading/MultipassTerrainTest.glsl","../views/3d/webgl-engine/core/shaderLibrary/util/AlphaCutoff","../views/3d/webgl-engine/core/shaderLibrary/util/ColorConversion.glsl","../views/3d/webgl-engine/core/shaderLibrary/util/View.glsl","../views/3d/webgl-engine/core/shaderModules/Float2PassUniform","../views/3d/webgl-engine/core/shaderModules/Float4PassUniform","../views/3d/webgl-engine/core/shaderModules/interfaces","../views/3d/webgl-engine/core/shaderModules/ShaderBuilder","../views/3d/webgl-engine/lib/basicInterfaces","../views/3d/webgl-engine/lib/VertexAttribute"],(function(e,r,o,l,i,t,a,s,n,d,u,g,p,h,c,v,w){"use strict";function b(e){const b=new c.ShaderBuilder,f=e.output===r.ShaderOutput.Depth,C=e.hasMultipassTerrain&&(e.output===r.ShaderOutput.Color||e.output===r.ShaderOutput.Alpha);u.addProjViewLocalOrigin(b,e),b.include(l.Transform,{hasModelTransformation:!1,linearDepth:f}),b.include(i.VertexColor,e),b.attributes.add(w.VertexAttribute.POSITION,"vec3"),b.varyings.add("vpos","vec3"),C&&b.varyings.add("depth","float");const{vertex:y,fragment:m}=b;return f&&(b.include(t.OutputDepth,e),y.uniforms.add(new g.Float2PassUniform("nearFar",((e,r)=>r.camera.nearFar))),b.varyings.add("linearDepth","float")),y.code.add(h.glsl`
    void main(void) {
      vpos = position;
      forwardNormalizedVertexColor();
      ${C?"depth = (view * vec4(vpos, 1.0)).z;":""}
      gl_Position = ${f?h.glsl`transformPositionWithDepth(proj, view, vpos, nearFar, linearDepth);`:h.glsl`transformPosition(proj, view, vpos);`}
    }
  `),b.include(o.SliceDraw,e),C&&b.include(s.multipassTerrainTest,e),m.include(d.ColorConversion),m.uniforms.add(new p.Float4PassUniform("eColor",(e=>e.color))),e.output===r.ShaderOutput.Highlight&&b.include(a.OutputHighlight),m.code.add(h.glsl`
  void main() {
    discardBySlice(vpos);
    ${C?"terrainDepthTest(gl_FragCoord, depth);":""}
    vec4 fColor = ${e.hasVertexColors?"vColor * eColor;":"eColor;"}

    if (fColor.a < ${h.glsl.float(n.symbolAlphaCutoff)}) {
      discard;
    }

    ${e.output===r.ShaderOutput.Alpha?h.glsl`gl_FragColor = vec4(fColor.a);`:""}

    ${e.output===r.ShaderOutput.Color?h.glsl`gl_FragColor = highlightSlice(fColor, vpos); ${e.transparencyPassType===v.TransparencyPassType.Color?"gl_FragColor = premultiplyAlpha(gl_FragColor);":""}`:""}
    ${e.output===r.ShaderOutput.Highlight?h.glsl`outputHighlight();`:""};
    ${e.output===r.ShaderOutput.Depth?h.glsl`outputDepth(linearDepth);`:""};
  }
  `),b}const f=Object.freeze(Object.defineProperty({__proto__:null,build:b},Symbol.toStringTag,{value:"Module"}));e.ColorMaterial=f,e.build=b}));
