/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{create as a}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ForwardLinearDepthToReadShadowMap as o}from"../ForwardLinearDepthToReadShadowMap.glsl.js";import{calculateUVZShadowPass as e,calculateUVZShadowDraw as r,ReadShadowMapOrigin as t}from"./calculateUVZShadow.glsl.js";import{ShadowmapFiltering as d}from"./ShadowmapFiltering.glsl.js";import{FloatBindUniform as i}from"../../shaderModules/FloatBindUniform.js";import{If as l,glsl as n}from"../../shaderModules/glsl.js";import{Texture2DShadowBindUniform as s}from"../../shaderModules/Texture2DShadowBindUniform.js";import{NoParameters as c}from"../../../../../webgl/NoParameters.js";class h extends t{}class m extends c{constructor(){super(...arguments),this.origin=a()}}function p(a,o){o.receiveShadows&&a.include(e),u(a,o)}function f(a,o){o.receiveShadows&&a.include(r),u(a,o)}function u(a,e){a.fragment.uniforms.add(new i("lightingGlobalFactor",a=>a.lighting.globalFactor));const{receiveShadows:r,spherical:t}=e;a.include(o,e),r&&w(a),a.fragment.code.add(n`
    float readShadow(float additionalAmbientScale, vec3 vpos) {
      return ${r?"max(lightingGlobalFactor * (1.0 - additionalAmbientScale), readShadowMap(vpos, linearDepth))":l(t,"lightingGlobalFactor * (1.0 - additionalAmbientScale)","0.0")};
    }
  `)}function w(a){a.include(d),a.fragment.uniforms.add(new s("shadowMap",({shadowMap:a})=>a.depthTexture)).code.add(n`float readShadowMap(const in vec3 _worldPos, float _linearDepth) {
vec3 uvzShadow = calculateUVZShadow(_worldPos, _linearDepth, textureSize(shadowMap,0));
if (uvzShadow.z < 0.0) {
return 0.0;
}
return readShadowMapUVZ(uvzShadow, shadowMap);
}`)}export{f as ReadShadowMapDraw,h as ReadShadowMapDrawParameters,p as ReadShadowMapPass,m as ReadShadowMapPassParameters};
