@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
21 lines (20 loc) • 1.99 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{set as e}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as l}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{glsl as i}from"../shaderModules/glsl.js";import{Integer2PassUniform as t}from"../shaderModules/Integer2PassUniform.js";import{IntegerPassUniform as o}from"../shaderModules/IntegerPassUniform.js";import{Texture2DUintPassUniform as n}from"../shaderModules/Texture2DUintPassUniform.js";import{g as c}from"../../../../../chunks/HighlightDownsample.glsl.js";function s(l){const{vertex:s}=l;s.uniforms.add(new n("coverageTexture",e=>e.coverageTexture),new t("highlightRenderCellCount",l=>e(r,l.horizontalCellCount,l.verticalCellCount)),new t("highlightTextureResolution",({highlightTexture:l})=>e(r,l.descriptor.width,l.descriptor.height)),new o("highlightLevel",e=>e.highlightLevel)).constants.add("cellSize","int",c),l.varyings.add("sUV","vec2"),l.varyings.add("vOutlinePossible","float"),s.code.add(i`const ivec2 cellVertices[4] = ivec2[4](ivec2(0,0), ivec2(1,0), ivec2(0,1), ivec2(1,1));`),s.main.add(i`int cellIndex = gl_InstanceID;
int cellX = cellIndex % highlightRenderCellCount[0];
int cellY = (cellIndex - cellX) / highlightRenderCellCount[0];
ivec2 cellPos = ivec2(cellX, cellY);
uvec2 covTexel = texelFetch(coverageTexture, cellPos, 0).rg;
int channelIndex = (highlightLevel >> 2) & 3;
uint channelValue = covTexel[channelIndex];
int highlightIndex = (highlightLevel & 3) << 1;
bool covered = ((channelValue >> highlightIndex) & 1u) == 1u;
if (!covered) {
gl_Position = vec4(0.0);
return;
}
vOutlinePossible = (((channelValue >> highlightIndex) & 2u) == 2u) ? 1.0 : 0.0;
ivec2 iPosInCell = cellVertices[gl_VertexID];
vec2 sPos = vec2(cellPos * cellSize + iPosInCell * (cellSize));
vec2 vPos = sPos / vec2(highlightTextureResolution);
sUV = vPos;
gl_Position = vec4(2.0 * vPos - vec2(1.0), 0.0, 1.0);`)}const r=l();export{s as HighlightCellGridScreenSpacePass};