UNPKG

@arcgis/core

Version:

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

29 lines (28 loc) 2.27 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{ScreenSpacePass as e}from"../views/3d/webgl-engine/core/shaderLibrary/ScreenSpacePass.glsl.js";import{glsl as t}from"../views/3d/webgl-engine/core/shaderModules/glsl.js";import{Texture2DUintPassUniform as i}from"../views/3d/webgl-engine/core/shaderModules/Texture2DUintPassUniform.js";import{NoParameters as l}from"../views/webgl/NoParameters.js";import{ShaderBuilder as r}from"../views/webgl/ShaderBuilder.js";class o extends l{}function c(){const l=new r,{outputs:o,fragment:c}=l;return l.include(e),c.uniforms.add(new i("highlightTexture",e=>e.highlightTexture)),c.constants.add("outlineWidth","int",Math.ceil(n)),c.constants.add("cellSize","int",u),o.add("fragGrid","uvec2"),c.main.add(t`ivec2 inputTextureSize = textureSize(highlightTexture, 0); ivec2 cellBottomLeftCornerInput = ivec2(ivec2(floor(gl_FragCoord.xy) * vec2(cellSize))); ivec2 coordMid = cellBottomLeftCornerInput + ivec2(cellSize >> 1); uvec2 centreTexel = texelFetch(highlightTexture, coordMid, 0).rg & uvec2(0x55u); float marginSquare = float(outlineWidth*outlineWidth); uvec2 outputValue = centreTexel & uvec2(0x55u); for(int y = -outlineWidth; y <= cellSize + outlineWidth; y+=2) { int dy = y < 0 ? -y : y > cellSize ? y-cellSize : 0; int xMargin = dy > 0 ? int(ceil(sqrt(marginSquare - float(dy*dy)))) : outlineWidth; for(int x = -xMargin; x <= cellSize + xMargin; x+=2) { ivec2 coord = cellBottomLeftCornerInput + ivec2(x, y); uvec2[4] texels = uvec2[4] ( texelFetch(highlightTexture,coord+ivec2(0,0),0).rg & uvec2(0x55u), texelFetch(highlightTexture,coord+ivec2(1,0),0).rg & uvec2(0x55u), texelFetch(highlightTexture,coord+ivec2(0,1),0).rg & uvec2(0x55u), texelFetch(highlightTexture,coord+ivec2(1,1),0).rg & uvec2(0x55u) ); if (texels[0] == texels[1] && texels[1] == texels[2] && texels[2] == texels[3] && texels[3] == centreTexel) { continue; } for (int i=0; i<4; ++i){ outputValue |= ((texels[i] ^ centreTexel) << 1); outputValue |= texels[i]; } } } fragGrid = outputValue;`),l}const u=32,n=9,s=.4,a=Object.freeze(Object.defineProperty({__proto__:null,HighlightDownsampleDrawParameters:o,blurSize:s,build:c,gridCellPixelSize:u,outlineSize:n},Symbol.toStringTag,{value:"Module"}));export{o as H,a,s as b,c,u as g,n as o};