Skip to content

Commit

Permalink
Fix filterIndices attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress committed Sep 26, 2024
1 parent a769749 commit 3daae3e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
13 changes: 9 additions & 4 deletions modules/extensions/src/data-filter/aggregator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Device, DeviceFeature, Framebuffer, RenderPipelineParameters} from '@luma.gl/core';
import {Model} from '@luma.gl/engine';
import {Model, ModelProps} from '@luma.gl/engine';

const AGGREGATE_VS = `\
#version 300 es
Expand All @@ -18,8 +18,7 @@ const float component = 1.0 / 255.0;
void main() {
#ifdef FLOAT_TARGET
// BUG: always 0 for some reason
// dataFilter_value *= float(filterIndices != filterPrevIndices);
dataFilter_value *= float(filterIndices != filterPrevIndices);
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
vColor = vec4(0.0, 0.0, 0.0, 1.0);
#else
Expand Down Expand Up @@ -84,7 +83,12 @@ export function getFramebuffer(device: Device, useFloatTarget: boolean): Framebu
}

// Increments the counter based on dataFilter_value
export function getModel(device: Device, shaderOptions: any, useFloatTarget: boolean): Model {
export function getModel(
device: Device,
bufferLayout: ModelProps['bufferLayout'],
shaderOptions: any,
useFloatTarget: boolean
): Model {
shaderOptions.defines.NON_INSTANCED_MODEL = 1;
if (useFloatTarget) {
shaderOptions.defines.FLOAT_TARGET = 1;
Expand All @@ -97,6 +101,7 @@ export function getModel(device: Device, shaderOptions: any, useFloatTarget: boo
topology: 'point-list',
vs: AGGREGATE_VS,
fs: AGGREGATE_FS,
bufferLayout,
...shaderOptions
});
}
Expand Down
10 changes: 5 additions & 5 deletions modules/extensions/src/data-filter/data-filter-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export default class DataFilterExtension extends LayerExtension<
// The vertex shader checks if a vertex has the same "index" as the previous vertex
// so that we only write one count cross multiple vertices of the same object
attributeManager.add({
filterIndices: {
filterVertexIndices: {
size: useFloatTarget ? 1 : 2,
vertexOffset: 1,
type: 'unorm8',
Expand All @@ -227,10 +227,10 @@ export default class DataFilterExtension extends LayerExtension<
const filterFBO = aggregator.getFramebuffer(device, useFloatTarget);
const filterModel = aggregator.getModel(
device,
attributeManager.getBufferLayouts({isInstanced: false}),
extension.getShaders.call(this, extension),
useFloatTarget
);
filterModel.setBufferLayout(attributeManager.getBufferLayouts(filterModel));
this.setState({filterFBO, filterModel});
}
}
Expand Down Expand Up @@ -315,15 +315,15 @@ export default class DataFilterExtension extends LayerExtension<
if (filterNeedsUpdate && onFilteredItemsChange && filterModel) {
const attributeManager = this.getAttributeManager()!;
const {
attributes: {filterValues, filterCategoryValues, filterIndices}
attributes: {filterValues, filterCategoryValues, filterVertexIndices}
} = attributeManager;
filterModel.setVertexCount(this.getNumInstances());

// @ts-expect-error filterValue and filterIndices should always have buffer value
// @ts-expect-error filterValue and filterVertexIndices should always have buffer value
const attributes: Record<string, Buffer> = {
...filterValues?.getValue(),
...filterCategoryValues?.getValue(),
...filterIndices?.getValue()
...filterVertexIndices?.getValue()
};
filterModel.setAttributes(attributes);
filterModel.shaderInputs.setProps({
Expand Down

0 comments on commit 3daae3e

Please sign in to comment.