Volume picking with vtkHardwareSelector
Picking is one of the most basic operations to interact with a 3D scene. The Visualization Toolkit (VTK) supports picking objects from a scene through different classes, each of which are used to select different entities (actors, cells, etc.). Traditionally, VTK’s volume mappers support picking through an instance external to the mapper itself called vtkVolumePicker which casts a ray into the volume and returns the point where the ray intersects an isosurface of a user specified opacity. This technique has certain limitations given that the picking class does not have enough information to correctly account for clipping, transfer functions and other parameters which define internally how the mapper renders, which reduces its overall reliability on the actual objects being picked.
In an earlier blog post the plan of extending vtkGPURayCastMapper (OpenGL2 backend) to make use of vtkHardwareSelector’s interface was discussed, this functionality is finally available as of VTK 7.1.0. The inherent flexibility of the glsl-based implementation of this mapper allows a seamless integration of the hardware selector, which allows consistent picking of objects in a scene regardless of whether these represent geometric or volumetric data. Providing picking support directly within the fragment shader of the volume mapper ensures high selection accuracy even in situations where a volume intermixes with geometry in seemingly cumbersome ways (Figure 1) or advanced features like clipping planes are enabled (what you see is what you pick).
Furthermore, this initial implementation supports a higher picking granularity than only the volume object itself (vtkProps). Given the readily available picking styles supported by vtkHardwareSelector (e.g. vtkAreaPicker), it is possible to select a specific set of voxels (Figures 2 and 3). Hardware volume picking has also been exposed to ParaView and will be available in release 5.2.
We would like to thank the National Institutes of Health for sponsoring this work under the grant NIH R01EB014955 “Accelerating Community-Driven Medical Innovation with VTK.”