Heterogeneous Computing

Marching Cubes using Histogram Pyramids
HPMC is a small OpenGL/C/C++-library that extractes iso-surfaces of volumetric data directly on the GPU.

HPMC is an implementation of the method described in

C. Dyken, G. Ziegler, C. Theobalt, H.-P. Seidel,
High-speed Marching Cubes using Histogram Pyramids,
Computer Graphics Forum 27 (8), 2008.

The library analyzes a lattice of scalar values describing a scalar field that is either stored in a Texture3D or can be accessed through an application-provided snippet of shader code. The output is a sequence of vertex positions and normals that form a triangulation of the iso-surface. HPMC provides traversal code to be included in an application vertex shader, which allows direct extraction in the vertex shader. Using the OpenGL transform feedback mechanism, the triangulation can be stored directly into a buffer object.  

News

  • 2009-12-01: Version 1.0.1 released.
    Fixes some Mac-specific issues.
  • 2009-11-29: Version 1.0 released.
    First public release.

Downloads

Current version is 1.0.1.

License

This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License ("GPL") version 2 as published by the Free Software Foundation. See the file LICENSE.GPL at the root directory of the source distribution for additional information about the GNU GPL.

For using HPMC with software that can not be combined with the GNU GPL, please contact SINTEF for aquiring a commercial license and support. 

System requirements

HPMC requires:

  • a C++ compiler,
  • CMake, unless you use the MSVC9 solution,
  • GLEW, preferably at least version 1.5.1, as 1.5.0 lacks the GL_EXT_transform_feedback extension needed to do transform feedback on ATI cards,
  • FreeGLUT or GLUT , for building the examples, and
  • latest display drivers.

HPMC should run on any OpenGL 2.0-compatible GPU with the GL_ARB_texture_float extension that allows texturing from a mip-map'ed GL_ALPHA32F_ARB Texture2D in the vertex shader. Using texture based scalar field lattices requires texturing from a Texture3D in the vertex shader. Using the transform feedback mechanism requires OpenGL 3.0 or the GL_NV_transform_feedback or the GL_EXT_transform_feedback extensions to be available.

In particular, HPMC has been tested and verified to work the following system configurations:

  • Gentoo linux-2.6.30, GeForce GTX 260, NVIDIA Display Driver 190.18.05.
  • Gentoo linux-2.6.30, GeForce 8400M GS,NVIDA Display Driver 190.42
  • Gentoo linux-2.6.30, FireStream 9250, ATI Catalyst 9.10,  
  • Gentoo linux-2.6.30, GeForce 6600 GT, NVIDA Display Driver 190.42.
    Note: Transform_feedback and particles not running, as transform_feedback is not supported by card. Texturing from Texture3D is slow, proably due to lack of hardware support. G80 emulation (Cheetah renderer string) does not work.
  • Gentoo linux-2.6.31 AMD64, GTX 260, NVIDIA Display Driver 195.17
  • Ubuntu 9.10 linux-2.6.31-15 x86_64, GeForce GTX 275, NVIDIA Display Driver 185.18.36. 
  • Ubuntu 8.04.3 LTS, linux-2.6.25-25-generic x86_64, GeForce 8600 GT, NVIDIA Display Driver 173.14.12.
    Note: Old GLEW 1.5.0.
  • Windows 7 x64, Radeon HD 4870 X2, AMD Catalyst 9.11, 32-bit build.
    Note: particles do not run as only the pipeline for GL_NV_transform_feedback is implemented in the sample.
  • Windows Vista, GeForce 8400M GS, NVIDIA Display Driver 190.38, MSVC9
  • Windows Vista, GeForce 260 GTX, NVIDIA Display Driver 185.85, MSVC9
  • Windows XP SP2, FireStream 9250, AMD Catalyst 9.11, MSVC8 2005
    Note: particles do not run as only the pipeline for GL_NV_transform_feedback is implemented in the sample.
  • Windows XP SP2, GeForce 8800 GT, NVIDIA Display Driver 195.62, Visual Studio 2005.
  • MacOS X 10.6.2, GeForce 9400M, Display Driver 1.6.6, i686-apple-darwin10-gcc-4.2.1
    Note: particles do not run as GL_NV_transform_feedback seems to be missing.

Sample applications

The HPMC distribution currently contains five sample applications:

Extracting iso-surfaces from an existing voxel set (texture3D.cpp)
This example demonstrates the most basic use of HPMC, providing the scalar field as a 3D texture. The example gets volume dimensions and a file name of a 8-bit raw dataset from the command line, reads the data into a 3D texture and passes this texture to HPMC. For each frame, a time-dependent iso-value is calculated, passed to HPMC which analyzes the scalar field using this iso-value. Then, HPMC renders the corresponding iso-surface. Wireframe rendering is done straight-forwardly by rendering the surface twice (traversing the HistoPyramid both times), one time with solid triangles in a dark color offset slightly away from the camera, and the second time using the line-drawing polygon mode to render the actual wireframe in white.


Extracting iso-surfaces from a scalar field defined using shader code (cayley.cpp)
This example is similar to the texture3d example. The difference is that instead of fetching scalar values from a texture 3d, the scalar value is fetched from an application provided shader function, which in this example evaluates the algebraic surface defined by 1 - 16xyz -4x^2 - 4y^2 - 4z^2 = iso. The application also provides the gradient field for this function, which is used instead of forward differences to determine surface normals.

For each frame, a time-dependent iso-value is calculated, passed to HPMC which analyzes the scalar field using this iso-value. Then, HPMC renders the corresponding iso-surface. Wireframe rendering is done straight-forwardly by rendering the surface twice (traversing the HistoPyramid both times), one time with solid triangles in a dark color offset slightly away from the camera, and the second time using the line-drawing polygon mode to render the actual wireframe in white.


Metaballs (metaballs.cpp)
This example demonstrates the use of a custom fetch function and how the application can get hold of program names to update uniform variables. In principle, the fetch calculates the distance field defined by eight metaballs, whose position is provided through uniform variables. To make the example more interesting, the domain is twisted time-dependently along the z- and y-axes.


Basic use of transform feedback (tranform_feedback.cpp)
Extracting iso-surfaces from a scalar field defined in terms shader code, and use transform feedback to capture geometry for wireframe rendering. This example is basically the same as cayley, the main difference is that instead of traversing the HistoPyramid twice when rendering wireframe, transform feedback is used to capture the geometry in the flat shading pass, and the result of this is rendered again using plain OpenGL to produce the line rendering.

The actual surface is an algebraic surface defined by 1 - 16xyz -4x^2 - 4y^2 - 4z^2 = iso. The application also provides the gradient field for this function, which is used instead of forward differences to determine surface normals.


Morphing algebraic shapes that emits particles (particles.cpp)
This example demonstrates using the surface generated by HPMC as input to a geometry shader that emits particles randomly over the surface. The particles are pulled by gravity, and uses the scalar field passed to HPMC to determine when particles hit the surface, and in this case, they bounce. To test if a particle hits the surface is done by evaluating the sign of the scalar field at the position of the particle at the beginning of the timestep and at the end. This approach is a bit too simple for these shapes, as they usually have a great deal of regions with multiple zeros, and this leads to the artefact of particles falling through the surface at some places.

The following render loop is used:

  • Use HPMC to determine the iso-surface of the current scalar field
  • Render the iso surface, but tap vertex position and normals into a transform feedback buffer.
  • Pass this buffer into a geometry shader that emits particles (points) at some of the triangles, output stored in another transform feedback buffer.
  • Pass the particles from the previous frame into a geometry shader that does a series of Euler-steps to integrate velocity and position, checking for collisions in-between. The output of this pass is concatenated at the end of the newly created particles using transform feedback.
  • Render the particles using a geometry shader that expands the point positions into quadrilateral screen-aligned billboards. 

Roadmap

  • Direct support for scalar field lattice in a tiled Texture2D (aka Flat3D).
  • Fetch from packed Texture3D. Here, four z-slices are packed in the RGBA-channels; this is useful when building the 3D texture on GPU quartering the number of rendering passes.
  • Extraction into Texture2D. This allows capture of geometry on GPUs that does not support transform feedback. This is mainly of interest to older hardware, if you need it, please contact the author.
  • Your suggestions.

Helping out

The best way of helping out is to use HPMC. Bug reports and patches are always welcome; If you have trouble with HPMC on a system configuration that should be able to run it, please contact the author. Also, if you find this software useful, sending the author an email stating this is an excellent motivation for continuing the development.

Further references

HistoPyramids are used and discussed in the following papers:

C. Dyken, M. Reimers, J. Seland,
Semi-uniform Adaptive Patch Tessellation,
Computer Graphics Forum, to appear
.
 
C. Dyken, M. Reimers, J. Seland,
Real-Time GPU Silhouette Refinement using adaptively blended Bezier Patches,
Computer Graphics Forum 27 (1), 2008, pp. 1-12
.
 
I. Ihrke, G. Ziegler, A. Tevs, C. Theobalt, M. Magnor, H.-P. Seidel,
Eikonal Rendering: Efficient Light Transport in Refractive Objects,
ACM Transactions on Graphics (Proc. ACM SIGGRAPH) 26 (3): 59-1 - 59-8, 2007
 
G. Ziegler, R. Dimitrov, C. Theobalt, H.-P. Seidel,
Real-time Quadtree Analysis using HistoPyramids,
In: Real-Time Image Processing 2007, San Jose, USA, 2007, 1-11
 
G. Ziegler, A. Tevs, C. Theobalt, H.-P. Seidel,
On-the-fly Point Clouds through Histogram Pyramids,
In: 11th International Fall Workshop on Vision, Modeling and Visualization 2006 (VMV2006), Aachen, Germany, 2006, 137-144

Published December 10, 2009

SINTEF logo

Christopher Dyken

Thanks to Gernot Ziegler, Jon Mikkelsen Hjelmervik, Johan Seland, Bård Skaflestad, Erik W.Bjønnes, Jens-Olav Nygaard, Martin Reimers, Trond Runar Hagen, and Greg Ruthenbeck for help and testing.

Thanks to NVIDIA and AMD for hardware donations.

This work is sponsored by the Research Council of Norway project number 180023 (Parallel3D).