@deck.gl/aggregation-layers 9.4.0-alpha.1 → 9.4.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts.map +1 -1
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js +1 -3
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js.map +1 -1
- package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js +0 -1
- package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js.map +1 -1
- package/dist/dist.dev.js +642 -38
- package/dist/grid-layer/grid-cell-layer.d.ts.map +1 -1
- package/dist/grid-layer/grid-cell-layer.js +3 -2
- package/dist/grid-layer/grid-cell-layer.js.map +1 -1
- package/dist/grid-layer/grid-cell-layer.wgsl.d.ts +3 -0
- package/dist/grid-layer/grid-cell-layer.wgsl.d.ts.map +1 -0
- package/dist/grid-layer/grid-cell-layer.wgsl.js +114 -0
- package/dist/grid-layer/grid-cell-layer.wgsl.js.map +1 -0
- package/dist/grid-layer/grid-layer-uniforms.d.ts +1 -0
- package/dist/grid-layer/grid-layer-uniforms.d.ts.map +1 -1
- package/dist/grid-layer/grid-layer-uniforms.js +14 -0
- package/dist/grid-layer/grid-layer-uniforms.js.map +1 -1
- package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts +2 -0
- package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts.map +1 -1
- package/dist/heatmap-layer/heatmap-layer-uniforms.js +19 -0
- package/dist/heatmap-layer/heatmap-layer-uniforms.js.map +1 -1
- package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -1
- package/dist/heatmap-layer/heatmap-layer.js +59 -12
- package/dist/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/heatmap-layer/max.wgsl.d.ts +3 -0
- package/dist/heatmap-layer/max.wgsl.d.ts.map +1 -0
- package/dist/heatmap-layer/max.wgsl.js +48 -0
- package/dist/heatmap-layer/max.wgsl.js.map +1 -0
- package/dist/heatmap-layer/triangle-layer-uniforms.d.ts +1 -0
- package/dist/heatmap-layer/triangle-layer-uniforms.d.ts.map +1 -1
- package/dist/heatmap-layer/triangle-layer-uniforms.js +16 -0
- package/dist/heatmap-layer/triangle-layer-uniforms.js.map +1 -1
- package/dist/heatmap-layer/triangle-layer.d.ts.map +1 -1
- package/dist/heatmap-layer/triangle-layer.js +3 -2
- package/dist/heatmap-layer/triangle-layer.js.map +1 -1
- package/dist/heatmap-layer/triangle-layer.wgsl.d.ts +3 -0
- package/dist/heatmap-layer/triangle-layer.wgsl.d.ts.map +1 -0
- package/dist/heatmap-layer/triangle-layer.wgsl.js +65 -0
- package/dist/heatmap-layer/triangle-layer.wgsl.js.map +1 -0
- package/dist/heatmap-layer/weights.wgsl.d.ts +3 -0
- package/dist/heatmap-layer/weights.wgsl.d.ts.map +1 -0
- package/dist/heatmap-layer/weights.wgsl.js +64 -0
- package/dist/heatmap-layer/weights.wgsl.js.map +1 -0
- package/dist/hexagon-layer/hexagon-cell-layer.d.ts.map +1 -1
- package/dist/hexagon-layer/hexagon-cell-layer.js +2 -2
- package/dist/hexagon-layer/hexagon-cell-layer.js.map +1 -1
- package/dist/hexagon-layer/hexagon-cell-layer.wgsl.d.ts +3 -0
- package/dist/hexagon-layer/hexagon-cell-layer.wgsl.d.ts.map +1 -0
- package/dist/hexagon-layer/hexagon-cell-layer.wgsl.js +120 -0
- package/dist/hexagon-layer/hexagon-cell-layer.wgsl.js.map +1 -0
- package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts +1 -0
- package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts.map +1 -1
- package/dist/hexagon-layer/hexagon-layer-uniforms.js +13 -0
- package/dist/hexagon-layer/hexagon-layer-uniforms.js.map +1 -1
- package/dist/index.cjs +13268 -1488
- package/dist/index.cjs.map +3 -4
- package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts +1 -6
- package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
- package/dist/screen-grid-layer/screen-grid-cell-layer.js +3 -2
- package/dist/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
- package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.d.ts +3 -0
- package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.d.ts.map +1 -0
- package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.js +76 -0
- package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.js.map +1 -0
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts +1 -0
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts.map +1 -1
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.js +12 -0
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.js.map +1 -1
- package/dist.min.js +545 -35
- package/dist.webgl-only/common/aggregation-layer.js +68 -0
- package/dist.webgl-only/common/aggregation-layer.js.map +1 -0
- package/dist.webgl-only/common/aggregator/aggregator.js +5 -0
- package/dist.webgl-only/common/aggregator/aggregator.js.map +1 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/aggregate.js +69 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/aggregate.js.map +1 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/cpu-aggregator.js +141 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/cpu-aggregator.js.map +1 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/sort-bins.js +44 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/sort-bins.js.map +1 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/vertex-accessor.js +56 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/vertex-accessor.js.map +1 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.js +22 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.js.map +1 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/bin-sorter-uniforms.js +18 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/bin-sorter-uniforms.js.map +1 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/utils.js +24 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/utils.js.map +1 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js +222 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js.map +1 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/webgl-aggregator.js +203 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/webgl-aggregator.js.map +1 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/webgl-bin-sorter.js +225 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/webgl-bin-sorter.js.map +1 -0
- package/dist.webgl-only/common/aggregator/index.js +6 -0
- package/dist.webgl-only/common/aggregator/index.js.map +1 -0
- package/dist.webgl-only/common/types.js +5 -0
- package/dist.webgl-only/common/types.js.map +1 -0
- package/dist.webgl-only/common/utils/bounds-utils.js +21 -0
- package/dist.webgl-only/common/utils/bounds-utils.js.map +1 -0
- package/dist.webgl-only/common/utils/color-utils.js +65 -0
- package/dist.webgl-only/common/utils/color-utils.js.map +1 -0
- package/dist.webgl-only/common/utils/prop-utils.js +13 -0
- package/dist.webgl-only/common/utils/prop-utils.js.map +1 -0
- package/dist.webgl-only/common/utils/scale-utils.js +181 -0
- package/dist.webgl-only/common/utils/scale-utils.js.map +1 -0
- package/dist.webgl-only/contour-layer/bin-options-uniforms.js +18 -0
- package/dist.webgl-only/contour-layer/bin-options-uniforms.js.map +1 -0
- package/dist.webgl-only/contour-layer/contour-layer.js +282 -0
- package/dist.webgl-only/contour-layer/contour-layer.js.map +1 -0
- package/dist.webgl-only/contour-layer/contour-utils.js +60 -0
- package/dist.webgl-only/contour-layer/contour-utils.js.map +1 -0
- package/dist.webgl-only/contour-layer/marching-squares-codes.js +341 -0
- package/dist.webgl-only/contour-layer/marching-squares-codes.js.map +1 -0
- package/dist.webgl-only/contour-layer/marching-squares.js +151 -0
- package/dist.webgl-only/contour-layer/marching-squares.js.map +1 -0
- package/dist.webgl-only/contour-layer/value-reader.js +47 -0
- package/dist.webgl-only/contour-layer/value-reader.js.map +1 -0
- package/dist.webgl-only/grid-layer/bin-options-uniforms.js +18 -0
- package/dist.webgl-only/grid-layer/bin-options-uniforms.js.map +1 -0
- package/dist.webgl-only/grid-layer/grid-cell-layer-vertex.glsl.js +51 -0
- package/dist.webgl-only/grid-layer/grid-cell-layer-vertex.glsl.js.map +1 -0
- package/dist.webgl-only/grid-layer/grid-cell-layer.js +95 -0
- package/dist.webgl-only/grid-layer/grid-cell-layer.js.map +1 -0
- package/dist.webgl-only/grid-layer/grid-cell-layer.wgsl.js +5 -0
- package/dist.webgl-only/grid-layer/grid-cell-layer.wgsl.js.map +1 -0
- package/dist.webgl-only/grid-layer/grid-layer-uniforms.js +26 -0
- package/dist.webgl-only/grid-layer/grid-layer-uniforms.js.map +1 -0
- package/dist.webgl-only/grid-layer/grid-layer.js +362 -0
- package/dist.webgl-only/grid-layer/grid-layer.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/aggregation-layer.js +140 -0
- package/dist.webgl-only/heatmap-layer/aggregation-layer.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/heatmap-layer-uniforms.js +36 -0
- package/dist.webgl-only/heatmap-layer/heatmap-layer-uniforms.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/heatmap-layer-utils.js +67 -0
- package/dist.webgl-only/heatmap-layer/heatmap-layer-utils.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/heatmap-layer.js +513 -0
- package/dist.webgl-only/heatmap-layer/heatmap-layer.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/max-fs.glsl.js +13 -0
- package/dist.webgl-only/heatmap-layer/max-fs.glsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/max-vs.glsl.js +18 -0
- package/dist.webgl-only/heatmap-layer/max-vs.glsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/max.wgsl.js +5 -0
- package/dist.webgl-only/heatmap-layer/max.wgsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer-fragment.glsl.js +34 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer-fragment.glsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer-uniforms.js +25 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer-uniforms.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer-vertex.glsl.js +28 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer-vertex.glsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer.js +49 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer.wgsl.js +5 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer.wgsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/weights-fs.glsl.js +21 -0
- package/dist.webgl-only/heatmap-layer/weights-fs.glsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/weights-vs.glsl.js +21 -0
- package/dist.webgl-only/heatmap-layer/weights-vs.glsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/weights.wgsl.js +5 -0
- package/dist.webgl-only/heatmap-layer/weights.wgsl.js.map +1 -0
- package/dist.webgl-only/hexagon-layer/bin-options-uniforms.js +18 -0
- package/dist.webgl-only/hexagon-layer/bin-options-uniforms.js.map +1 -0
- package/dist.webgl-only/hexagon-layer/hexagon-cell-layer-vertex.glsl.js +55 -0
- package/dist.webgl-only/hexagon-layer/hexagon-cell-layer-vertex.glsl.js.map +1 -0
- package/dist.webgl-only/hexagon-layer/hexagon-cell-layer.js +90 -0
- package/dist.webgl-only/hexagon-layer/hexagon-cell-layer.js.map +1 -0
- package/dist.webgl-only/hexagon-layer/hexagon-cell-layer.wgsl.js +5 -0
- package/dist.webgl-only/hexagon-layer/hexagon-cell-layer.wgsl.js.map +1 -0
- package/dist.webgl-only/hexagon-layer/hexagon-layer-uniforms.js +24 -0
- package/dist.webgl-only/hexagon-layer/hexagon-layer-uniforms.js.map +1 -0
- package/dist.webgl-only/hexagon-layer/hexagon-layer.js +360 -0
- package/dist.webgl-only/hexagon-layer/hexagon-layer.js.map +1 -0
- package/dist.webgl-only/hexagon-layer/hexbin.js +70 -0
- package/dist.webgl-only/hexagon-layer/hexbin.js.map +1 -0
- package/dist.webgl-only/index.cjs +15625 -0
- package/dist.webgl-only/index.cjs.map +6 -0
- package/dist.webgl-only/index.js +11 -0
- package/dist.webgl-only/index.js.map +1 -0
- package/dist.webgl-only/screen-grid-layer/bin-options-uniforms.js +16 -0
- package/dist.webgl-only/screen-grid-layer/bin-options-uniforms.js.map +1 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-cell-layer.js +88 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-cell-layer.js.map +1 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-cell-layer.wgsl.js +5 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-cell-layer.wgsl.js.map +1 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer-fragment.glsl.js +16 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +1 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer-uniforms.js +22 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer-uniforms.js.map +1 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer-vertex.glsl.js +31 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +1 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer.js +194 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer.js.map +1 -0
- package/package.json +14 -5
- package/src/common/aggregator/gpu-aggregator/webgl-aggregation-transform.ts +1 -3
- package/src/common/aggregator/gpu-aggregator/webgl-bin-sorter.ts +0 -1
- package/src/grid-layer/grid-cell-layer.ts +3 -2
- package/src/grid-layer/grid-cell-layer.wgsl.ts +114 -0
- package/src/grid-layer/grid-layer-uniforms.ts +15 -0
- package/src/heatmap-layer/heatmap-layer-uniforms.ts +20 -0
- package/src/heatmap-layer/heatmap-layer.ts +67 -13
- package/src/heatmap-layer/max.wgsl.ts +48 -0
- package/src/heatmap-layer/triangle-layer-uniforms.ts +17 -0
- package/src/heatmap-layer/triangle-layer.ts +3 -2
- package/src/heatmap-layer/triangle-layer.wgsl.ts +65 -0
- package/src/heatmap-layer/weights.wgsl.ts +64 -0
- package/src/hexagon-layer/hexagon-cell-layer.ts +2 -3
- package/src/hexagon-layer/hexagon-cell-layer.wgsl.ts +120 -0
- package/src/hexagon-layer/hexagon-layer-uniforms.ts +14 -0
- package/src/screen-grid-layer/screen-grid-cell-layer.ts +4 -4
- package/src/screen-grid-layer/screen-grid-cell-layer.wgsl.ts +76 -0
- package/src/screen-grid-layer/screen-grid-layer-uniforms.ts +13 -0
|
@@ -5,6 +5,20 @@
|
|
|
5
5
|
import {Texture} from '@luma.gl/core';
|
|
6
6
|
import type {ShaderModule} from '@luma.gl/shadertools';
|
|
7
7
|
|
|
8
|
+
const uniformBlockWGSL = /* wgsl */ `\
|
|
9
|
+
struct gridUniforms {
|
|
10
|
+
colorDomain: vec4<f32>,
|
|
11
|
+
elevationDomain: vec4<f32>,
|
|
12
|
+
elevationRange: vec2<f32>,
|
|
13
|
+
originCommon: vec2<f32>,
|
|
14
|
+
sizeCommon: vec2<f32>,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
@group(0) @binding(auto) var<uniform> grid: gridUniforms;
|
|
18
|
+
@group(0) @binding(auto) var colorRange: texture_2d<f32>;
|
|
19
|
+
@group(0) @binding(auto) var colorRangeSampler: sampler;
|
|
20
|
+
`;
|
|
21
|
+
|
|
8
22
|
const uniformBlock = /* glsl */ `\
|
|
9
23
|
layout(std140) uniform gridUniforms {
|
|
10
24
|
vec4 colorDomain;
|
|
@@ -26,6 +40,7 @@ export type GridProps = {
|
|
|
26
40
|
|
|
27
41
|
export const gridUniforms = {
|
|
28
42
|
name: 'grid',
|
|
43
|
+
source: uniformBlockWGSL,
|
|
29
44
|
vs: uniformBlock,
|
|
30
45
|
uniformTypes: {
|
|
31
46
|
colorDomain: 'vec4<f32>',
|
|
@@ -5,6 +5,17 @@
|
|
|
5
5
|
import {Texture} from '@luma.gl/core';
|
|
6
6
|
import type {ShaderModule} from '@luma.gl/shadertools';
|
|
7
7
|
|
|
8
|
+
const uniformBlockWGSL = /* wgsl */ `\
|
|
9
|
+
struct weightUniforms {
|
|
10
|
+
commonBounds: vec4<f32>,
|
|
11
|
+
radiusPixels: f32,
|
|
12
|
+
textureWidth: f32,
|
|
13
|
+
weightsScale: f32,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
@group(0) @binding(auto) var<uniform> weight: weightUniforms;
|
|
17
|
+
`;
|
|
18
|
+
|
|
8
19
|
const uniformBlock = `\
|
|
9
20
|
layout(std140) uniform weightUniforms {
|
|
10
21
|
vec4 commonBounds;
|
|
@@ -23,6 +34,7 @@ export type WeightProps = {
|
|
|
23
34
|
|
|
24
35
|
export const weightUniforms = {
|
|
25
36
|
name: 'weight',
|
|
37
|
+
source: uniformBlockWGSL,
|
|
26
38
|
vs: uniformBlock,
|
|
27
39
|
uniformTypes: {
|
|
28
40
|
commonBounds: 'vec4<f32>',
|
|
@@ -39,6 +51,14 @@ export type MaxWeightProps = {
|
|
|
39
51
|
|
|
40
52
|
export const maxWeightUniforms = {
|
|
41
53
|
name: 'maxWeight',
|
|
54
|
+
source: /* wgsl */ `\
|
|
55
|
+
struct maxWeightUniforms {
|
|
56
|
+
textureSize: f32,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
@group(0) @binding(auto) var<uniform> maxWeight: maxWeightUniforms;
|
|
60
|
+
@group(0) @binding(auto) var inTexture: texture_2d<f32>;
|
|
61
|
+
`,
|
|
42
62
|
vs: `\
|
|
43
63
|
layout(std140) uniform maxWeightUniforms {
|
|
44
64
|
float textureSize;
|
|
@@ -10,7 +10,14 @@ import {
|
|
|
10
10
|
scaleToAspectRatio,
|
|
11
11
|
getTextureCoordinates
|
|
12
12
|
} from './heatmap-layer-utils';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
Buffer,
|
|
15
|
+
DeviceFeature,
|
|
16
|
+
Texture,
|
|
17
|
+
TextureProps,
|
|
18
|
+
TextureFormat,
|
|
19
|
+
TextureFormatColor
|
|
20
|
+
} from '@luma.gl/core';
|
|
14
21
|
import {TextureTransform, TextureTransformProps} from '@luma.gl/engine';
|
|
15
22
|
import {
|
|
16
23
|
Accessor,
|
|
@@ -34,6 +41,8 @@ import weightsVs from './weights-vs.glsl';
|
|
|
34
41
|
import weightsFs from './weights-fs.glsl';
|
|
35
42
|
import maxVs from './max-vs.glsl';
|
|
36
43
|
import maxFs from './max-fs.glsl';
|
|
44
|
+
import maxSource from './max.wgsl';
|
|
45
|
+
import weightsSource from './weights.wgsl';
|
|
37
46
|
import {
|
|
38
47
|
MaxWeightProps,
|
|
39
48
|
maxWeightUniforms,
|
|
@@ -42,6 +51,7 @@ import {
|
|
|
42
51
|
} from './heatmap-layer-uniforms';
|
|
43
52
|
|
|
44
53
|
const RESOLUTION = 2; // (number of common space pixels) / (number texels)
|
|
54
|
+
const MAX_WEIGHT_REDUCTION_SIZE = 16;
|
|
45
55
|
const TEXTURE_PROPS: TextureProps = {
|
|
46
56
|
format: 'rgba8unorm',
|
|
47
57
|
dimension: '2d',
|
|
@@ -376,11 +386,26 @@ export default class HeatmapLayer<
|
|
|
376
386
|
|
|
377
387
|
_setupAttributes() {
|
|
378
388
|
const attributeManager = this.getAttributeManager()!;
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
389
|
+
|
|
390
|
+
if (this.context.device.type === 'webgpu') {
|
|
391
|
+
attributeManager.addInstanced({
|
|
392
|
+
instancePositions: {
|
|
393
|
+
size: 3,
|
|
394
|
+
type: 'float64',
|
|
395
|
+
accessor: 'getPosition',
|
|
396
|
+
// Normalize binary XY positions into the packed XYZ high/low layout WebGPU requires.
|
|
397
|
+
transform: (position: Position) => [position[0], position[1], position[2] ?? 0]
|
|
398
|
+
},
|
|
399
|
+
instanceWeights: {size: 1, accessor: 'getWeight'}
|
|
400
|
+
});
|
|
401
|
+
this.setState({positionAttributeName: 'instancePositions'});
|
|
402
|
+
} else {
|
|
403
|
+
attributeManager.add({
|
|
404
|
+
positions: {size: 3, type: 'float64', accessor: 'getPosition'},
|
|
405
|
+
weights: {size: 1, accessor: 'getWeight'}
|
|
406
|
+
});
|
|
407
|
+
this.setState({positionAttributeName: 'positions'});
|
|
408
|
+
}
|
|
384
409
|
}
|
|
385
410
|
|
|
386
411
|
_setupTextureParams() {
|
|
@@ -388,8 +413,15 @@ export default class HeatmapLayer<
|
|
|
388
413
|
const {weightsTextureSize} = this.props;
|
|
389
414
|
|
|
390
415
|
const textureSize = Math.min(weightsTextureSize, device.limits.maxTextureDimension2D);
|
|
391
|
-
const
|
|
392
|
-
const
|
|
416
|
+
const isWebGPU = device.type === 'webgpu';
|
|
417
|
+
const floatTargetSupport = isWebGPU
|
|
418
|
+
? device.getTextureFormatCapabilities('rgba16float').blend
|
|
419
|
+
: FLOAT_TARGET_FEATURES.every(feature => device.features.has(feature));
|
|
420
|
+
const format: TextureFormat = floatTargetSupport
|
|
421
|
+
? isWebGPU
|
|
422
|
+
? 'rgba16float'
|
|
423
|
+
: 'rgba32float'
|
|
424
|
+
: 'rgba8unorm';
|
|
393
425
|
const weightsScale = floatTargetSupport ? 1 : 1 / 255;
|
|
394
426
|
this.setState({textureSize, format, weightsScale});
|
|
395
427
|
if (!floatTargetSupport) {
|
|
@@ -402,14 +434,23 @@ export default class HeatmapLayer<
|
|
|
402
434
|
_createWeightsTransform(shaders: {vs: string; fs?: string; modules: any[]}) {
|
|
403
435
|
let {weightsTransform} = this.state;
|
|
404
436
|
const {weightsTexture} = this.state;
|
|
437
|
+
const isWebGPU = this.context.device.type === 'webgpu';
|
|
405
438
|
const attributeManager = this.getAttributeManager()!;
|
|
406
439
|
|
|
407
440
|
weightsTransform?.destroy();
|
|
408
441
|
weightsTransform = new TextureTransform(this.context.device, {
|
|
409
442
|
id: `${this.id}-weights-transform`,
|
|
410
443
|
...shaders,
|
|
411
|
-
|
|
412
|
-
|
|
444
|
+
source: weightsSource,
|
|
445
|
+
bufferLayout: attributeManager.getBufferLayouts({isInstanced: isWebGPU}),
|
|
446
|
+
vertexCount: isWebGPU ? 6 : 1,
|
|
447
|
+
...(isWebGPU
|
|
448
|
+
? {
|
|
449
|
+
colorAttachmentFormats: [weightsTexture!.format as TextureFormatColor],
|
|
450
|
+
isInstanced: true,
|
|
451
|
+
instanceCount: this.getNumInstances()
|
|
452
|
+
}
|
|
453
|
+
: {}),
|
|
413
454
|
targetTexture: weightsTexture!,
|
|
414
455
|
parameters: {
|
|
415
456
|
depthWriteEnabled: false,
|
|
@@ -420,7 +461,7 @@ export default class HeatmapLayer<
|
|
|
420
461
|
blendAlphaSrcFactor: 'one',
|
|
421
462
|
blendAlphaDstFactor: 'one'
|
|
422
463
|
},
|
|
423
|
-
topology: 'point-list',
|
|
464
|
+
topology: isWebGPU ? 'triangle-list' : 'point-list',
|
|
424
465
|
modules: [...shaders.modules, weightUniforms]
|
|
425
466
|
} as TextureTransformProps);
|
|
426
467
|
|
|
@@ -439,6 +480,7 @@ export default class HeatmapLayer<
|
|
|
439
480
|
this._createWeightsTransform(weightsTransformShaders);
|
|
440
481
|
|
|
441
482
|
const maxWeightsTransformShaders = this.getShaders({
|
|
483
|
+
source: maxSource,
|
|
442
484
|
vs: maxVs,
|
|
443
485
|
fs: maxFs,
|
|
444
486
|
modules: [maxWeightUniforms]
|
|
@@ -447,7 +489,13 @@ export default class HeatmapLayer<
|
|
|
447
489
|
id: `${this.id}-max-weights-transform`,
|
|
448
490
|
targetTexture: maxWeightsTexture!,
|
|
449
491
|
...maxWeightsTransformShaders,
|
|
450
|
-
|
|
492
|
+
...(device.type === 'webgpu'
|
|
493
|
+
? {colorAttachmentFormats: [maxWeightsTexture!.format as TextureFormatColor]}
|
|
494
|
+
: {}),
|
|
495
|
+
vertexCount:
|
|
496
|
+
device.type === 'webgpu'
|
|
497
|
+
? Math.ceil(textureSize / MAX_WEIGHT_REDUCTION_SIZE) ** 2
|
|
498
|
+
: textureSize * textureSize,
|
|
451
499
|
topology: 'point-list',
|
|
452
500
|
parameters: {
|
|
453
501
|
depthWriteEnabled: false,
|
|
@@ -605,7 +653,13 @@ export default class HeatmapLayer<
|
|
|
605
653
|
const attributes = attributeManager.getAttributes();
|
|
606
654
|
const moduleSettings = this.getModuleSettings();
|
|
607
655
|
this._setModelAttributes(weightsTransform.model, attributes);
|
|
608
|
-
|
|
656
|
+
if (this.context.device.type === 'webgpu') {
|
|
657
|
+
const instanceCount = this.getNumInstances();
|
|
658
|
+
weightsTransform.model.setVertexCount(instanceCount > 0 ? 6 : 0);
|
|
659
|
+
weightsTransform.model.setInstanceCount(instanceCount);
|
|
660
|
+
} else {
|
|
661
|
+
weightsTransform.model.setVertexCount(this.getNumInstances());
|
|
662
|
+
}
|
|
609
663
|
|
|
610
664
|
const weightProps: WeightProps = {
|
|
611
665
|
radiusPixels,
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
export default /* wgsl */ `\
|
|
6
|
+
struct MaxWeightVaryings {
|
|
7
|
+
@builtin(position) position: vec4<f32>,
|
|
8
|
+
@location(0) weights: vec4<f32>,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const MAX_WEIGHT_REDUCTION_SIZE: u32 = 16u;
|
|
12
|
+
|
|
13
|
+
@vertex
|
|
14
|
+
fn vertexMain(@builtin(vertex_index) vertexIndex: u32) -> MaxWeightVaryings {
|
|
15
|
+
var output: MaxWeightVaryings;
|
|
16
|
+
let textureSize = u32(maxWeight.textureSize);
|
|
17
|
+
let reducedTextureSize =
|
|
18
|
+
(textureSize + MAX_WEIGHT_REDUCTION_SIZE - 1u) / MAX_WEIGHT_REDUCTION_SIZE;
|
|
19
|
+
let blockCoordinates = vec2<u32>(
|
|
20
|
+
vertexIndex % reducedTextureSize,
|
|
21
|
+
vertexIndex / reducedTextureSize
|
|
22
|
+
);
|
|
23
|
+
var maximumWeights = vec4<f32>(0.0);
|
|
24
|
+
|
|
25
|
+
for (var y = 0u; y < MAX_WEIGHT_REDUCTION_SIZE; y++) {
|
|
26
|
+
for (var x = 0u; x < MAX_WEIGHT_REDUCTION_SIZE; x++) {
|
|
27
|
+
let textureCoordinates = blockCoordinates * MAX_WEIGHT_REDUCTION_SIZE + vec2<u32>(x, y);
|
|
28
|
+
|
|
29
|
+
if (textureCoordinates.x < textureSize && textureCoordinates.y < textureSize) {
|
|
30
|
+
let weights = textureLoad(inTexture, vec2<i32>(textureCoordinates), 0);
|
|
31
|
+
maximumWeights.r = max(maximumWeights.r, weights.r);
|
|
32
|
+
maximumWeights.g = max(maximumWeights.g, weights.r / max(1.0, weights.a));
|
|
33
|
+
maximumWeights.b = max(maximumWeights.b, weights.b);
|
|
34
|
+
maximumWeights.a = max(maximumWeights.a, weights.a);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
|
40
|
+
output.weights = maximumWeights;
|
|
41
|
+
return output;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@fragment
|
|
45
|
+
fn fragmentMain(varyings: MaxWeightVaryings) -> @location(0) vec4<f32> {
|
|
46
|
+
return varyings.weights;
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
@@ -5,6 +5,22 @@
|
|
|
5
5
|
import {Texture} from '@luma.gl/core';
|
|
6
6
|
import type {ShaderModule} from '@luma.gl/shadertools';
|
|
7
7
|
|
|
8
|
+
const uniformBlockWGSL = /* wgsl */ `\
|
|
9
|
+
struct triangleUniforms {
|
|
10
|
+
aggregationMode: f32,
|
|
11
|
+
colorDomain: vec2<f32>,
|
|
12
|
+
intensity: f32,
|
|
13
|
+
threshold: f32,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
@group(0) @binding(auto) var<uniform> triangle: triangleUniforms;
|
|
17
|
+
@group(0) @binding(auto) var colorTexture: texture_2d<f32>;
|
|
18
|
+
@group(0) @binding(auto) var colorTextureSampler: sampler;
|
|
19
|
+
@group(0) @binding(auto) var maxTexture: texture_2d<f32>;
|
|
20
|
+
@group(0) @binding(auto) var weightsTexture: texture_2d<f32>;
|
|
21
|
+
@group(0) @binding(auto) var weightsTextureSampler: sampler;
|
|
22
|
+
`;
|
|
23
|
+
|
|
8
24
|
const uniformBlock = `\
|
|
9
25
|
layout(std140) uniform triangleUniforms {
|
|
10
26
|
float aggregationMode;
|
|
@@ -26,6 +42,7 @@ export type TriangleProps = {
|
|
|
26
42
|
|
|
27
43
|
export const triangleUniforms = {
|
|
28
44
|
name: 'triangle',
|
|
45
|
+
source: uniformBlockWGSL,
|
|
29
46
|
vs: uniformBlock,
|
|
30
47
|
fs: uniformBlock,
|
|
31
48
|
uniformTypes: {
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import type {Buffer, Device, Texture} from '@luma.gl/core';
|
|
6
6
|
import {Model} from '@luma.gl/engine';
|
|
7
|
-
import {Layer, LayerContext, project32} from '@deck.gl/core';
|
|
7
|
+
import {Layer, LayerContext, color, project32} from '@deck.gl/core';
|
|
8
|
+
import source from './triangle-layer.wgsl';
|
|
8
9
|
import vs from './triangle-layer-vertex.glsl';
|
|
9
10
|
import fs from './triangle-layer-fragment.glsl';
|
|
10
11
|
import {TriangleProps, triangleUniforms} from './triangle-layer-uniforms';
|
|
@@ -31,7 +32,7 @@ export default class TriangleLayer extends Layer<_TriangleLayerProps> {
|
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
getShaders() {
|
|
34
|
-
return super.getShaders({vs, fs, modules: [project32, triangleUniforms]});
|
|
35
|
+
return super.getShaders({source, vs, fs, modules: [project32, color, triangleUniforms]});
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
initializeState({device}: LayerContext): void {
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
export default /* wgsl */ `\
|
|
6
|
+
struct TriangleAttributes {
|
|
7
|
+
@location(0) positions: vec3<f32>,
|
|
8
|
+
@location(1) texCoords: vec2<f32>,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
struct TriangleVaryings {
|
|
12
|
+
@builtin(position) position: vec4<f32>,
|
|
13
|
+
@location(0) textureCoordinates: vec2<f32>,
|
|
14
|
+
@location(1) intensityMinimum: f32,
|
|
15
|
+
@location(2) intensityMaximum: f32,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
@vertex
|
|
19
|
+
fn vertexMain(attributes: TriangleAttributes) -> TriangleVaryings {
|
|
20
|
+
var output: TriangleVaryings;
|
|
21
|
+
output.position = project_position_to_clipspace(
|
|
22
|
+
attributes.positions,
|
|
23
|
+
vec3<f32>(0.0),
|
|
24
|
+
vec3<f32>(0.0)
|
|
25
|
+
);
|
|
26
|
+
// WebGPU render-target textures use a top-left origin.
|
|
27
|
+
output.textureCoordinates = vec2<f32>(attributes.texCoords.x, 1.0 - attributes.texCoords.y);
|
|
28
|
+
|
|
29
|
+
let maxWeights = textureLoad(maxTexture, vec2<i32>(0), 0);
|
|
30
|
+
var maximumValue = select(maxWeights.r, maxWeights.g, triangle.aggregationMode > 0.5);
|
|
31
|
+
var minimumValue = maximumValue * triangle.threshold;
|
|
32
|
+
|
|
33
|
+
if (triangle.colorDomain.y > 0.0) {
|
|
34
|
+
maximumValue = triangle.colorDomain.y;
|
|
35
|
+
minimumValue = triangle.colorDomain.x;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
output.intensityMaximum = triangle.intensity / maximumValue;
|
|
39
|
+
output.intensityMinimum = triangle.intensity / minimumValue;
|
|
40
|
+
return output;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@fragment
|
|
44
|
+
fn fragmentMain(varyings: TriangleVaryings) -> @location(0) vec4<f32> {
|
|
45
|
+
let weights = textureSample(weightsTexture, weightsTextureSampler, varyings.textureCoordinates);
|
|
46
|
+
var weight = weights.r;
|
|
47
|
+
|
|
48
|
+
if (triangle.aggregationMode > 0.5) {
|
|
49
|
+
weight /= max(1.0, weights.a);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let colorCoordinates = vec2<f32>(
|
|
53
|
+
clamp(weight * varyings.intensityMaximum, 0.0, 1.0),
|
|
54
|
+
0.5
|
|
55
|
+
);
|
|
56
|
+
var color = textureSample(colorTexture, colorTextureSampler, colorCoordinates);
|
|
57
|
+
|
|
58
|
+
if (weight <= 0.0) {
|
|
59
|
+
discard;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
color.a *= min(weight * varyings.intensityMinimum, 1.0) * layer.opacity;
|
|
63
|
+
return deckgl_premultiplied_alpha(color);
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
export default /* wgsl */ `\
|
|
6
|
+
struct WeightAttributes {
|
|
7
|
+
@builtin(vertex_index) vertexIndex: u32,
|
|
8
|
+
@location(0) instancePositions: vec3<f32>,
|
|
9
|
+
@location(1) instancePositions64Low: vec3<f32>,
|
|
10
|
+
@location(2) instanceWeights: f32,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
struct WeightVaryings {
|
|
14
|
+
@builtin(position) position: vec4<f32>,
|
|
15
|
+
@location(0) pointCoordinates: vec2<f32>,
|
|
16
|
+
@location(1) weights: vec4<f32>,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const WEIGHT_QUAD_POSITIONS = array<vec2<f32>, 6>(
|
|
20
|
+
vec2<f32>(-1.0, -1.0),
|
|
21
|
+
vec2<f32>(1.0, -1.0),
|
|
22
|
+
vec2<f32>(-1.0, 1.0),
|
|
23
|
+
vec2<f32>(-1.0, 1.0),
|
|
24
|
+
vec2<f32>(1.0, -1.0),
|
|
25
|
+
vec2<f32>(1.0, 1.0)
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
@vertex
|
|
29
|
+
fn vertexMain(attributes: WeightAttributes) -> WeightVaryings {
|
|
30
|
+
var output: WeightVaryings;
|
|
31
|
+
let commonPosition = project_position_vec3_f64(
|
|
32
|
+
attributes.instancePositions,
|
|
33
|
+
attributes.instancePositions64Low
|
|
34
|
+
);
|
|
35
|
+
let clipPosition =
|
|
36
|
+
(commonPosition.xy - weight.commonBounds.xy) /
|
|
37
|
+
(weight.commonBounds.zw - weight.commonBounds.xy) * 2.0 - vec2<f32>(1.0);
|
|
38
|
+
let radiusTexels =
|
|
39
|
+
project_pixel_size_float(weight.radiusPixels) * weight.textureWidth /
|
|
40
|
+
(weight.commonBounds.z - weight.commonBounds.x);
|
|
41
|
+
let offset = WEIGHT_QUAD_POSITIONS[attributes.vertexIndex];
|
|
42
|
+
|
|
43
|
+
output.position = vec4<f32>(
|
|
44
|
+
clipPosition + offset * radiusTexels * 2.0 / weight.textureWidth,
|
|
45
|
+
0.0,
|
|
46
|
+
1.0
|
|
47
|
+
);
|
|
48
|
+
output.pointCoordinates = (offset + vec2<f32>(1.0)) * 0.5;
|
|
49
|
+
output.weights = vec4<f32>(attributes.instanceWeights * weight.weightsScale, 0.0, 0.0, 1.0);
|
|
50
|
+
return output;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@fragment
|
|
54
|
+
fn fragmentMain(varyings: WeightVaryings) -> @location(0) vec4<f32> {
|
|
55
|
+
let distanceFromCenter = length(varyings.pointCoordinates - vec2<f32>(0.5));
|
|
56
|
+
if (distanceFromCenter > 0.5) {
|
|
57
|
+
discard;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let gaussian = exp(-pow(2.0 * distanceFromCenter, 2.0) / 0.05555) /
|
|
61
|
+
(1.77245385 * 0.166666);
|
|
62
|
+
return varyings.weights * gaussian;
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
@@ -6,6 +6,7 @@ import {Texture} from '@luma.gl/core';
|
|
|
6
6
|
import {UpdateParameters, Color} from '@deck.gl/core';
|
|
7
7
|
import {ColumnLayer} from '@deck.gl/layers';
|
|
8
8
|
import {createColorRangeTexture, updateColorRangeTexture} from '../common/utils/color-utils';
|
|
9
|
+
import source from './hexagon-cell-layer.wgsl';
|
|
9
10
|
import vs from './hexagon-cell-layer-vertex.glsl';
|
|
10
11
|
import {HexagonProps, hexagonUniforms} from './hexagon-layer-uniforms';
|
|
11
12
|
import type {ScaleType} from '../common/types';
|
|
@@ -35,7 +36,7 @@ export default class HexagonCellLayer<ExtraPropsT extends {} = {}> extends Colum
|
|
|
35
36
|
getShaders() {
|
|
36
37
|
const shaders = super.getShaders();
|
|
37
38
|
shaders.modules.push(hexagonUniforms);
|
|
38
|
-
return {...shaders, vs};
|
|
39
|
+
return {...shaders, source, vs};
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
initializeState() {
|
|
@@ -108,8 +109,6 @@ export default class HexagonCellLayer<ExtraPropsT extends {} = {}> extends Colum
|
|
|
108
109
|
const elevationCutoff = this.props.elevationCutoff || [-Infinity, Infinity];
|
|
109
110
|
const fillModel = this.state.fillModel!;
|
|
110
111
|
|
|
111
|
-
fillModel.setVertexCount(this.state.fillVertexCount);
|
|
112
|
-
|
|
113
112
|
const hexagonProps: Omit<HexagonProps, 'colorRange'> = {
|
|
114
113
|
colorDomain: [
|
|
115
114
|
Math.max(colorDomain[0], colorCutoff[0]), // instanceColorValue that maps to colorRange[0]
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
export default /* wgsl */ `\
|
|
6
|
+
const HEXBIN_DISTANCE: vec2<f32> = vec2<f32>(1.7320508, 1.5);
|
|
7
|
+
|
|
8
|
+
struct Attributes {
|
|
9
|
+
@builtin(instance_index) instanceIndex: u32,
|
|
10
|
+
@location(0) positions: vec3<f32>,
|
|
11
|
+
@location(1) normals: vec3<f32>,
|
|
12
|
+
@location(2) instancePositions: vec2<f32>,
|
|
13
|
+
@location(3) instanceColorValues: f32,
|
|
14
|
+
@location(4) instanceElevationValues: f32,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
struct Varyings {
|
|
18
|
+
@builtin(position) position: vec4<f32>,
|
|
19
|
+
@location(0) color: vec4<f32>,
|
|
20
|
+
@location(1) pickingColor: vec3<f32>,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
fn hexbinCentroid(binId: vec2<f32>, radius: f32) -> vec2<f32> {
|
|
24
|
+
var adjustedBinId = binId;
|
|
25
|
+
adjustedBinId.x += fract(adjustedBinId.y * 0.5);
|
|
26
|
+
return adjustedBinId * HEXBIN_DISTANCE * radius;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
fn interpolate(value: f32, domain: vec2<f32>, range: vec2<f32>) -> f32 {
|
|
30
|
+
let ratio = clamp((value - domain.x) / (domain.y - domain.x), 0.0, 1.0);
|
|
31
|
+
return mix(range.x, range.y, ratio);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
fn sampleColorRange(value: f32, domain: vec2<f32>) -> vec4<f32> {
|
|
35
|
+
let ratio = (value - domain.x) / (domain.y - domain.x);
|
|
36
|
+
return textureSampleLevel(colorRange, colorRangeSampler, vec2<f32>(ratio, 0.5), 0.0);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@vertex
|
|
40
|
+
fn vertexMain(attributes: Attributes) -> Varyings {
|
|
41
|
+
var output: Varyings;
|
|
42
|
+
geometry.pickingColor = picking_getPickingColorFromIndex(attributes.instanceIndex);
|
|
43
|
+
output.pickingColor = geometry.pickingColor;
|
|
44
|
+
|
|
45
|
+
if (
|
|
46
|
+
attributes.instanceColorValues != attributes.instanceColorValues ||
|
|
47
|
+
attributes.instanceColorValues < hexagon.colorDomain.z ||
|
|
48
|
+
attributes.instanceColorValues > hexagon.colorDomain.w ||
|
|
49
|
+
attributes.instanceElevationValues < hexagon.elevationDomain.z ||
|
|
50
|
+
attributes.instanceElevationValues > hexagon.elevationDomain.w
|
|
51
|
+
) {
|
|
52
|
+
output.position = vec4<f32>(0.0);
|
|
53
|
+
output.color = vec4<f32>(0.0);
|
|
54
|
+
return output;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var commonPosition =
|
|
58
|
+
hexbinCentroid(attributes.instancePositions, column.radius) +
|
|
59
|
+
(hexagon.originCommon - project.commonOrigin.xy);
|
|
60
|
+
commonPosition += attributes.positions.xy * column.radius * column.coverage;
|
|
61
|
+
geometry.position = vec4<f32>(commonPosition, 0.0, 1.0);
|
|
62
|
+
geometry.normal = project_normal(attributes.normals);
|
|
63
|
+
|
|
64
|
+
if (column.extruded > 0.5) {
|
|
65
|
+
var elevation = interpolate(
|
|
66
|
+
attributes.instanceElevationValues,
|
|
67
|
+
hexagon.elevationDomain.xy,
|
|
68
|
+
hexagon.elevationRange
|
|
69
|
+
);
|
|
70
|
+
elevation = project_size_float(elevation);
|
|
71
|
+
geometry.position.z = (attributes.positions.z + 1.0) / 2.0 * elevation;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
output.position = project_common_position_to_clipspace(geometry.position);
|
|
75
|
+
var colorValue = sampleColorRange(attributes.instanceColorValues, hexagon.colorDomain.xy);
|
|
76
|
+
if (column.extruded > 0.5) {
|
|
77
|
+
colorValue = vec4<f32>(
|
|
78
|
+
lighting_getLightColor2(
|
|
79
|
+
colorValue.rgb,
|
|
80
|
+
project.cameraPosition,
|
|
81
|
+
geometry.position.xyz,
|
|
82
|
+
geometry.normal
|
|
83
|
+
),
|
|
84
|
+
colorValue.a
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
output.color = vec4<f32>(colorValue.rgb, colorValue.a * layer.opacity);
|
|
88
|
+
return output;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@fragment
|
|
92
|
+
fn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {
|
|
93
|
+
if (picking.isActive > 0.5) {
|
|
94
|
+
if (!picking_isColorValid(varyings.pickingColor)) {
|
|
95
|
+
discard;
|
|
96
|
+
}
|
|
97
|
+
return vec4<f32>(varyings.pickingColor, 1.0);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
var color = varyings.color;
|
|
101
|
+
if (picking.isHighlightActive > 0.5) {
|
|
102
|
+
let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
|
|
103
|
+
if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {
|
|
104
|
+
let highLightAlpha = picking.highlightColor.a;
|
|
105
|
+
let blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);
|
|
106
|
+
if (blendedAlpha > 0.0) {
|
|
107
|
+
let highLightRatio = highLightAlpha / blendedAlpha;
|
|
108
|
+
color = vec4<f32>(
|
|
109
|
+
mix(color.rgb, picking.highlightColor.rgb, highLightRatio),
|
|
110
|
+
blendedAlpha
|
|
111
|
+
);
|
|
112
|
+
} else {
|
|
113
|
+
color = vec4<f32>(color.rgb, 0.0);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return deckgl_premultiplied_alpha(color);
|
|
119
|
+
}
|
|
120
|
+
`;
|
|
@@ -5,6 +5,19 @@
|
|
|
5
5
|
import {Texture} from '@luma.gl/core';
|
|
6
6
|
import type {ShaderModule} from '@luma.gl/shadertools';
|
|
7
7
|
|
|
8
|
+
const uniformBlockWGSL = /* wgsl */ `\
|
|
9
|
+
struct HexagonUniforms {
|
|
10
|
+
colorDomain: vec4<f32>,
|
|
11
|
+
elevationDomain: vec4<f32>,
|
|
12
|
+
elevationRange: vec2<f32>,
|
|
13
|
+
originCommon: vec2<f32>,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
@group(0) @binding(auto) var<uniform> hexagon: HexagonUniforms;
|
|
17
|
+
@group(0) @binding(auto) var colorRange: texture_2d<f32>;
|
|
18
|
+
@group(0) @binding(auto) var colorRangeSampler: sampler;
|
|
19
|
+
`;
|
|
20
|
+
|
|
8
21
|
const uniformBlock = /* glsl */ `\
|
|
9
22
|
layout(std140) uniform hexagonUniforms {
|
|
10
23
|
vec4 colorDomain;
|
|
@@ -24,6 +37,7 @@ export type HexagonProps = {
|
|
|
24
37
|
|
|
25
38
|
export const hexagonUniforms = {
|
|
26
39
|
name: 'hexagon',
|
|
40
|
+
source: uniformBlockWGSL,
|
|
27
41
|
vs: uniformBlock,
|
|
28
42
|
uniformTypes: {
|
|
29
43
|
colorDomain: 'vec4<f32>',
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import {Texture} from '@luma.gl/core';
|
|
6
6
|
import {Model, Geometry} from '@luma.gl/engine';
|
|
7
|
-
import {Layer, picking, UpdateParameters, Color} from '@deck.gl/core';
|
|
7
|
+
import {Layer, color, picking, UpdateParameters, Color} from '@deck.gl/core';
|
|
8
8
|
import {createColorRangeTexture, updateColorRangeTexture} from '../common/utils/color-utils';
|
|
9
|
+
import source from './screen-grid-cell-layer.wgsl';
|
|
9
10
|
import vs from './screen-grid-layer-vertex.glsl';
|
|
10
11
|
import fs from './screen-grid-layer-fragment.glsl';
|
|
11
12
|
import {ScreenGridProps, screenGridUniforms} from './screen-grid-layer-uniforms';
|
|
12
|
-
import {ShaderModule} from '@luma.gl/shadertools';
|
|
13
13
|
import type {ScaleType} from '../common/types';
|
|
14
14
|
|
|
15
15
|
/** Proprties added by ScreenGridCellLayer. */
|
|
@@ -31,8 +31,8 @@ export default class ScreenGridCellLayer<ExtraPropsT extends {} = {}> extends La
|
|
|
31
31
|
colorTexture: Texture;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
getShaders()
|
|
35
|
-
return super.getShaders({vs, fs, modules: [picking, screenGridUniforms]});
|
|
34
|
+
getShaders() {
|
|
35
|
+
return super.getShaders({source, vs, fs, modules: [color, picking, screenGridUniforms]});
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
initializeState() {
|