/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{ForwardLinearDepth as r}from"./ForwardLinearDepth.glsl.js";import{isShadowLike as e}from"./ShaderOutput.js";import{VertexPosition as a}from"./attributes/VertexPosition.glsl.js";import{Float2BindUniform as o}from"../shaderModules/Float2BindUniform.js";import{glsl as t,If as n}from"../shaderModules/glsl.js";function i(r){r.vertex.uniforms.add(new o("nearFar",r=>r.camera.nearFar))}function d(r){r.vertex.code.add(t`float calculateLinearDepth(vec2 nearFar,float z) {
return (-z - nearFar[0]) / (nearFar[1] - nearFar[0]);
}`)}function s(o,s){const{vertex:l}=o,u=e(s.output);u&&(o.include(a,s),r(o,!0),i(o),d(o)),l.code.add(t`
    void forwardLinearDepthToWriteShadowMap() {
      ${n(u,"forwardLinearDepth(calculateLinearDepth(nearFar, vPosition_view.z));")}
    }
  `)}export{s as ForwardLinearDepthToWriteShadowMap,d as addCalculateLinearDepth,i as addNearFar};
