Skip to main content

Gaussian splat picking and scenes

GPU picking​

SplatPicker renders a dedicated semantic-aware picking pass while borrowing the renderer's existing source batches, visibility state, and sorted GPU draw runs:

import {SplatPicker} from '@luma.gl/engine/splats';

const picker = new SplatPicker(renderer, {
mode: 'auto',
onPick: info => {
console.log(info.rowIndex, info.batchIndex, info.batchRowIndex, info.semanticId);
}
});

const pickedSplat = await picker.pick([pointerX, pointerY]);
await picker.pick([pointerX, pointerY], {force: true});

picker.destroy();

WebGPU and compatible WebGL devices use integer picking attachments; other WebGL devices fall back to RGBA color picking. Results report the original source batch, stable global row, batch-local row, and optional semantic identifier. Stable global rows range from zero through 2,147,483,647; WebGL color picking internally remaps larger-than-24-bit row identities without changing the original source indices. Destroy the picker before destroying the borrowing renderer or its caller-owned source batches.

For a WebGPU command graph, use GPUSplatGraphPicker instead:

import {GPUSplatGraphPicker} from '@luma.gl/engine/splats';

const graphPicker = new GPUSplatGraphPicker(graphRenderer, {
onPick: info => console.log(info.rowIndex, info.batchIndex, info.semanticId)
});

const selected = await graphPicker.pick([pointerX, pointerY]);
graphPicker.destroy();

The graph picker borrows the existing projected records, globally sorted indices, uniforms, and GPU-counted indirect command. It performs one integer-attachment draw and explicit asynchronous pixel readback without walking, copying, or repacking source batches.

Mixed mesh and splat scenes​

Use an existing render pass to draw opaque meshes, depth-tested Gaussian splats, and transparent mesh overlays against the same depth attachment:

renderer.drawMixed(renderPass, {
opaqueMeshes: [terrainModel, buildingModel],
transparentMeshes: [selectionOverlay]
});

Opaque meshes are drawn first, splats are composited in their selected depth order, and transparent meshes are drawn last. Set depthCompare for reversed-depth scenes and enable depthWriteEnabled only when the application explicitly needs splat depth writes.

GPUSplatGraphMixedRenderer provides the equivalent WebGPU graph composition against a caller-owned color/depth pass:

const composition = new GPUSplatGraphMixedRenderer(graphRenderer, {
depthCompare: 'less-equal'
});

using frame = new GPUGraphFrame(device.createCommandEncoder());
composition.predraw(frame);
const renderPass = frame.commandEncoder.beginRenderPass({framebuffer, clearDepth: 1});
composition.draw(renderPass, {opaqueMeshes, transparentMeshes});
renderPass.end();
frame.submit();

Mixed rendering and picking share one prepared result. The first consumer after a camera or data change records the compute work. Each consumer draws into its own target, so picking alone leaves the canvas untouched.

Use graphRenderer.getPreparedDraw() after prepare() to bind those same projected records, sorted IDs, and uniforms from your own pass. The result also includes the indirect draw commands and the source batches used to resolve picked IDs.

graphRenderer.prepare(frame);
const prepared = graphRenderer.getPreparedDraw();
if (prepared) {
const renderPass = frame.commandEncoder.beginRenderPass({framebuffer, clearDepth: 1});
renderPass.setPipeline(splatPipeline);
renderPass.setVertexArray(splatVertexArray);
renderPass.setBindings(prepared.bindings);
prepared.drawCommands.draw(renderPass, 0);
renderPass.end();
}

When using a GPUGraphFrame, prepare once and keep all consumers on its encoder. The renderer restores the last prepared result on discard if its allocations survived. Reacquire the result after every preparation or renderer change.