#include <vtkOpenGLHAVSVolumeMapper.h>
vtkHAVSVolumeMapper is a class that renders polygonal data (represented as an unstructured grid) using the Hardware-Assisted Visibility Sorting (HAVS) algorithm. First the unique triangles are sorted in object space, then they are sorted in image space using a fixed size A-buffer implemented on the GPU called the k-buffer. The HAVS algorithm excels at rendering large datasets quickly. The trade-off is that the algorithm may produce some rendering artifacts due to an insufficient k size (currently 2 or 6 is supported) or read/write race conditions.
A built in level-of-detail (LOD) approach samples the geometry using one of two heuristics (field or area). If LOD is enabled, the amount of geometry that is sampled and rendered changes dynamically to stay within the target frame rate. The field sampling method generally works best for datasets with cell sizes that don't vary much in size. On the contrary, the area sampling approach gives better approximations when the volume has a lot of variation in cell size.
The HAVS algorithm uses several advanced features on graphics hardware. The k-buffer sorting network is implemented using framebuffer objects (FBOs) with multiple render targets (MRTs). Therefore, only cards that support these features can run the algorithm (at least an ATI 9500 or an NVidia NV40 (6600)).
The HAVS algorithm operates on the triangles that compose the mesh. Therefore, before rendering, the cells are decomposed into unique triangles and stored on the GPU for efficient rendering. The use of GPU data structures is only recommended if the entire geometry can fit in graphics memory. Otherwise this feature should be disabled.
Another new feature is the handling of mixed data types (eg., polygonal data with volume data). This is handled by reading the z-buffer from the current window and copying it into the framebuffer object for off-screen rendering. The depth test is then enabled so that the volume only appears over the opaque geometry. Finally, the results of the off-screen rendering are blended into the framebuffer as a transparent, view-aligned texture.
Instead of using a preintegrated 3D lookup table for storing the ray integral, this implementation uses partial pre-integration. This improves the performance of dynamic transfer function updates by avoiding a costly preprocess of the table.
A final change to the original algorithm is the handling of non-convexities in the mesh. Due to read/write hazards that may create undesired artifacts with non-convexities when using a inside/outside toggle in the fragment program, another approach was employed. To handle non-convexities, the fragment shader determines if a ray-gap is larger than the max cell size and kill the fragment if so. This approximation performs rather well in practice but may miss small non-convexities.
For more information on the HAVS algorithm see:
"Hardware-Assisted Visibility Sorting for Unstructured Volume Rendering" by S. P. Callahan, M. Ikits, J. L. D. Comba, and C. T. Silva, IEEE Transactions of Visualization and Computer Graphics; May/June 2005.
For more information on the Level-of-Detail algorithm, see:
"Interactive Rendering of Large Unstructured Grids Using Dynamic Level-of-Detail" by S. P. Callahan, J. L. D. Comba, P. Shirley, and C. T. Silva, Proceedings of IEEE Visualization '05, Oct. 2005.
Definition at line 127 of file vtkOpenGLHAVSVolumeMapper.h.
Public Types | |
typedef vtkHAVSVolumeMapper | Superclass |
Public Member Functions | |
virtual const char * | GetClassName () |
virtual int | IsA (const char *type) |
virtual void | PrintSelf (ostream &os, vtkIndent indent) |
virtual void | Render (vtkRenderer *ren, vtkVolume *vol) |
virtual void | ReleaseGraphicsResources (vtkWindow *) |
virtual void | SetGPUDataStructures (bool) |
virtual bool | SupportedByHardware (vtkRenderer *r) |
Static Public Member Functions | |
static vtkOpenGLHAVSVolumeMapper * | New () |
static int | IsTypeOf (const char *type) |
static vtkOpenGLHAVSVolumeMapper * | SafeDownCast (vtkObject *o) |
Protected Member Functions | |
vtkOpenGLHAVSVolumeMapper () | |
~vtkOpenGLHAVSVolumeMapper () | |
virtual int | FillInputPortInformation (int port, vtkInformation *info) |
virtual void | Initialize (vtkRenderer *ren, vtkVolume *vol) |
virtual void | InitializeLookupTables (vtkVolume *vol) |
void | InitializeGPUDataStructures () |
void | InitializeShaders () |
void | DeleteShaders () |
void | InitializeFramebufferObject () |
void | RenderHAVS (vtkRenderer *ren) |
void | SetupFBOZBuffer (int screenWidth, int screenHeight, float depthNear, float depthFar, float *zbuffer) |
void | SetupFBOMRT () |
void | DrawFBOInit (int screenWidth, int screenHeight, float depthNear, float depthFar) |
void | DrawFBOGeometry () |
void | DrawFBOFlush (int screenWidth, int screenHeight, float depthNear, float depthFar) |
void | DrawBlend (int screenWidth, int screenHeight, float depthNear, float depthFar) |
void | CheckOpenGLError (const char *str) |
Protected Attributes | |
unsigned int | VBOVertexName |
unsigned int | VBOTexCoordName |
unsigned int | VBOVertexIndexName |
unsigned int | VertexProgram |
unsigned int | FragmentProgramBegin |
unsigned int | FragmentProgram |
unsigned int | FragmentProgramEnd |
unsigned int | FramebufferObject |
int | FramebufferObjectSize |
unsigned int | FramebufferTextures [4] |
unsigned int | DepthTexture |
unsigned int | PsiTableTexture |
unsigned int | TransferFunctionTexture |
vtkWeakPointer< vtkRenderWindow > | RenderWindow |
vtkOpenGLHAVSVolumeMapper::vtkOpenGLHAVSVolumeMapper | ( | ) | [protected] |
vtkOpenGLHAVSVolumeMapper::~vtkOpenGLHAVSVolumeMapper | ( | ) | [protected] |
static vtkOpenGLHAVSVolumeMapper* vtkOpenGLHAVSVolumeMapper::New | ( | ) | [static] |
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
Reimplemented from vtkHAVSVolumeMapper.
virtual const char* vtkOpenGLHAVSVolumeMapper::GetClassName | ( | ) | [virtual] |
Reimplemented from vtkHAVSVolumeMapper.
static int vtkOpenGLHAVSVolumeMapper::IsTypeOf | ( | const char * | name | ) | [static] |
Return 1 if this class type is the same type of (or a subclass of) the named class. Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.
Reimplemented from vtkHAVSVolumeMapper.
virtual int vtkOpenGLHAVSVolumeMapper::IsA | ( | const char * | name | ) | [virtual] |
Return 1 if this class is the same type of (or a subclass of) the named class. Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.
Reimplemented from vtkHAVSVolumeMapper.
static vtkOpenGLHAVSVolumeMapper* vtkOpenGLHAVSVolumeMapper::SafeDownCast | ( | vtkObject * | o | ) | [static] |
Reimplemented from vtkHAVSVolumeMapper.
virtual void vtkOpenGLHAVSVolumeMapper::PrintSelf | ( | ostream & | os, | |
vtkIndent | indent | |||
) | [virtual] |
Methods invoked by print to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.
Reimplemented from vtkHAVSVolumeMapper.
virtual void vtkOpenGLHAVSVolumeMapper::Render | ( | vtkRenderer * | ren, | |
vtkVolume * | vol | |||
) | [virtual] |
Render the volume
Implements vtkUnstructuredGridVolumeMapper.
virtual void vtkOpenGLHAVSVolumeMapper::ReleaseGraphicsResources | ( | vtkWindow * | ) | [virtual] |
Release any graphics resources that are being consumed by this volume renderer.
Reimplemented from vtkUnstructuredGridVolumeMapper.
virtual void vtkOpenGLHAVSVolumeMapper::SetGPUDataStructures | ( | bool | ) | [virtual] |
Set/get whether or not the data structures should be stored on the GPU for better peformance.
Implements vtkHAVSVolumeMapper.
virtual bool vtkOpenGLHAVSVolumeMapper::SupportedByHardware | ( | vtkRenderer * | r | ) | [virtual] |
Check hardware support for the HAVS algorithm. Necessary features include off-screen rendering, 32-bit fp textures, multiple render targets, and framebuffer objects. Subclasses must override this method to indicate if supported by Hardware.
virtual int vtkOpenGLHAVSVolumeMapper::FillInputPortInformation | ( | int | port, | |
vtkInformation * | info | |||
) | [protected, virtual] |
Fill the input port information objects for this algorithm. This is invoked by the first call to GetInputPortInformation for each port so subclasses can specify what they can handle.
Reimplemented from vtkUnstructuredGridVolumeMapper.
virtual void vtkOpenGLHAVSVolumeMapper::Initialize | ( | vtkRenderer * | ren, | |
vtkVolume * | vol | |||
) | [protected, virtual] |
Implements vtkHAVSVolumeMapper.
virtual void vtkOpenGLHAVSVolumeMapper::InitializeLookupTables | ( | vtkVolume * | vol | ) | [protected, virtual] |
Reimplemented from vtkHAVSVolumeMapper.
void vtkOpenGLHAVSVolumeMapper::InitializeGPUDataStructures | ( | ) | [protected] |
void vtkOpenGLHAVSVolumeMapper::InitializeShaders | ( | ) | [protected] |
void vtkOpenGLHAVSVolumeMapper::DeleteShaders | ( | ) | [protected] |
void vtkOpenGLHAVSVolumeMapper::InitializeFramebufferObject | ( | ) | [protected] |
void vtkOpenGLHAVSVolumeMapper::RenderHAVS | ( | vtkRenderer * | ren | ) | [protected] |
void vtkOpenGLHAVSVolumeMapper::SetupFBOZBuffer | ( | int | screenWidth, | |
int | screenHeight, | |||
float | depthNear, | |||
float | depthFar, | |||
float * | zbuffer | |||
) | [protected] |
void vtkOpenGLHAVSVolumeMapper::SetupFBOMRT | ( | ) | [protected] |
void vtkOpenGLHAVSVolumeMapper::DrawFBOInit | ( | int | screenWidth, | |
int | screenHeight, | |||
float | depthNear, | |||
float | depthFar | |||
) | [protected] |
void vtkOpenGLHAVSVolumeMapper::DrawFBOGeometry | ( | ) | [protected] |
void vtkOpenGLHAVSVolumeMapper::DrawFBOFlush | ( | int | screenWidth, | |
int | screenHeight, | |||
float | depthNear, | |||
float | depthFar | |||
) | [protected] |
void vtkOpenGLHAVSVolumeMapper::DrawBlend | ( | int | screenWidth, | |
int | screenHeight, | |||
float | depthNear, | |||
float | depthFar | |||
) | [protected] |
void vtkOpenGLHAVSVolumeMapper::CheckOpenGLError | ( | const char * | str | ) | [protected] |
unsigned int vtkOpenGLHAVSVolumeMapper::VBOVertexName [protected] |
Definition at line 179 of file vtkOpenGLHAVSVolumeMapper.h.
unsigned int vtkOpenGLHAVSVolumeMapper::VBOTexCoordName [protected] |
Definition at line 180 of file vtkOpenGLHAVSVolumeMapper.h.
unsigned int vtkOpenGLHAVSVolumeMapper::VBOVertexIndexName [protected] |
Definition at line 181 of file vtkOpenGLHAVSVolumeMapper.h.
unsigned int vtkOpenGLHAVSVolumeMapper::VertexProgram [protected] |
Definition at line 182 of file vtkOpenGLHAVSVolumeMapper.h.
unsigned int vtkOpenGLHAVSVolumeMapper::FragmentProgramBegin [protected] |
Definition at line 183 of file vtkOpenGLHAVSVolumeMapper.h.
unsigned int vtkOpenGLHAVSVolumeMapper::FragmentProgram [protected] |
Definition at line 184 of file vtkOpenGLHAVSVolumeMapper.h.
unsigned int vtkOpenGLHAVSVolumeMapper::FragmentProgramEnd [protected] |
Definition at line 185 of file vtkOpenGLHAVSVolumeMapper.h.
unsigned int vtkOpenGLHAVSVolumeMapper::FramebufferObject [protected] |
Definition at line 186 of file vtkOpenGLHAVSVolumeMapper.h.
int vtkOpenGLHAVSVolumeMapper::FramebufferObjectSize [protected] |
Definition at line 187 of file vtkOpenGLHAVSVolumeMapper.h.
unsigned int vtkOpenGLHAVSVolumeMapper::FramebufferTextures[4] [protected] |
Definition at line 188 of file vtkOpenGLHAVSVolumeMapper.h.
unsigned int vtkOpenGLHAVSVolumeMapper::DepthTexture [protected] |
Definition at line 189 of file vtkOpenGLHAVSVolumeMapper.h.
unsigned int vtkOpenGLHAVSVolumeMapper::PsiTableTexture [protected] |
Definition at line 192 of file vtkOpenGLHAVSVolumeMapper.h.
unsigned int vtkOpenGLHAVSVolumeMapper::TransferFunctionTexture [protected] |
Definition at line 193 of file vtkOpenGLHAVSVolumeMapper.h.
Definition at line 195 of file vtkOpenGLHAVSVolumeMapper.h.