UNPKG

@arcgis/core

Version:

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

11 lines (10 loc) 1.16 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ 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 d(d,{occlusionPass:i,terrainDepthTest:a,cullAboveTerrain:s}){const n=d.vertex,p=d.fragment;if(!a)return n.code.add("void forwardViewPosDepth(vec3 pos) {}"),void p.code.add(`${i?"bool":"void"} discardByTerrainDepth() { ${r(i,"return false;")}}`);d.varyings.add("viewPosDepth","float"),n.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` ${i?"bool":"void"} discardByTerrainDepth() { float depth = texelFetch(terrainDepthTexture, ivec2(gl_FragCoord.xy), 0).r; float linearDepth = linearizeDepth(depth); ${i?"return viewPosDepth < linearDepth && depth < 1.0;":`if(viewPosDepth ${s?">":"<="} linearDepth) discard;`} }`)}export{d as terrainDepthTest};