/* COPYRIGHT Esri - https://js.arcgis.com/5.0/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:d,discardInvisibleFragments:m,oitPremultipliedAlpha:p,snowCover:c}=n,C=9===f,g=o(f)&&1===u,h=o(f)&&2===u,v=o(f)&&1!==u;let b=0;(v||g)&&e.outputs.add("fragColor","vec4",b++),d&&e.outputs.add("fragEmission","vec4",b++),g&&e.outputs.add("fragAlpha","float",b++),e.fragment.code.add(s`
    void outputColorHighlightOLID(vec4 finalColor, const in vec3 vWorldPosition, vec3 emissiveSymbolColor ${a(c,", float snow")}) {
      ${a(C,"finalColor.a = 1.0;")}
      ${a(m,`if (finalColor.a < ${s.float(t)}) { discard; }`)}
      finalColor = applySlice(finalColor, vWorldPosition);

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