/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
import{isColor as o,isOITColorAlpha as i,isOITFrontFace as l}from"../core/shaderLibrary/ShaderOutput.js";import{Emissions as r}from"../core/shaderLibrary/output/Emissions.glsl.js";import{OutputHighlight as s}from"../core/shaderLibrary/output/OutputHighlight.glsl.js";import{ColorConversion as a}from"../core/shaderLibrary/util/ColorConversion.glsl.js";import{emissionDimming as e}from"../core/shaderLibrary/util/EmissionDimming.glsl.js";import{If as n,glsl as t}from"../core/shaderModules/glsl.js";import{alphaCutoff as f}from"./alphaCutoff.glsl.js";import{ditherNoise as m}from"./ditherNoise.glsl.js";import{oitResolution as u}from"./oitResolution.glsl.js";function d(d,g){d.include(s,g),d.include(r,g);const{fragment:c,outputs:p}=d;c.include(a);const{output:C,hasEmission:h,oitPremultipliedAlpha:b,snowCover:v,emissionDimmingPass:E,renderOccluded:y}=g,j=11===C,O=i(C),$=l(C),A=o(C)&&!O,L=0!==C||y;let S=0;(A||O)&&p.add("fragColor","vec4",S++),O&&p.add("fragAlpha","float",S++),h&&p.add("fragEmission","vec4",S++),c.include(a),c.include(f),c.include(u,g),c.include(m,g),E&&c.include(e,g),c.code.add(t`
    void outputColorHighlightOLID(vec4 finalColor, vec3 emissiveSymbolColor ${n(v,", float snow")}) {
      ${n(j,"finalColor.a = 1.0;")}
      ${n(L,"if (finalColor.a < alphaCutoff) discard;")}

      ${n(O,`float noise = ditherNoise(finalColor);\n         fragColor = ${n(b,"finalColor","premultiplyAlpha(finalColor)")};\n         fragColor.rgb = fragColor.rgb * floatBlendOutputScale + noise;\n         fragAlpha = finalColor.a * floatBlendOutputScale + noise;\n        `)}
      ${n($&&b,"finalColor.rgb /= finalColor.a;")}
      ${n(A,"fragColor = finalColor;")}
      ${n(h,E?"fragEmission = vec4(emissionDimming(premultiplyAlpha(finalColor).rgb, finalColor.a), 0.0);":`fragEmission = ${n(v,"mix(finalColor.a * getEmissions(emissiveSymbolColor), vec4(0.0), snow);","finalColor.a * getEmissions(emissiveSymbolColor);")}\n            float emissionNoise = ditherNoise(fragEmission);\n            fragEmission = vec4(fragEmission.rgb * floatBlendOutputScale + emissionNoise, fragEmission.a);`)}
      calculateOcclusionAndOutputHighlight();
      ${n(j,"outputObjectAndLayerIdColor();")}
    }
  `)}export{d as outputColorHighlightOLID};
