/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{ScreenSpacePass as e}from"../views/3d/webgl-engine/core/shaderLibrary/ScreenSpacePass.glsl.js";import{emissionDimming as o}from"../views/3d/webgl-engine/core/shaderLibrary/util/EmissionDimming.glsl.js";import{If as s,glsl as r}from"../views/3d/webgl-engine/core/shaderModules/glsl.js";import{Texture2DPassUniform as i}from"../views/3d/webgl-engine/core/shaderModules/Texture2DPassUniform.js";import{NoParameters as t}from"../views/webgl/NoParameters.js";import{ShaderBuilder as a}from"../views/webgl/ShaderBuilder.js";class l extends t{}function n(t){const l=new a;l.include(e);const{hasEmission:n}=t,m=l.fragment;return n&&m.include(o,t),m.uniforms.add(new i("colorTexture",e=>e.color),new i("splatOutputColor",e=>e.splatColor)),n&&m.uniforms.add(new i("emissionTexture",e=>e.emission)),l.outputs.add("fragColor","vec4",0),n&&l.outputs.add("fragEmission","vec4",1),l.fragment.main.add(r`
      vec4 color = texture(colorTexture, uv);
      vec4 splatColor = texture(splatOutputColor, uv);

      fragColor = splatColor + color * (1.0 - splatColor.a);
      ${s(n,r`
          vec4 emission = texture(emissionTexture, uv);
          float srcAlpha = splatColor.a;

          if (srcAlpha == 0.0) {
            fragEmission = emission;
            return;
          }

          vec3 oitDimming = emissionDimming(splatColor.rgb, 1.0 - srcAlpha);
          float opaqueSuppression = smoothstep(0.95, 1.0, srcAlpha);
          vec3 dimming = mix(oitDimming, vec3(0.0), opaqueSuppression);

          fragEmission = vec4(emission.rgb * dimming, emission.a);
        `)}
    `),l}const m=Object.freeze(Object.defineProperty({__proto__:null,GaussianSplatCompositionPassParameters:l,build:n},Symbol.toStringTag,{value:"Module"}));export{l as G,m as S,n as b};
