Openvdb Introduction
Openvdb Introduction
Schedule
Part 1 - 2:00pm Introduction to OpenVDB, Ken Museth (DWA) - 2:45pm Overview of toolset, Mihai Alden (DWA) - 3:15pm Break Part 2
SIGGRAPH2013
OpenVDB
- 3:30pm Adoption at DreamWorks Animation, Jeff Budsberg (DWA) - 4:00pm Adoption at Digital Domain, John Johansson (DD) - 4:30pm Adoption in Houdini, Edward Lam (SideFX Software) - 5:00pm Concluding remarks and questions, Ken Museth (DWA)
2
Course Material
SIGGRAPH2013
OpenVDB
Main site: http://www.openvdb.org - Course slides and hip les - Coding cookbook - FAQ - Google group: OpenVDB Forum Technical paper on VDB (http://ken.museth.org)
3
History of VDB
2000
2001
SIGGRAPH2013
OpenVDB
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
Motivating VDB
SIGGRAPH2013
OpenVDB
Consider extremes
- DT-Grid / H-RLE (level sets only) - DB-Grid (doesnt scale and non-hierarchical) - Octrees (slow tree traversal)
Facts
DWA feature lms using VDB - Puss in Boots, Rise of the Guardians, The Croods, Turbo OpenVDB developers - K. Museth, P. Cucka, M. Aldn and D. Hill Availability - http://www.openvdb.org - https://github.com/dreamworksanimation/openvdb_dev License - Mozilla Public License version 2 and CLA
SIGGRAPH2013
OpenVDB
Library Versioning
Patch: Minor:
major.minor.patch
SIGGRAPH2013
OpenVDB
- No change to API, le format or ABI of Grid or its member classes - Change to API but not Grid ABI; backward-compatible le format Major: - Change to ABI of Grid or non-backward-compatible le format No release guarantees complete ABI compatibility! - Library is namespaced on the complete version number
7
SideEffects Houdini
SIGGRAPH2013
OpenVDB
Commercial Renderers
SIGGRAPH2013
OpenVDB
SideFX Mantra
Terminology
Voxel
- Smallest addressable unit of index space - Resides at the leaf node level
SIGGRAPH2013
OpenVDB
Tile
- Larger constant domain of index space - Resides at the upper (non-leaf) tree levels
Active state
- All values (voxels and tiles) have a binary state - Interpretation of state is application-dened
10
SIGGRAPH2013
OpenVDB
Internal Node 1
Internal Node 2
Leaf Node
11
SIGGRAPH2013
OpenVDB
Grid
12
SIGGRAPH2013
OpenVDB
13
Grid Types
Fully compile-time congurable - Value type - Node size, Tree depth, e.g. tile-grid, Octree, N-tree etc.
typedef LeafNode<float,3> N0; typedef InternalNode<N0,4> N1; typedef InternalNode<N1,5> N2; typedef RootNode<N2> RootType;
SIGGRAPH2013
OpenVDB
SIGGRAPH2013
OpenVDB
Fog or density volumes - Scalar normalized density [01] - Background zero - Interior voxels have value 1 - Active tiles SDFs or narrow band level sets - Scalar truncated signed distance ] 2, 2[ - Background is the positive half-width of the narrow band ( 2 ) - Interior is the negative half-width of the narrow band ( 2 ) - No active tiles
15
SIGGRAPH2013
OpenVDB
16
SIGGRAPH2013
OpenVDB
InternalNodes: 10243 InternalNodes: 643 LeafNodes: 43 Voxels: 13 228 million sparse voxel vs 69 billion dense voxels
17
SIGGRAPH2013
OpenVDB
18
Morphological Operations
Opening Closing
SIGGRAPH2013
OpenVDB
erosion
dilation
dilation
erosion
19
math::Transform
Transforms Index Space (coordinates)
SIGGRAPH2013
OpenVDB
- Vec3d Transform::indexToWorld(const Vec3d& xyz) const; - Vec3d Transform::indexToWorld(const Coord& ijk) const; - Vec3d Transform::worldToIndex(const Vec3d& xyz) const;
Supports - Afne Transforms (mix of scaling, rotation, shearing, translation) - Frustum Transforms - Updates with pre and post semantics Wraps a minimal representation BaseMap - Virtual hit in calling BaseMap
20
SIGGRAPH2013
OpenVDB
Used in vector calculus operators (Gradient, Curl) in world space - Computes rst and second derivatives of the transform - Chain Rule-based logic implemented for various operators
21
Data Access
Sequential access - Fundamental to simulations - Access elements according to memory layout Random access - Coordinate-based access: getValue(x,y,z) - Spatial coherence Stencil access - Fundamental to nite differencing, ltering and interpolation - Often combined with sequential or random access
SIGGRAPH2013
OpenVDB
22
Iterators
Bit mask - Located in all nodes - Facilitates efcient iterators
Grid/Tree/NodeType::ValueOnIter Grid/Tree/NodeType::ValueOffIter Grid/Tree/NodeType::ValueAllIter
SIGGRAPH2013
OpenVDB
tree::LeafManager
Fundamental assumptions - Voxel processing only, so safe to ignore tiles - Static topology Linearize tree as an array of leaf nodes - Lightweight
SIGGRAPH2013
OpenVDB
- Very fast iteration and trivial split operator for multithreading Temporal value buffers for each leaf node - Solve time-dependent PDEs, ltering and convolution - Multithreaded swapping of buffers
24
tree::ValueAccessor
Random or coordinate-based access - Should never be truly random! - Virtually always spatially coherent Improved random access - Cache nodes - Inverted tree traversal - On average shorter path - Amortize overhead of slow dynamic RootNode
SIGGRAPH2013
OpenVDB
25
Stencil Operations
Finite differencing - Gradient, curvature, Laplacian, curl, etc. - Central-difference schemes (2nd6th order) - Upwind schemes (1st5th order) Interpolation - Nearest neighbor: tools::PointSampler - Trilinear: tools::BoxSampler - Triquadratic: tools::QuadraticSampler - Staggered variants for MAC grids
SIGGRAPH2013
OpenVDB
26
Optimization
Use ValueAccessor for random access Use sparse iterators for sequential access
SIGGRAPH2013
OpenVDB
Use LeafManager when applicable (i.e., no tiles and static topology) Disable asserts (-DNDEBUG) Use library tools and routines (dont reinvent the wheel!) If possible, partition algorithm into topology and value updates - Use topology copy constructors - Use setValueOnly Use multithreading
27
Thread Safety
Non-thread-safe operations - Insert new values (due to allocate-on-insert) - Change state of a value (due to bit masks)
SIGGRAPH2013
OpenVDB
- Read or write via ValueAccessor (due to internal node caching) Thread-safe operations - Random or sequential read of constant values and states - Modify values in existing nodes
28
Threading Strategies
Thread over values or nodes using sparse iterators Consider using tree::LeafManager if applicable Assign one tree::ValueAccessor to each thread Reuse ValueAccessors as much as possible
SIGGRAPH2013
OpenVDB
- Never allocate a new ValueAccessor per access operation - In extreme cases use thread-safe access methods on Tree
29
Threading Strategies
If the topology of the output grid is known
SIGGRAPH2013
OpenVDB
- Pre-allocate output grid with correct topology (use topologyCopy) - Use tools::foreach or tbb::parallel_for over output grid - Use setValueOnly If the topology of the output grid is unknown - Assign an empty grid to each computational thread - Use tools::transformValues or tbb::parallel_reduce - Use hierarchical merge or compositing in thread join - Use concurrent malloc, e.g., tbb_malloc or jemalloc
30
End
SIGGRAPH2013
OpenVDB
Questions?
31
SIGGRAPH2013
OpenVDB
32
End
SIGGRAPH2013
OpenVDB
Questions?
33