UNPKG

@deck.gl/experimental-layers

Version:

Experimental layers for deck.gl

29 lines (28 loc) 3.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; // Copyright (c) 2015 - 2017 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // Inspired by screen-grid-layer vertex shader in deck.gl var _default = "#version 300 es\n#define SHADER_NAME gpu-grid-cell-layer-vertex-shader\n\nin vec3 positions;\nin vec3 normals;\n\nin vec4 instanceCounts;\nuniform float extruded;\nuniform float cellSize;\nuniform float coverage;\nuniform float opacity;\nuniform float elevationScale;\n\nuniform vec2 gridSize;\nuniform vec2 gridOrigin;\nuniform vec2 gridOriginLow;\nuniform vec2 gridOffset;\nuniform vec2 gridOffsetLow;\nuniform vec4 minColor;\nuniform vec4 maxColor;\nlayout(std140) uniform;\nuniform AggregationData\n{\n vec4 maxCount;\n} aggregationData;\n\n#define ELEVATION_SCALE 100.\nout vec4 vColor;\n\nvoid main(void) {\n\n bool noRender = instanceCounts.r <= 0.0;\n\n float step = instanceCounts.r / aggregationData.maxCount.r;\n vec4 color = mix(minColor, maxColor, step) / 255.;\n float finalCellSize = noRender ? 0.0 : project_scale(cellSize);\n\n\n float elevation = 0.0;\n\n if (extruded > 0.5) {\n elevation = instanceCounts.r * (positions.z + 1.0) *\n ELEVATION_SCALE * elevationScale;\n }\n\n float yIndex = floor(float(gl_InstanceID) / gridSize[0]);\n float xIndex = float(gl_InstanceID) - (yIndex * gridSize[0]);\n\n vec2 instancePositionXFP64 = mul_fp64(vec2(gridOffset[0], gridOffsetLow[0]), vec2(xIndex, 0.));\n instancePositionXFP64 = sum_fp64(instancePositionXFP64, vec2(gridOrigin[0], gridOriginLow[0]));\n vec2 instancePositionYFP64 = mul_fp64(vec2(gridOffset[1], gridOffsetLow[1]), vec2(yIndex, 0.));\n instancePositionYFP64 = sum_fp64(instancePositionYFP64, vec2(gridOrigin[1], gridOriginLow[1]));\n vec3 extrudedPosition = vec3(instancePositionXFP64[0], instancePositionYFP64[0], elevation);\n vec2 extrudedPosition64xyLow = vec2(instancePositionXFP64[1], instancePositionYFP64[1]);\n\n vec3 offset = vec3(\n (positions.x * coverage + 1.0) / 2.0 * finalCellSize,\n (positions.y * coverage - 1.0) / 2.0 * finalCellSize,\n 1.0);\n vec4 position_worldspace;\n gl_Position = project_position_to_clipspace(extrudedPosition, extrudedPosition64xyLow, offset, position_worldspace);\n\n float lightWeight = 1.0;\n\n if (extruded > 0.5) {\n lightWeight = lighting_getLightWeight(\n position_worldspace.xyz,\n normals\n );\n }\n\n vec3 lightWeightedColor = lightWeight * color.rgb;\n vColor = vec4(lightWeightedColor, color.a * opacity);\n}\n"; exports.default = _default; //# sourceMappingURL=gpu-grid-cell-layer-vertex.glsl.js.map