/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{AlignPixel as e}from"./AlignPixel.glsl.js";import{Float4BindUniform as r}from"../../shaderModules/Float4BindUniform.js";import{FloatBindUniform as o}from"../../shaderModules/FloatBindUniform.js";import{glsl as i}from"../../shaderModules/glsl.js";import{Texture2DBindUniform as l}from"../../shaderModules/Texture2DBindUniform.js";function n(n){n.vertex.uniforms.add(new o("renderTransparentlyOccludedHUD",e=>0===e.hudRenderStyle?1:1===e.hudRenderStyle?0:.75),new r("viewport",e=>e.camera.fullViewport),new l("hudVisibilityTexture",e=>e.hudVisibility?.getTexture())),n.vertex.include(e),n.vertex.code.add(i`bool testHUDVisibility(vec4 posProj) {
vec4 posProjCenter = alignToPixelCenter(posProj, viewport.zw);
vec4 occlusionPixel = texture(hudVisibilityTexture, .5 + .5 * posProjCenter.xy / posProjCenter.w);
if (renderTransparentlyOccludedHUD > 0.5) {
return occlusionPixel.r * occlusionPixel.g > 0.0 && occlusionPixel.g * renderTransparentlyOccludedHUD < 1.0;
}
return occlusionPixel.r * occlusionPixel.g > 0.0 && occlusionPixel.g == 1.0;
}`)}export{n as HUDVisibility};
