Picking objects created from geometry shader


I’ve been using VTK to construct a network visualizer in Python. We are using geometry shaders to convert the lines to shaded 3D tubes and fake spheres technique to draw vertices (a fake sphere is generated in the fragment shader which is drawn on top of a quad facing the camera). The rendering works fine, but we couldn’t find any picker that seems to be working correctly. These networks can be huge, so we made all lines belonging to the same actor and the same is true for the geometry of nodes, belonging to another actor. So, for picking, we need to know the vertex ID or the face ID to recover which edge (line) or node (quad) was selected.

The problem is that none of the hardware-based vtk pickers seem to work properly in this case. We tried scenePicker but it is too verbose (no way to disable internal printing), there are visual glitches in the rendering when enabled, and it is non-reliable sometimes as it gives us wrong vertex ids. We also tried vtkHardwareSelector. However, it does not seem to be complete in Python as many of the methods in the documentation are not exposed by the wrapper. We also found it very difficult to find documentation or working examples of how to use these pickers properly.

Normally, in OpenGL, for picking in complex rendering pipelines, we create an offscreen rendering of the same geometry around the position of the cursor and then change the fragment shader to draw the object id or 3d position encoded to RGB to that framebuffer, instead of the real color. We then get the RGB data (or int32 in supported hardware) and decode it back to the object id.

Please, do any of you know if there is any documentation or examples of this technique, or maybe using VTK own functions to attain similar results? Is there any recommended approach for picking in such a kind of pipeline in VTK?

We are testing this in vtk 8.1.2 and vtk 9.0.1.