← All demos

GPU picking with color ids

Each shape is rendered into an off-screen Framebuffer with its id encoded as a color. Move your pointer over the canvas — a one-pixel readback under the cursor identifies the shape with no CPU ray-casting and no scene graph.

id: 4 1×1 px readback
Under cursor: id 4 · 0.0 ms Framebuffer · readPixels

The id buffer re-renders only when the scene changes; picking is just readPixels(x, y, 1, 1) against it. The same pattern scales to thousands of objects — ids are cheap. API reference: Framebuffer readback.