UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

8 lines (7 loc) 1.09 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */ import{ReadDepth as e}from"../output/ReadDepth.glsl.js";import{If as r,glsl as t}from"../../shaderModules/glsl.js";import{Texture2DBindUniform as o}from"../../shaderModules/Texture2DBindUniform.js";function i(i,{occlusionPass:d,terrainDepthTest:a,cullAboveTerrain:n}){const{vertex:s,fragment:p,varyings:h}=i;if(!a)return s.code.add("void forwardViewPosDepth(vec3 pos) {}"),void p.code.add(`${d?"bool":"void"} discardByTerrainDepth() { ${r(d,"return false;")}}`);h.add("viewPosDepth","float",{invariant:!0}),s.code.add("void forwardViewPosDepth(vec3 pos) {\n viewPosDepth = pos.z;\n }"),p.include(e),p.uniforms.add(new o("terrainDepthTexture",e=>e.terrainDepth?.attachment)).code.add(t` ${d?"bool":"void"} discardByTerrainDepth() { float depth = texelFetch(terrainDepthTexture, ivec2(gl_FragCoord.xy), 0).r; float linearDepth = linearizeDepth(depth); ${d?"return viewPosDepth < linearDepth && depth < 1.0;":`if(viewPosDepth ${n?">":"<="} linearDepth) discard;`} }`)}export{i as terrainDepthTest};