/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{isColor as o}from"../core/shaderLibrary/ShaderOutput.js";import{Emissions as r}from"../core/shaderLibrary/output/Emissions.glsl.js";import{OutputHighlight as l}from"../core/shaderLibrary/output/OutputHighlight.glsl.js";import{ColorConversion as i}from"../core/shaderLibrary/util/ColorConversion.glsl.js";import{If as a,glsl as s}from"../core/shaderModules/glsl.js";import{alphaCutoff as t}from"../../../../webscene/support/AlphaCutoff.js";function e(e,n){e.include(l,n),e.include(r,n),e.fragment.include(i);const{output:f,oitPass:u,hasEmission:m,discardInvisibleFragments:d,oitPremultipliedAlpha:p,snowCover:c}=n,g=9===f,C=o(f)&&1===u,h=o(f)&&2===u,v=o(f)&&1!==u;let b=0;(v||C)&&e.outputs.add("fragColor","vec4",b++),m&&e.outputs.add("fragEmission","vec4",b++),C&&e.outputs.add("fragAlpha","float",b++),e.fragment.code.add(s`
    void outputColorHighlightOLID(vec4 finalColor, vec3 emissiveSymbolColor ${a(c,", float snow")}) {
      ${a(g,"finalColor.a = 1.0;")}
      ${a(d,`if (finalColor.a < ${s.float(t)}) { discard; }`)}

      ${a(C,`${a(p,"fragColor = finalColor;","fragColor = premultiplyAlpha(finalColor);")}\n           fragAlpha = finalColor.a;`)}
      ${a(h&&p&&d,"finalColor.rgb /= finalColor.a;")}
      ${a(v,"fragColor = finalColor;")}
      ${a(m,`fragEmission = ${a(c,"mix(finalColor.a * getEmissions(emissiveSymbolColor), vec4(0.0), snow);","finalColor.a * getEmissions(emissiveSymbolColor);")}`)}
      calculateOcclusionAndOutputHighlight();
      ${a(g,"outputObjectAndLayerIdColor();")}
    }
  `)}export{e as outputColorHighlightOLID};
