filterPlugin
import {filterPlugin} from '@luma.gl/shaders/plugins';
filterPlugin tests one value per row against an inclusive range.
FILTER_POSITIONis the vertex shader target the host registers and calls.filterValuesis the scalar column. Supply onefloat32value per row through thefilterValuesvertex input.
The plugin attaches a filter shader module with enabled, min, and max props. Defaults are {enabled: true, min: 0, max: 1}.
Compatible base shaders register and call the position target:
shaderAssembler.addShaderInjectionTarget({name: 'FILTER_POSITION', stage: 'vertex', glsl: {parameters: 'inout vec4 position'}}); // GLSL
shaderAssembler.addShaderInjectionTarget({name: 'FILTER_POSITION', stage: 'vertex', wgsl: {parameters: 'position: ptr<function, vec4<f32>>'}}); // WGSL
- GLSL
- WGSL
FILTER_POSITION(gl_Position);
FILTER_POSITION(&outputs.position);
The caller supplies the data and updates only shader inputs when the range changes:
const model = new Model(device, {
plugins: [filterPlugin],
shaderAssembler,
bufferLayout: [{name: 'filterValues', format: 'float32', stepMode: 'instance'}],
attributes: {filterValues: filterValueBuffer}
});
model.shaderInputs.setProps({filter: {enabled: true, min: 0.2, max: 0.8}});
Rejected vertices are moved outside clip space. This first version does not support category filters, filtered-row counts, fp64 values, or storage-buffer inputs.