Selection
Rough Draft
This page describes alternative approaches to "low-level" interactive selection of geometry - i.e. identification of element IDs given user input. "High-level" selection policy (e.g. whether to select or deselect, which key-combinations lead to which type of selection, etc) is not covered here.
Terminology
- Pick Selection - selection of individual cells. Typically, this picks the cell "closest" to the camera.
- Rubber-Band Selection - selection of groups of cells that fall within a rectangular region defined by the user in screen space. Typically, all cells within the rubber-band are selected, regardless of their depth.
- Lasso Selection - selection of groups of cells that fall within an arbitrary-shaped region defined by the user in screen space. Typically, all cells within the lasso are selected, regardless of their depth.
Pure Geometry
Using the purely-geometric approach, cells are tested for intersection with different geometric types to build a collection of "candidate" cells. For pick selection, cells can be tested for intersection with a single ray that starts at the camera origin. For rubber-band selection, cells can be tested for intersection with a frustum. For lasso selection, cells are tested for intersection with an arbitrary volume, defined by a collection of rays that start at the camera origin. Each of these cases may return zero-to-many cells that intersect. For the picking case, the intersecting cells are depth-sorted and the cell with the smallest Z-value is selected.
Pros: The most flexible of all the methods covered, supports all selection types.
Cons: Doesn't take advantage of graphics hardware.
G Buffer
In the geometry-buffer approach, all cells are rendered off-screen with lighting and transparency disabled. The Z-buffer is enabled normally. For each cell, the cell ID is encoded as a color which is used to render the cell. A mask can be used to limit rendering to an "area-of-interest", i.e. a single pixel (picking), a rectangle (rubber-band) or an arbitrary shape (lasso). Once rendering is complete, the buffer will contain an image where each pixel contains the cell ID (color) of the closest cell. After reading the buffer contents for the area-of-interest, the colors are "decoded" back into cell IDs to form the set of selected cells.
Pros: Takes advantage of graphics hardware. Is capable of supporting all selection types.
Cons: The number of cell IDs is limited by the depth of the off-screen buffer, possibly as-low-as (2^16)-1 cell IDs, depending on hardware. Because the buffer can only "store" one cell ID per pixel, selections always contain only the closest cells, never a volume.
OpenGL Selection
Pros:
Cons: