Hi all,
I've open sourced some libraries for real-time OpenGL preview of OpenVDB grids using voxel ray-marching. I've only tested on Windows, but everything should be cross-platform. License is MIT.
https://github.com/matthew-reid/GraphtaneThere's a video here:http://vimeo.com/mreid/graphtane
The basic approach is:
- flatten VDB grid into 2 levels; deepest internal node level and leaf level
- pack leaf node data into texture atlases
- build indirection map of leaf index -> texture atlas coordinates
- create renderable box volume for each internal node
- if transparent sorting is disabled, batch boxes into fewer draw calls
- if transparent sorting is enabled, sort boxes
- render boxes with ray-marching shader
Current limitations:
- Flattening the grid to 2 levels may result in a large number of draw calls for extremely large grids. This could be overcome by supporting more levels of node indirection.
- Shader does not support adaptive sampling. I think this would improve performance, but it's not critical because most of the empty space in the grid is already 'culled' by virtue of only rendering the deepest internal nodes. If more levels are supported in the future, adaptive sampling may become necessary.
- The limitation of max hardware texture size can lead to many atlases being required. Due to lack of hardware support for 3D texture arrays, this may result in many draw calls. One could potentially get around this by using TBOs or 2D texture arrays and implementing manual trilinear filtering.
- The flattening step does not take tiles into account, so tile nodes will not be rendered unless they are first voxelized with openvdb::tree::Tree::voxelizeActiveTiles()
Please let me know if you find this useful, or if you have any questions or feedback about my approach.