UNPKG

@arcgis/core

Version:

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

10 lines (9 loc) 1.24 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{ShaderOutput as e}from"./ShaderOutput.js";import{VertexPosition as r}from"./attributes/VertexPosition.glsl.js";import{Float2BindUniform as a}from"../shaderModules/Float2BindUniform.js";import{glsl as o}from"../shaderModules/glsl.js";function i(e){e.varyings.add("linearDepth","float")}function t(e){e.vertex.uniforms.add(new a("nearFar",(e=>e.camera.nearFar)))}function d(e){e.vertex.code.add(o`float calculateLinearDepth(vec2 nearFar,float z) { return (-z - nearFar[0]) / (nearFar[1] - nearFar[0]); }`)}function n(a,n){const{vertex:s}=a;switch(n.output){case e.Color:case e.ColorEmission:if(n.receiveShadows)return i(a),void s.code.add(o`void forwardLinearDepth() { linearDepth = gl_Position.w; }`);break;case e.Shadow:case e.ShadowHighlight:case e.ShadowExcludeHighlight:case e.ViewshedShadow:return a.include(r,n),i(a),t(a),d(a),void s.code.add(o`void forwardLinearDepth() { linearDepth = calculateLinearDepth(nearFar, vPosition_view.z); }`)}s.code.add(o`void forwardLinearDepth() {}`)}export{n as ForwardLinearDepth,d as addCalculateLinearDepth,i as addLinearDepth,t as addNearFar};