@deck.gl/extensions 9.0.34 → 9.1.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/brushing/brushing-extension.d.ts +1 -0
- package/dist/brushing/brushing-extension.d.ts.map +1 -1
- package/dist/brushing/brushing-extension.js +15 -19
- package/dist/brushing/shader-module.d.ts +8 -2
- package/dist/brushing/shader-module.d.ts.map +1 -1
- package/dist/brushing/shader-module.js +74 -50
- package/dist/clip/clip-extension.d.ts +5 -2
- package/dist/clip/clip-extension.d.ts.map +1 -1
- package/dist/clip/clip-extension.js +36 -42
- package/dist/collision-filter/collision-filter-effect.d.ts +4 -4
- package/dist/collision-filter/collision-filter-effect.d.ts.map +1 -1
- package/dist/collision-filter/collision-filter-effect.js +27 -13
- package/dist/collision-filter/collision-filter-extension.d.ts +1 -1
- package/dist/collision-filter/collision-filter-extension.d.ts.map +1 -1
- package/dist/collision-filter/collision-filter-extension.js +5 -6
- package/dist/collision-filter/collision-filter-pass.d.ts +7 -3
- package/dist/collision-filter/collision-filter-pass.d.ts.map +1 -1
- package/dist/collision-filter/collision-filter-pass.js +8 -3
- package/dist/collision-filter/shader-module.d.ts +3 -2
- package/dist/collision-filter/shader-module.d.ts.map +1 -1
- package/dist/collision-filter/shader-module.js +74 -52
- package/dist/data-filter/aggregator.d.ts +4 -10
- package/dist/data-filter/aggregator.d.ts.map +1 -1
- package/dist/data-filter/aggregator.js +14 -8
- package/dist/data-filter/data-filter-extension.d.ts.map +1 -1
- package/dist/data-filter/data-filter-extension.js +40 -38
- package/dist/data-filter/shader-module.d.ts +11 -4
- package/dist/data-filter/shader-module.d.ts.map +1 -1
- package/dist/data-filter/shader-module.js +189 -131
- package/dist/dist.dev.js +2699 -2028
- package/dist/fill-style/fill-style-extension.d.ts.map +1 -1
- package/dist/fill-style/fill-style-extension.js +11 -4
- package/dist/fill-style/shader-module.d.ts +64 -6
- package/dist/fill-style/shader-module.d.ts.map +1 -1
- package/dist/fill-style/shader-module.js +73 -51
- package/dist/fp64/fp64-extension.d.ts +1 -0
- package/dist/fp64/fp64-extension.d.ts.map +1 -1
- package/dist/fp64/fp64-extension.js +7 -19
- package/dist/fp64/project64.d.ts +2 -2
- package/dist/fp64/project64.d.ts.map +1 -1
- package/dist/fp64/project64.glsl.d.ts +1 -1
- package/dist/fp64/project64.glsl.d.ts.map +1 -1
- package/dist/fp64/project64.glsl.js +18 -21
- package/dist/fp64/project64.js +24 -24
- package/dist/index.cjs +1017 -523
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/mask/mask-effect.d.ts +5 -3
- package/dist/mask/mask-effect.d.ts.map +1 -1
- package/dist/mask/mask-effect.js +12 -5
- package/dist/mask/mask-extension.d.ts +1 -1
- package/dist/mask/mask-extension.d.ts.map +1 -1
- package/dist/mask/mask-extension.js +13 -8
- package/dist/mask/mask-pass.d.ts +38 -38
- package/dist/mask/mask-pass.d.ts.map +1 -1
- package/dist/mask/mask-pass.js +3 -0
- package/dist/mask/shader-module.d.ts +60 -3
- package/dist/mask/shader-module.d.ts.map +1 -1
- package/dist/mask/shader-module.js +73 -46
- package/dist/path-style/path-style-extension.d.ts.map +1 -1
- package/dist/path-style/path-style-extension.js +20 -24
- package/dist/path-style/shaders.glsl.d.ts.map +1 -1
- package/dist/path-style/shaders.glsl.js +11 -7
- package/dist/terrain/height-map-builder.d.ts.map +1 -1
- package/dist/terrain/height-map-builder.js +3 -0
- package/dist/terrain/shader-module.d.ts +60 -6
- package/dist/terrain/shader-module.d.ts.map +1 -1
- package/dist/terrain/shader-module.js +69 -61
- package/dist/terrain/terrain-cover.d.ts.map +1 -1
- package/dist/terrain/terrain-cover.js +3 -0
- package/dist/terrain/terrain-effect.d.ts +4 -2
- package/dist/terrain/terrain-effect.d.ts.map +1 -1
- package/dist/terrain/terrain-effect.js +31 -18
- package/dist/terrain/terrain-extension.d.ts.map +1 -1
- package/dist/terrain/terrain-extension.js +3 -0
- package/dist/terrain/terrain-pass.d.ts +43 -38
- package/dist/terrain/terrain-pass.d.ts.map +1 -1
- package/dist/terrain/terrain-pass.js +10 -0
- package/dist/terrain/terrain-picking-pass.d.ts +5 -0
- package/dist/terrain/terrain-picking-pass.d.ts.map +1 -1
- package/dist/terrain/terrain-picking-pass.js +10 -0
- package/dist/terrain/utils.d.ts.map +1 -1
- package/dist/terrain/utils.js +3 -0
- package/dist/utils/debug.d.ts +2 -2
- package/dist/utils/debug.d.ts.map +1 -1
- package/dist/utils/debug.js +3 -1
- package/dist/utils/projection-utils.d.ts.map +1 -1
- package/dist/utils/projection-utils.js +3 -0
- package/dist.min.js +1102 -817
- package/package.json +8 -8
- package/src/brushing/brushing-extension.ts +17 -20
- package/src/brushing/shader-module.ts +58 -47
- package/src/clip/clip-extension.ts +38 -40
- package/src/collision-filter/collision-filter-effect.ts +31 -20
- package/src/collision-filter/collision-filter-extension.ts +6 -7
- package/src/collision-filter/collision-filter-pass.ts +9 -3
- package/src/collision-filter/shader-module.ts +40 -22
- package/src/data-filter/aggregator.ts +23 -11
- package/src/data-filter/data-filter-extension.ts +68 -48
- package/src/data-filter/shader-module.ts +144 -84
- package/src/fill-style/fill-style-extension.ts +13 -5
- package/src/fill-style/shader-module.ts +84 -52
- package/src/fp64/fp64-extension.ts +8 -19
- package/src/fp64/project64.glsl.ts +18 -21
- package/src/fp64/project64.ts +27 -28
- package/src/index.ts +5 -0
- package/src/mask/mask-effect.ts +17 -7
- package/src/mask/mask-extension.ts +16 -9
- package/src/mask/mask-pass.ts +4 -0
- package/src/mask/shader-module.ts +63 -27
- package/src/path-style/path-style-extension.ts +27 -28
- package/src/path-style/shaders.glsl.ts +13 -7
- package/src/terrain/height-map-builder.ts +4 -0
- package/src/terrain/shader-module.ts +62 -44
- package/src/terrain/terrain-cover.ts +4 -0
- package/src/terrain/terrain-effect.ts +36 -19
- package/src/terrain/terrain-extension.ts +4 -0
- package/src/terrain/terrain-pass.ts +12 -0
- package/src/terrain/terrain-picking-pass.ts +12 -0
- package/src/terrain/utils.ts +4 -0
- package/src/utils/debug.ts +4 -0
- package/src/utils/projection-utils.ts +4 -0
- package/dist/utils/syntax-tags.d.ts +0 -6
- package/dist/utils/syntax-tags.d.ts.map +0 -1
- package/dist/utils/syntax-tags.js +0 -5
- package/src/utils/syntax-tags.ts +0 -5
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {Device, DeviceFeature, Framebuffer, RenderPipelineParameters} from '@luma.gl/core';
|
|
6
|
+
import {Model, ModelProps} from '@luma.gl/engine';
|
|
4
7
|
|
|
5
8
|
const AGGREGATE_VS = `\
|
|
6
9
|
#version 300 es
|
|
@@ -71,7 +74,6 @@ export function getFramebuffer(device: Device, useFloatTarget: boolean): Framebu
|
|
|
71
74
|
colorAttachments: [
|
|
72
75
|
device.createTexture({
|
|
73
76
|
format: 'rgba32float',
|
|
74
|
-
type: GL.FLOAT,
|
|
75
77
|
mipmaps: false
|
|
76
78
|
})
|
|
77
79
|
]
|
|
@@ -80,12 +82,17 @@ export function getFramebuffer(device: Device, useFloatTarget: boolean): Framebu
|
|
|
80
82
|
return device.createFramebuffer({
|
|
81
83
|
width: 256,
|
|
82
84
|
height: 64,
|
|
83
|
-
colorAttachments: [device.createTexture({format: 'rgba8unorm',
|
|
85
|
+
colorAttachments: [device.createTexture({format: 'rgba8unorm', mipmaps: false})]
|
|
84
86
|
});
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
// Increments the counter based on dataFilter_value
|
|
88
|
-
export function getModel(
|
|
90
|
+
export function getModel(
|
|
91
|
+
device: Device,
|
|
92
|
+
bufferLayout: ModelProps['bufferLayout'],
|
|
93
|
+
shaderOptions: any,
|
|
94
|
+
useFloatTarget: boolean
|
|
95
|
+
): Model {
|
|
89
96
|
shaderOptions.defines.NON_INSTANCED_MODEL = 1;
|
|
90
97
|
if (useFloatTarget) {
|
|
91
98
|
shaderOptions.defines.FLOAT_TARGET = 1;
|
|
@@ -95,16 +102,21 @@ export function getModel(device: Device, shaderOptions: any, useFloatTarget: boo
|
|
|
95
102
|
id: 'data-filter-aggregation-model',
|
|
96
103
|
vertexCount: 1,
|
|
97
104
|
isInstanced: false,
|
|
98
|
-
|
|
105
|
+
topology: 'point-list',
|
|
99
106
|
vs: AGGREGATE_VS,
|
|
100
107
|
fs: AGGREGATE_FS,
|
|
108
|
+
bufferLayout,
|
|
101
109
|
...shaderOptions
|
|
102
110
|
});
|
|
103
111
|
}
|
|
104
112
|
|
|
105
|
-
export const parameters = {
|
|
113
|
+
export const parameters: RenderPipelineParameters = {
|
|
106
114
|
blend: true,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
blendColorSrcFactor: 'one',
|
|
116
|
+
blendColorDstFactor: 'one',
|
|
117
|
+
blendAlphaSrcFactor: 'one',
|
|
118
|
+
blendAlphaDstFactor: 'one',
|
|
119
|
+
blendColorOperation: 'add',
|
|
120
|
+
blendAlphaOperation: 'add',
|
|
121
|
+
depthCompare: 'never'
|
|
110
122
|
} as const;
|
|
@@ -1,29 +1,20 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
// furnished to do so, subject to the following conditions:
|
|
9
|
-
//
|
|
10
|
-
// The above copyright notice and this permission notice shall be included in
|
|
11
|
-
// all copies or substantial portions of the Software.
|
|
12
|
-
//
|
|
13
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
// THE SOFTWARE.
|
|
20
|
-
|
|
21
|
-
import type {Framebuffer} from '@luma.gl/core';
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Buffer, Framebuffer} from '@luma.gl/core';
|
|
22
6
|
import type {Model} from '@luma.gl/engine';
|
|
23
7
|
import type {Layer, LayerContext, Accessor, UpdateParameters} from '@deck.gl/core';
|
|
24
8
|
import {_deepEqual as deepEqual, LayerExtension, log} from '@deck.gl/core';
|
|
25
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
CategoryBitMask,
|
|
11
|
+
DataFilterModuleProps,
|
|
12
|
+
Defines,
|
|
13
|
+
dataFilter,
|
|
14
|
+
dataFilter64
|
|
15
|
+
} from './shader-module';
|
|
26
16
|
import * as aggregator from './aggregator';
|
|
17
|
+
import {NumberArray4} from '@math.gl/core';
|
|
27
18
|
|
|
28
19
|
const defaultProps = {
|
|
29
20
|
getFilterValue: {type: 'accessor', value: 0},
|
|
@@ -154,7 +145,10 @@ export default class DataFilterExtension extends LayerExtension<
|
|
|
154
145
|
defines.DATAFILTER_DOUBLE = Boolean(fp64);
|
|
155
146
|
}
|
|
156
147
|
|
|
157
|
-
|
|
148
|
+
const module = fp64 ? dataFilter64 : dataFilter;
|
|
149
|
+
module.uniformTypes = module.uniformTypesFromOptions(extension.opts);
|
|
150
|
+
|
|
151
|
+
return {modules: [module], defines};
|
|
158
152
|
}
|
|
159
153
|
|
|
160
154
|
initializeState(this: Layer<DataFilterExtensionProps>, context: LayerContext, extension: this) {
|
|
@@ -195,7 +189,7 @@ export default class DataFilterExtension extends LayerExtension<
|
|
|
195
189
|
// The vertex shader checks if a vertex has the same "index" as the previous vertex
|
|
196
190
|
// so that we only write one count cross multiple vertices of the same object
|
|
197
191
|
attributeManager.add({
|
|
198
|
-
|
|
192
|
+
filterVertexIndices: {
|
|
199
193
|
size: useFloatTarget ? 1 : 2,
|
|
200
194
|
vertexOffset: 1,
|
|
201
195
|
type: 'unorm8',
|
|
@@ -217,6 +211,7 @@ export default class DataFilterExtension extends LayerExtension<
|
|
|
217
211
|
const filterFBO = aggregator.getFramebuffer(device, useFloatTarget);
|
|
218
212
|
const filterModel = aggregator.getModel(
|
|
219
213
|
device,
|
|
214
|
+
attributeManager.getBufferLayouts({isInstanced: false}),
|
|
220
215
|
extension.getShaders.call(this, extension),
|
|
221
216
|
useFloatTarget
|
|
222
217
|
);
|
|
@@ -271,40 +266,65 @@ export default class DataFilterExtension extends LayerExtension<
|
|
|
271
266
|
const filterModel = this.state.filterModel as Model;
|
|
272
267
|
const filterNeedsUpdate = this.state.filterNeedsUpdate as boolean;
|
|
273
268
|
|
|
274
|
-
const {onFilteredItemsChange} = this.props;
|
|
275
|
-
|
|
276
269
|
if (!this.state.categoryBitMask) {
|
|
277
270
|
extension._updateCategoryBitMask.call(this, params, extension);
|
|
278
271
|
}
|
|
272
|
+
|
|
273
|
+
const {
|
|
274
|
+
onFilteredItemsChange,
|
|
275
|
+
extensions,
|
|
276
|
+
filterEnabled,
|
|
277
|
+
filterRange,
|
|
278
|
+
filterSoftRange,
|
|
279
|
+
filterTransformSize,
|
|
280
|
+
filterTransformColor,
|
|
281
|
+
filterCategories
|
|
282
|
+
} = this.props;
|
|
283
|
+
const dataFilterProps: DataFilterModuleProps = {
|
|
284
|
+
extensions,
|
|
285
|
+
filterEnabled,
|
|
286
|
+
filterRange,
|
|
287
|
+
filterSoftRange,
|
|
288
|
+
filterTransformSize,
|
|
289
|
+
filterTransformColor,
|
|
290
|
+
filterCategories
|
|
291
|
+
};
|
|
292
|
+
if (this.state.categoryBitMask) {
|
|
293
|
+
dataFilterProps.categoryBitMask = this.state.categoryBitMask as CategoryBitMask;
|
|
294
|
+
}
|
|
295
|
+
this.setShaderModuleProps({dataFilter: dataFilterProps});
|
|
296
|
+
|
|
279
297
|
/* eslint-disable-next-line camelcase */
|
|
280
|
-
params.uniforms.filter_categoryBitMask = this.state.categoryBitMask;
|
|
281
298
|
if (filterNeedsUpdate && onFilteredItemsChange && filterModel) {
|
|
299
|
+
const attributeManager = this.getAttributeManager()!;
|
|
282
300
|
const {
|
|
283
|
-
attributes: {filterValues, filterCategoryValues,
|
|
284
|
-
} =
|
|
301
|
+
attributes: {filterValues, filterCategoryValues, filterVertexIndices}
|
|
302
|
+
} = attributeManager;
|
|
285
303
|
filterModel.setVertexCount(this.getNumInstances());
|
|
286
304
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
filterModel.updateModuleSettings(params.moduleParameters);
|
|
290
|
-
// @ts-expect-error filterValue and filterIndices should always have buffer value
|
|
291
|
-
filterModel.setAttributes({
|
|
305
|
+
// @ts-expect-error filterValue and filterVertexIndices should always have buffer value
|
|
306
|
+
const attributes: Record<string, Buffer> = {
|
|
292
307
|
...filterValues?.getValue(),
|
|
293
308
|
...filterCategoryValues?.getValue(),
|
|
294
|
-
...
|
|
309
|
+
...filterVertexIndices?.getValue()
|
|
310
|
+
};
|
|
311
|
+
filterModel.setAttributes(attributes);
|
|
312
|
+
filterModel.shaderInputs.setProps({
|
|
313
|
+
dataFilter: dataFilterProps
|
|
295
314
|
});
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
);
|
|
315
|
+
|
|
316
|
+
const viewport = [0, 0, filterFBO.width, filterFBO.height] as NumberArray4;
|
|
317
|
+
|
|
318
|
+
const renderPass = filterModel.device.beginRenderPass({
|
|
319
|
+
id: 'data-filter-aggregation',
|
|
320
|
+
framebuffer: filterFBO,
|
|
321
|
+
parameters: {viewport},
|
|
322
|
+
clearColor: [0, 0, 0, 0]
|
|
323
|
+
});
|
|
324
|
+
filterModel.setParameters(aggregator.parameters);
|
|
325
|
+
filterModel.draw(renderPass);
|
|
326
|
+
renderPass.end();
|
|
327
|
+
|
|
308
328
|
const color = filterModel.device.readPixelsToArrayWebGL(filterFBO);
|
|
309
329
|
let count = 0;
|
|
310
330
|
for (let i = 0; i < color.length; i++) {
|
|
@@ -338,7 +358,7 @@ export default class DataFilterExtension extends LayerExtension<
|
|
|
338
358
|
const {categorySize} = extension.opts;
|
|
339
359
|
if (!categorySize) return;
|
|
340
360
|
const {filterCategories} = this.props;
|
|
341
|
-
const categoryBitMask = new Uint32Array([0, 0, 0, 0]);
|
|
361
|
+
const categoryBitMask: CategoryBitMask = new Uint32Array([0, 0, 0, 0]);
|
|
342
362
|
const categoryFilters = (
|
|
343
363
|
categorySize === 1 ? [filterCategories] : filterCategories
|
|
344
364
|
) as FilterCategory[][];
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import type {ShaderModule} from '@luma.gl/shadertools';
|
|
2
|
-
import type {DataFilterExtensionProps} from './data-filter-extension';
|
|
3
|
-
import {
|
|
6
|
+
import type {DataFilterExtensionOptions, DataFilterExtensionProps} from './data-filter-extension';
|
|
7
|
+
import {UniformFormat} from '@luma.gl/shadertools/dist/types';
|
|
4
8
|
|
|
5
9
|
/*
|
|
6
10
|
* data filter shader module
|
|
@@ -27,27 +31,35 @@ export type Defines = {
|
|
|
27
31
|
DATAFILTER_DOUBLE?: boolean;
|
|
28
32
|
};
|
|
29
33
|
|
|
30
|
-
const
|
|
31
|
-
uniform
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const uniformBlock = /* glsl */ `\
|
|
35
|
+
uniform dataFilterUniforms {
|
|
36
|
+
bool useSoftMargin;
|
|
37
|
+
bool enabled;
|
|
38
|
+
bool transformSize;
|
|
39
|
+
bool transformColor;
|
|
36
40
|
#ifdef DATAFILTER_TYPE
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
DATAFILTER_TYPE min;
|
|
42
|
+
DATAFILTER_TYPE softMin;
|
|
43
|
+
DATAFILTER_TYPE softMax;
|
|
44
|
+
DATAFILTER_TYPE max;
|
|
45
|
+
#ifdef DATAFILTER_DOUBLE
|
|
46
|
+
DATAFILTER_TYPE min64High;
|
|
47
|
+
DATAFILTER_TYPE max64High;
|
|
48
|
+
#endif
|
|
49
|
+
#endif
|
|
50
|
+
#ifdef DATACATEGORY_TYPE
|
|
51
|
+
highp ivec4 categoryBitMask;
|
|
52
|
+
#endif
|
|
53
|
+
} dataFilter;
|
|
54
|
+
`;
|
|
41
55
|
|
|
56
|
+
const vertex = /* glsl */ `
|
|
57
|
+
#ifdef DATAFILTER_TYPE
|
|
42
58
|
in DATAFILTER_TYPE filterValues;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
uniform DATAFILTER_TYPE filter_min64High;
|
|
47
|
-
uniform DATAFILTER_TYPE filter_max64High;
|
|
48
|
-
#endif
|
|
59
|
+
#ifdef DATAFILTER_DOUBLE
|
|
60
|
+
in DATAFILTER_TYPE filterValues64Low;
|
|
61
|
+
#endif
|
|
49
62
|
#endif
|
|
50
|
-
|
|
51
63
|
|
|
52
64
|
#ifdef DATACATEGORY_TYPE
|
|
53
65
|
in DATACATEGORY_TYPE filterCategoryValues;
|
|
@@ -70,23 +82,23 @@ float dataFilter_reduceValue(vec4 value) {
|
|
|
70
82
|
|
|
71
83
|
#ifdef DATAFILTER_TYPE
|
|
72
84
|
void dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFromMax) {
|
|
73
|
-
if (
|
|
85
|
+
if (dataFilter.useSoftMargin) {
|
|
74
86
|
// smoothstep results are undefined if edge0 ≥ edge1
|
|
75
87
|
// Fallback to ignore filterSoftRange if it is truncated by filterRange
|
|
76
88
|
DATAFILTER_TYPE leftInRange = mix(
|
|
77
|
-
smoothstep(
|
|
78
|
-
step(
|
|
79
|
-
step(
|
|
89
|
+
smoothstep(dataFilter.min, dataFilter.softMin, valueFromMin),
|
|
90
|
+
step(dataFilter.min, valueFromMin),
|
|
91
|
+
step(dataFilter.softMin, dataFilter.min)
|
|
80
92
|
);
|
|
81
93
|
DATAFILTER_TYPE rightInRange = mix(
|
|
82
|
-
1.0 - smoothstep(
|
|
83
|
-
step(valueFromMax,
|
|
84
|
-
step(
|
|
94
|
+
1.0 - smoothstep(dataFilter.softMax, dataFilter.max, valueFromMax),
|
|
95
|
+
step(valueFromMax, dataFilter.max),
|
|
96
|
+
step(dataFilter.max, dataFilter.softMax)
|
|
85
97
|
);
|
|
86
98
|
dataFilter_value = dataFilter_reduceValue(leftInRange * rightInRange);
|
|
87
99
|
} else {
|
|
88
100
|
dataFilter_value = dataFilter_reduceValue(
|
|
89
|
-
step(
|
|
101
|
+
step(dataFilter.min, valueFromMin) * step(valueFromMax, dataFilter.max)
|
|
90
102
|
);
|
|
91
103
|
}
|
|
92
104
|
}
|
|
@@ -95,16 +107,16 @@ float dataFilter_reduceValue(vec4 value) {
|
|
|
95
107
|
#ifdef DATACATEGORY_TYPE
|
|
96
108
|
void dataFilter_setCategoryValue(DATACATEGORY_TYPE category) {
|
|
97
109
|
#if DATACATEGORY_CHANNELS == 1 // One 128-bit mask
|
|
98
|
-
int dataFilter_masks =
|
|
110
|
+
int dataFilter_masks = dataFilter.categoryBitMask[int(category / 32.0)];
|
|
99
111
|
#elif DATACATEGORY_CHANNELS == 2 // Two 64-bit masks
|
|
100
112
|
ivec2 dataFilter_masks = ivec2(
|
|
101
|
-
|
|
102
|
-
|
|
113
|
+
dataFilter.categoryBitMask[int(category.x / 32.0)],
|
|
114
|
+
dataFilter.categoryBitMask[int(category.y / 32.0) + 2]
|
|
103
115
|
);
|
|
104
116
|
#elif DATACATEGORY_CHANNELS == 3 // Three 32-bit masks
|
|
105
|
-
ivec3 dataFilter_masks =
|
|
117
|
+
ivec3 dataFilter_masks = dataFilter.categoryBitMask.xyz;
|
|
106
118
|
#else // Four 32-bit masks
|
|
107
|
-
ivec4 dataFilter_masks =
|
|
119
|
+
ivec4 dataFilter_masks = dataFilter.categoryBitMask;
|
|
108
120
|
#endif
|
|
109
121
|
|
|
110
122
|
// Shift mask and extract relevant bits
|
|
@@ -120,17 +132,28 @@ float dataFilter_reduceValue(vec4 value) {
|
|
|
120
132
|
#endif
|
|
121
133
|
`;
|
|
122
134
|
|
|
123
|
-
const
|
|
124
|
-
|
|
135
|
+
const vs = `
|
|
136
|
+
${uniformBlock}
|
|
137
|
+
${vertex}
|
|
138
|
+
`;
|
|
139
|
+
|
|
140
|
+
const fragment = /* glsl */ `
|
|
125
141
|
in float dataFilter_value;
|
|
126
142
|
`;
|
|
127
143
|
|
|
128
|
-
|
|
144
|
+
const fs = `
|
|
145
|
+
${uniformBlock}
|
|
146
|
+
${fragment}
|
|
147
|
+
`;
|
|
148
|
+
|
|
149
|
+
export type CategoryBitMask = Uint32Array;
|
|
150
|
+
export type DataFilterModuleProps = {
|
|
129
151
|
extensions: any[]; // used to detect if layer props are present
|
|
152
|
+
categoryBitMask?: CategoryBitMask;
|
|
130
153
|
} & DataFilterExtensionProps;
|
|
131
154
|
|
|
132
155
|
/* eslint-disable camelcase */
|
|
133
|
-
function getUniforms(opts?:
|
|
156
|
+
function getUniforms(opts?: DataFilterModuleProps | {}): Record<string, any> {
|
|
134
157
|
if (!opts || !('extensions' in opts)) {
|
|
135
158
|
return {};
|
|
136
159
|
}
|
|
@@ -138,69 +161,71 @@ function getUniforms(opts?: DataFilterModuleSettings | {}): Record<string, any>
|
|
|
138
161
|
filterRange = [-1, 1],
|
|
139
162
|
filterEnabled = true,
|
|
140
163
|
filterTransformSize = true,
|
|
141
|
-
filterTransformColor = true
|
|
164
|
+
filterTransformColor = true,
|
|
165
|
+
categoryBitMask = [0, 0, 0, 0]
|
|
142
166
|
} = opts;
|
|
143
167
|
const filterSoftRange = opts.filterSoftRange || filterRange;
|
|
144
168
|
|
|
145
169
|
return {
|
|
146
170
|
...(Number.isFinite(filterRange[0])
|
|
147
171
|
? {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
172
|
+
min: filterRange[0],
|
|
173
|
+
softMin: filterSoftRange[0],
|
|
174
|
+
softMax: filterSoftRange[1],
|
|
175
|
+
max: filterRange[1]
|
|
152
176
|
}
|
|
153
177
|
: {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
178
|
+
min: filterRange.map(r => r[0]),
|
|
179
|
+
softMin: filterSoftRange.map(r => r[0]),
|
|
180
|
+
softMax: filterSoftRange.map(r => r[1]),
|
|
181
|
+
max: filterRange.map(r => r[1])
|
|
158
182
|
}),
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
183
|
+
enabled: filterEnabled,
|
|
184
|
+
useSoftMargin: Boolean(opts.filterSoftRange),
|
|
185
|
+
transformSize: filterEnabled && filterTransformSize,
|
|
186
|
+
transformColor: filterEnabled && filterTransformColor,
|
|
187
|
+
categoryBitMask
|
|
163
188
|
};
|
|
164
189
|
}
|
|
165
190
|
|
|
166
|
-
function getUniforms64(opts?:
|
|
191
|
+
function getUniforms64(opts?: DataFilterModuleProps | {}): Record<string, any> {
|
|
167
192
|
if (!opts || !('extensions' in opts)) {
|
|
168
193
|
return {};
|
|
169
194
|
}
|
|
170
195
|
const uniforms = getUniforms(opts);
|
|
171
|
-
if (Number.isFinite(uniforms.
|
|
172
|
-
const min64High = Math.fround(uniforms.
|
|
173
|
-
uniforms.
|
|
174
|
-
uniforms.
|
|
175
|
-
uniforms.
|
|
176
|
-
|
|
177
|
-
const max64High = Math.fround(uniforms.
|
|
178
|
-
uniforms.
|
|
179
|
-
uniforms.
|
|
180
|
-
uniforms.
|
|
196
|
+
if (Number.isFinite(uniforms.min)) {
|
|
197
|
+
const min64High = Math.fround(uniforms.min);
|
|
198
|
+
uniforms.min -= min64High;
|
|
199
|
+
uniforms.softMin -= min64High;
|
|
200
|
+
uniforms.min64High = min64High;
|
|
201
|
+
|
|
202
|
+
const max64High = Math.fround(uniforms.max);
|
|
203
|
+
uniforms.max -= max64High;
|
|
204
|
+
uniforms.softMax -= max64High;
|
|
205
|
+
uniforms.max64High = max64High;
|
|
181
206
|
} else {
|
|
182
|
-
const min64High = uniforms.
|
|
183
|
-
uniforms.
|
|
184
|
-
uniforms.
|
|
185
|
-
uniforms.
|
|
186
|
-
|
|
187
|
-
const max64High = uniforms.
|
|
188
|
-
uniforms.
|
|
189
|
-
uniforms.
|
|
190
|
-
uniforms.
|
|
207
|
+
const min64High = uniforms.min.map(Math.fround);
|
|
208
|
+
uniforms.min = uniforms.min.map((x, i) => x - min64High[i]);
|
|
209
|
+
uniforms.softMin = uniforms.softMin.map((x, i) => x - min64High[i]);
|
|
210
|
+
uniforms.min64High = min64High;
|
|
211
|
+
|
|
212
|
+
const max64High = uniforms.max.map(Math.fround);
|
|
213
|
+
uniforms.max = uniforms.max.map((x, i) => x - max64High[i]);
|
|
214
|
+
uniforms.softMax = uniforms.softMax.map((x, i) => x - max64High[i]);
|
|
215
|
+
uniforms.max64High = max64High;
|
|
191
216
|
}
|
|
192
217
|
return uniforms;
|
|
193
218
|
}
|
|
194
219
|
|
|
195
220
|
const inject = {
|
|
196
|
-
'vs:#main-start': glsl`
|
|
221
|
+
'vs:#main-start': /* glsl */ `
|
|
197
222
|
dataFilter_value = 1.0;
|
|
198
|
-
if (
|
|
223
|
+
if (dataFilter.enabled) {
|
|
199
224
|
#ifdef DATAFILTER_TYPE
|
|
200
225
|
#ifdef DATAFILTER_DOUBLE
|
|
201
226
|
dataFilter_setValue(
|
|
202
|
-
filterValues -
|
|
203
|
-
filterValues -
|
|
227
|
+
filterValues - dataFilter.min64High + filterValues64Low,
|
|
228
|
+
filterValues - dataFilter.max64High + filterValues64Low
|
|
204
229
|
);
|
|
205
230
|
#else
|
|
206
231
|
dataFilter_setValue(filterValues, filterValues);
|
|
@@ -213,38 +238,73 @@ const inject = {
|
|
|
213
238
|
}
|
|
214
239
|
`,
|
|
215
240
|
|
|
216
|
-
'vs:#main-end': glsl`
|
|
241
|
+
'vs:#main-end': /* glsl */ `
|
|
217
242
|
if (dataFilter_value == 0.0) {
|
|
218
243
|
gl_Position = vec4(0.);
|
|
219
244
|
}
|
|
220
245
|
`,
|
|
221
246
|
|
|
222
|
-
'vs:DECKGL_FILTER_SIZE': glsl`
|
|
223
|
-
if (
|
|
247
|
+
'vs:DECKGL_FILTER_SIZE': /* glsl */ `
|
|
248
|
+
if (dataFilter.transformSize) {
|
|
224
249
|
size = size * dataFilter_value;
|
|
225
250
|
}
|
|
226
251
|
`,
|
|
227
252
|
|
|
228
|
-
'fs:DECKGL_FILTER_COLOR': glsl`
|
|
253
|
+
'fs:DECKGL_FILTER_COLOR': /* glsl */ `
|
|
229
254
|
if (dataFilter_value == 0.0) discard;
|
|
230
|
-
if (
|
|
255
|
+
if (dataFilter.transformColor) {
|
|
231
256
|
color.a *= dataFilter_value;
|
|
232
257
|
}
|
|
233
258
|
`
|
|
234
259
|
};
|
|
235
260
|
|
|
236
|
-
|
|
237
|
-
|
|
261
|
+
type UniformTypesFunc = (opts: DataFilterExtensionOptions) => any;
|
|
262
|
+
function uniformTypesFromOptions(opts: DataFilterExtensionOptions): any {
|
|
263
|
+
const {categorySize, filterSize, fp64} = opts;
|
|
264
|
+
const uniformTypes: Record<string, UniformFormat> = {
|
|
265
|
+
useSoftMargin: 'i32',
|
|
266
|
+
enabled: 'i32',
|
|
267
|
+
transformSize: 'i32',
|
|
268
|
+
transformColor: 'i32'
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
if (filterSize) {
|
|
272
|
+
const uniformFormat: UniformFormat = filterSize === 1 ? 'f32' : `vec${filterSize}<f32>`;
|
|
273
|
+
uniformTypes.min = uniformFormat;
|
|
274
|
+
uniformTypes.softMin = uniformFormat;
|
|
275
|
+
uniformTypes.softMax = uniformFormat;
|
|
276
|
+
uniformTypes.max = uniformFormat;
|
|
277
|
+
if (fp64) {
|
|
278
|
+
uniformTypes.min64High = uniformFormat;
|
|
279
|
+
uniformTypes.max64High = uniformFormat;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (categorySize) {
|
|
284
|
+
uniformTypes.categoryBitMask = 'vec4<i32>';
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return uniformTypes;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export const dataFilter: ShaderModule<DataFilterModuleProps> & {
|
|
291
|
+
uniformTypesFromOptions: UniformTypesFunc;
|
|
292
|
+
} = {
|
|
293
|
+
name: 'dataFilter',
|
|
238
294
|
vs,
|
|
239
295
|
fs,
|
|
240
296
|
inject,
|
|
241
|
-
getUniforms
|
|
297
|
+
getUniforms,
|
|
298
|
+
uniformTypesFromOptions
|
|
242
299
|
};
|
|
243
300
|
|
|
244
|
-
export const
|
|
245
|
-
|
|
301
|
+
export const dataFilter64: ShaderModule<DataFilterModuleProps> & {
|
|
302
|
+
uniformTypesFromOptions: UniformTypesFunc;
|
|
303
|
+
} = {
|
|
304
|
+
name: 'dataFilter',
|
|
246
305
|
vs,
|
|
247
306
|
fs,
|
|
248
307
|
inject,
|
|
249
|
-
getUniforms: getUniforms64
|
|
308
|
+
getUniforms: getUniforms64,
|
|
309
|
+
uniformTypesFromOptions
|
|
250
310
|
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import {LayerExtension} from '@deck.gl/core';
|
|
2
6
|
|
|
3
|
-
import {patternShaders} from './shader-module';
|
|
7
|
+
import {FillStyleModuleProps, patternShaders} from './shader-module';
|
|
4
8
|
|
|
5
9
|
import type {
|
|
6
10
|
Layer,
|
|
@@ -155,10 +159,14 @@ export default class FillStyleExtension extends LayerExtension<FillStyleExtensio
|
|
|
155
159
|
return;
|
|
156
160
|
}
|
|
157
161
|
|
|
158
|
-
const {fillPatternAtlas} = this.props;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
+
const {fillPatternAtlas, fillPatternEnabled, fillPatternMask} = this.props;
|
|
163
|
+
const fillProps: FillStyleModuleProps = {
|
|
164
|
+
project: params.shaderModuleProps.project,
|
|
165
|
+
fillPatternEnabled,
|
|
166
|
+
fillPatternMask,
|
|
167
|
+
fillPatternTexture: (fillPatternAtlas || this.state.emptyTexture) as Texture
|
|
168
|
+
};
|
|
169
|
+
this.setShaderModuleProps({fill: fillProps});
|
|
162
170
|
}
|
|
163
171
|
|
|
164
172
|
finalizeState(this: Layer<FillStyleExtensionProps>) {
|