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.
Current version is 1.0.1.
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.
HPMC requires:
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:
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:
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.
HistoPyramids are used and discussed in the following papers:
Published December 10, 2009
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).