/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{ScreenSpacePass as e}from"../views/3d/webgl-engine/core/shaderLibrary/ScreenSpacePass.glsl.js";import{ReadDepth as r}from"../views/3d/webgl-engine/core/shaderLibrary/output/ReadDepth.glsl.js";import{glsl as t,If as o}from"../views/3d/webgl-engine/core/shaderModules/glsl.js";import{Texture2DPassUniform as a}from"../views/3d/webgl-engine/core/shaderModules/Texture2DPassUniform.js";import{NoParameters as l}from"../views/webgl/NoParameters.js";import{ShaderBuilder as n}from"../views/webgl/ShaderBuilder.js";class s extends l{}function d(l){const{preparePass:s}=l,d=new n;return d.include(e),d.fragment.include(r),d.fragment.uniforms.add(new a("cutFillReferenceDepthTexture",e=>e.referenceDepthTexture),new a("cutFillTargetDepthTexture",e=>e.targetDepthTexture)),d.fragment.code.add(t`bool outsideFar(float depth) {
return depth >= 1.0;
}`),d.fragment.main.add(t`
    float referenceDepth = depthFromTexture(cutFillReferenceDepthTexture, uv);
    float targetDepth = depthFromTexture(cutFillTargetDepthTexture, uv);

    if (outsideFar(targetDepth)) {
      discard;
    }

    ${o(0===s,"\n        float depth = referenceDepth - targetDepth;\n        fragColor = vec4(min(0.0, depth), max(0.0, depth), 0.0, 0.0);\n    ")}

    ${o(1===s,"\n        ivec2 texSize = textureSize(cutFillReferenceDepthTexture, 0);\n        ivec2 coords = ivec2(gl_FragCoord.xy);\n        float packedCoords = float(coords.x) + float(coords.y) * float(texSize.x);\n\n        fragColor = vec4(referenceDepth, packedCoords, 0.0, 0.0);\n    ")}
  `),d}const i=Object.freeze(Object.defineProperty({__proto__:null,CutFillDepthParameters:s,build:d},Symbol.toStringTag,{value:"Module"}));export{s as C,i as a,d as b};
