OpenVDB


 Click here to expand Table of Contents...


Introduction

Both gases and liquids are fluids. LightWave 2018 introduced us to the importation of existing OpenVDB simulations, but Lightwave 2019 presents a robust framework based upon the industry-standard OpenVDB toolset. This toolset was developed by DreamWorks Animation, primarily by Ken Museth, Peter Cucka, Mihai Aldén and David Hill, for use in volumetric applications typically encountered in feature film and expands on this foundation providing backward compatibility with Lightwave’s existing particle simulation tools - ParticleFX and Flocking - while also introducing a new workflow for entirely VDB-based simulations.

In most cases, gases are handled by the OpenVDB Primitive type introduced in 2018 with a dedicated node editor. This provides fog-like raymarched volumetric rendering of thin particles such as smoke and fire.

Fluids, on the other hand, will mostly be generated as polygonal surfaces - called Iso Surfaces - using the OpenVDB Evaluator found in the Object Properties Object Replacement dropdown menu.

The key element in OpenVDB is the grid, more precisely "the efficient storage and manipulation of sparse volumetric data discretized on three-dimensional grids." Think of grids as an object’s bounding box that can be subdivided into smaller cells where something exists (such as a surface, points, particles…) while ignoring the empty cells, hence the "sparse" part of the description.

These cells are Voxels and act much like pixels in an image, but representing 3D volumetric shapes. The smaller the voxel size, the more detailed the object will be.

The beauty behind this system is that it entirely ignores empty cells decreasing memory and disk usage while making the rendering of volumes much faster.

This new feature gives the user the power to create volumes from meshes and meshes from volumes

OpenVDB Evaluator

To create your own OpenVDB object, you need to start with a source object and a null with the OpenVDB Evaluator Object Replacement added. OpenVDB objects can be made from meshes, primitives and even other volumetrics.

Once you have your target mesh and null to direct it to, open the node editor by clicking on the Properties button next to the OpenVDB Evaluator entry. The destination node

contains two entries. A scalar-based grid input and a vector-based velocity grid input. The scalar grid is the one you'll use most often for fixed shapes. If motion blur is enabled and there is a velocity grid, a deformer will be added to the object modifiers list allowing for subframe evaluation of the grid using the velocity input.

The OpenVDB Blur deformer cannot be interacted with by the user. It has no UI, cannot be added or deleted except automatically by Layout

Double clicking on the destination node will open its settings window

  • Iso - The iso value is considered to be the zero crossing of the grid's field of values. This zero crossing is where polygons are constructed
  • Adaptive - Values above zero will consolidate small voxel size polygons into larger polygons as flatness allows
  • Invert - Fog volumes can be input, but due to the representational difference between them (unsigned ) and SDF (signed) volumes the polygons appear backwards. This will flip the polygons for that case. Additionally you will need to move the Iso surface above 0

 Click here to expand Table of Contents...


Common

 OpenVDB nodes may have the following common settings:

  • Voxel Size - Size of the voxel grid in meters (LightWave supports uniform grids); the size of the voxel "blocks" that will make up your object
  • Inner Bandwidth - Inner Bandwidth for level set in voxels
  • Outer Bandwidth - Outer Bandwidth for level set in voxels. For fog volumes, this defines the "softness" until maximum density is reached.
  • Fill Interior - Toggle for whether the volume will be solid when cut into or just a shell like polygons are. Turning on Fill Interior with a Fog Volume will soften the outside of the fog
  • Coordinate System - How the voxel will be transformed. There are three choices
    • Local - No transform
    • World - Transform into world space
    • Parent - Use the parent item's space
  • Grid Name - the base name of savedgrid.vdb files. Files will be appended with the frame number and written with temperature, density, and velocity grids

Solid Volumes from Meshes and other Scene Items

Creating volumes from meshes relies on polygons being tris or quads. NGons are not supported

Creating a volume this way requires a target mesh, primitive shape or Particle emitter that needs to be in the scene. It can be out of camera view, hidden from render and hidden in OpenGL and the Object Replacement will still work. To create a volume from this item requires adding a null and using the Object Replacement entry OpenVDB Evaluator. Clicking Properties for it will bring up a Node Editor window.

Mesh To Volume

In the OpenVDB nodes group, Mesh To Volume will be the node to convert your mesh objects into volumes. There are two choices for conversion, Fog Volume will convert a mesh into a volumetric fog, much like the image at the top of this page but you need to use an OpenVDB primitive. The second option is Level Set, which creates a volumetric mesh object. The Voxel Size setting will determine the resolution of your volumetric object. For the Logo Rezzing Up example, a Scalar Constant node was used with an envelope that went from the default 1 down to 0.0025 to create the increasing resolution of the volume.

Shape To Volume

Will create a volume from LightWave primitive objects.

Fog To LevelSet

Converts a Fog grid to a Level Set mesh object. A fog grid can be imported using the OpenVDB Info node. Double-clicking the node brings up its window with Iso setting and Normalize toggle.

From Particles


When you have a particle emitter being meshed, you cannot bring up the particle properties, as upon meshing (the OpenVDB Evaluator being an object replacement procedure), the PFX Emitter server pane will close. The only way to adjust particle properties in this case is by using the modal FX Browser panel.

The same is true for other server pane items - changing the subdivision level, for example - but in that case, the only workaround is to disable the VDB object in the Scene Editor by unchecking the render flag.

FX Emitter particles must have a Size, and that size must be output with the Output Size toggle. You don't need to Show Size; it just helps visually.


This node will create a volumetric object from a stream of particles created using the FX Emitter or the Scatter or Solver nodes here. You have the option to either create sphere shapes or a trail per particle derived from their position, radius, and velocity. Each trail is generated as CSG unions of sphere instances with decreasing radius.

The direction of a trail is inverse to the direction of the Velocity vector, with a length of |V|. The radius at the head of the trail is given by the radius of the particle and the radius at the tail of the trail is Rmin voxel units which has a default value of 1.5 corresponding to the Nyquist frequency.

Gaseous Volumes from Scene items

Gas Solver

Gas solver.  Use Stam's stable fluids method to advect density and temperatures. Both the density and the temperature affect the fluid’s velocity. Heavy smoke tends to fall downwards due to gravity while hot gases tend to rise due to buoyancy. We use a simple model to account for these effects by defining external forces that  are directly proportional to the density and the temperature.

buoyancy = (-densityscale * density * Vec3f(0, 1, 0)) + (temperaturescale * temperature * Vec3f(0, 1, 0));

External forces can be added on the Force Grid input. This input accounts for external forces like gravity, wind, turbulence and merely is added onto the end of the momentum equation.

Temperature Tab

  • Ambient Temperature - Ambient air temperature
  • Clamp Temperature - Clamps the temperature to the minimum value set below (otherwise the gas cools to the point where it falls like dry ice)
  • Min - The minimum temperature (in Celsius) for the gas to fall to
  • Normalize Temperature Grid - Outputs the temperature grid as a scale between 0 and 1, rather than, say, 60 and 900
  • Fuel Temperature - Fuel temperature as it is emitted
  • Gas Density - Density of emitted smoke from the fuel grid
  • Fuel Velocity - Velocity of emitted smoke and heat from the fuel grid
  • Density Scale - Scale of the downward pull on dense smoke
  • Buoyancy Scale - Scale of the temperature gradient pulling smoke upward
  • Cooling Scale - Scales the cooling rate
  • Dissipation - The amount of density that falls off over each iteration so that the gas thins over time

Advection Tab

  • Spacial - Set the spatial finite difference scheme. In other words, how accurately the gradients of the signed distance field are computed depends on your pick of interpolator. The choices further through the list are more accurate but take more time
  • Spacial Tracker - Set the spatial finite difference scheme. How accurately time is evolved within the timestep. The choices further through the list are more accurate but take more time
  • Temporal - Set the temporal integration scheme. How accurately time is evolved within the renormalization stage. The choices further through the list are more accurate but take more time
  • Temporal Tracker - Set the temporal integration scheme. How accurately time is evolved within the timestep. The choices further through the list are more accurate but take more time
  • Integrator - Set the numerical advection scheme. The choices further through the list are more accurate but take more time
  • Limiter - Set the limiter scheme used to stabilize the second-order MacCormack and BFECC schemes
  • Max Divergence Steps - Maximum number of iterations of the pressure solver
  • Advection Sub Steps - Substeps per integration step. The only reason to increase it above its default value of one is to reduce the memory footprint from dilations - likely at the cost of more smoothing!
  • Curl Scale - Curl strength of the vorticity confinement

Domain Tab

  • Boundary - One of three choices:
    • Free Slip - Velocity is negated at the boundary axis
    • No Slip - Velocity is set to 0 at the boundary
    • Outflow - The grid is clipped at the boundary

The Min and Max domain fields are for setting the minimum and maximum extents (corners) of the simulation's domain.

Cache Tab

  • Cache Grids - Toggle for enabling the caching of grids to Cache Path folder. Once cached they can be loaded without simulation
  • Cache Name - Base name of saved grid . vdb files. Files will be appended with the frame number. Files will be written with temperature, density, and velocity grids
  • Grid Path - Path to save folder
  • Clear Cache - Clear all files in the cache folder
  • Behavior - A dropdown with three choices:
    • Manual - Cache control is completely up to the user
    • Warn - A message will warn "The cache is invalid, should it be cleared?"
    • Automatic - The cache is cleared automatically, when necessary

To Fog Volume

Converts an SDF grid (signed) to a fog volume (unsigned) with a filled interior. There are no options.

Tools

You can manipulate OpenVDB volumes with the following included tools.

Advect

Advect a Signed SDF grid with a velocity grid. Requires a Velocity Grid vector to give movement and direction.

  • Spatial - Set the spatial finite difference scheme. In other words, how accurately the gradients of the signed distance field are computed depends on your pick of interpolator. The choices further through the list are more accurate but take more time
  • Spatial Tracker - Set the spatial finite difference scheme. How accurately time is evolved within the timestep. The choices further through the list are more accurate but take more time
  • Temporal - Set the temporal integration scheme. How accurately time is evolved within the renormalization stage. The choices further through the list are more accurate but take more time
  • Temporal Tracker - Set the temporal integration scheme. How accurately time is evolved within the timestep. The choices further through the list are more accurate but take more time
  • Integrator - Set the numerical advection scheme. The choices further through the list are more accurate but take more time
  • Limiter - Set the limiter scheme used to stabilize the second-order MacCormack and BFECC schemes
  • Normalizing Steps - A number of renormalization passes can be performed between each substep to convert it back into a proper signed distance field. Prevents jerky motion but soften and slows the velocities
  • SubFrame Steps - Substeps per integration step. The only reason to increase it above its default value of one is to reduce the memory footprint from dilations - likely at the cost of more smoothing!
  • Rebuild SDF - Toggle to rebuild and retrack the narrow band of the SDF

CSG

Takes the Result from two SDF shapes and combines them in the fashion that should be familiar by now -

  • Union - Combines the two shapes, and is the default option
  • Intersection - Only leaves the parts of the two shapes that overlap
  • Subtraction - Removes Shape A from Shape B

The velocity of the input grids will be reconstructed and output.

Filter

This node adjusts the inner bandwidth of a volumetric signed distance field represented by a VDB volume

Filters the level set grid:

  • Filter Type:
    • Renormalize - Repair level sets represented by VDB volumes. Certain operations on a level set volume can cause the signed distances to its zero crossing to become invalid. This node iteratively adjusts voxel values to restore proper distance
    • Mean Value - This performs the equivalent of a simple box blur by taking the mean of the surrounding values
    • Median Value - This chooses the median of the surrounding values, good for homogenizing noisy data to avoid spikes
    • Mean Curvature - Finds the average curvature for a location and moves the surface along its normal to smooth out bumps
    • Laplacian Flow - Uses a local Laplacian value for movement along a normal
    • Dilate - Dilate the grid along its normals making it bigger
    • Erode - Erode the grid along its normals making it smaller
    • Close - Dilate the grid to close holes then erode closing openings
    • Open - Erode the grid then dilate to create openings
    • Track - the grid topology is updated by rebuilding the inner band so that it tracks the new iso interface
    • Gaussian - Gaussian smoothing
    • Resize - Change the width of the inner band of a VDB signed distance field
  • Accuracy - Increasingly complex algorithms for the accuracy of the integration
  • World - Performs the math for creating the levelset in World space, rather than Local
  • Half Bandwidth - Level sets are normally symmetrical on the inner band. Half Bandwidth uses this fact to halve calculation times but at the cost of accuracy
  • Iterations - the maximum number of attempts to achieve a divergence-free pressure matrix
  • Voxel Offset - Offsets the iso surface from the actual value. For instance, using

Noise

Add the Bump output from an image or a 3D Texture to this node and pipe the output through.

OpenVDB Info

The values for the Fuel channel of a VDB sequence

You can pipe a Level Set or Fog grid into this node and see the values contained within the file, but this node becomes more useful when you load a vdb file directly in the node. You can see info from whatever channels the vdb file contains.

Resample

Resample input grid to new voxelsize to output grid.

  • Interpolation - Different interpolators with increasing complexity
  • Rebuild SDF - Rebuilds and normalizes the narrow band of the level set
  • Prune - Removes values from the level set that are smaller than the Prune Tolerance set below

Saver

Pipe a grid into here and the frame or sequence is saved as VDB files upon clicking the Save button.

  • Save Type - a choice of Frame or Sequence. In both cases, a files or files will be saved using the File Name chosen appended with the frame number
  • Save Path - Choose a folder for the frame or sequence
  • File Name - The chosen prefix for the frame or sequence
  • Save - Immediately saves the frame or sequence. There is no visual confirmation apart from the playhead stepping through the scene in case of a sequence save

To load files saved this way, use the OpenVDB Info node to choose the VDB file and its channel saved.


Scatter

Scatter creates particles on the input grid.  The particle system constructed belongs to the scatter target item. Particles can be scattered on or in both SDF and fog volumes.

  • Scatter Target - The input grid to scatter on
  • Scatter Mode - Dropdown to specify how the particles will be placed:
    • Point total - Absolute number of particles to be scattered
    • Point Density - Percentage of voxels in which to place a particle
    • Points Per Voxel - Number of particles to put in each voxel
  • Seed - Sets the random seed
  • Spread - Distance to randomly move from the voxel center

Depending on the scatter mode chosen:

    • Point Count - When Point Total is chosen (integer)
    • Density - When Point Density is picked (percentage)
    • Points Per Voxel - When Points per Voxel is chosen (scalar)
  • Multiply - Density multiplier
  • Animate - Reseed the random generator each frame
  • Fill Interior - Fill particles inside the sdf narrow band
  • Size Factor - The size of the particles created

Creating bubbles inside a VDB toroid is simple with the Scatter node. The Filter node has been used here in Erode mode to ensure that the bubbles are created inside the toroid volume and not at the boundary.

Solver

A particle solver that uses a particle system to initialize a temporal PIC/FLIP feedback loop. Particles from the particle system are input as they are born. Then are advected by the integrator using the gravity over the frame substeps. PIC (Particle In Cell) produces smoother motions, and FLIP (FLuid Implicit Particles) is splashier. The two methods can be combined.

The Navier-Stokes equations that the PIC/FLIP system uses do not dictate position but velocity. The vectors contained are not coordinates but velocities. PIC / FLIP is an advection equation, which is how the particles in these objects move within velocity fields.

Particles In Cells (PIC) works by evaluating particles as groups of particles in cells (like voxels)

FLIP stands for FLuid-Implicit Particles and uses a grid rather than particles. Grid-based methods were great for large ocean effects, but not fine detail close up visual effects work. Things can look globby and unrealistic at small scale (thin fluids).

Inputs

  • Collision Grid - SDF grid to be used for collisions
  • Particle System input - Use a separate particle system

Outputs

  • Grid - Outputs an SDF grid
  • Particle System Out - Particle system output


  • Start Only - Only uses the first frame of the particle system
  • Voxel Size - Size of the gid voxels
  • Integrator - In short, the upper choices from this dropdown menu are faster but the lower choices are better quality
  • Subframe Steps - More steps per frame is more accurate but takes longer
  • PIC↔FLIP - Ratio of PIC velocities to FLIP velocities
  • Blobby - Check to treat the particles as spheres
  • Gravity - Downward pull in meters per second squared
  • Stickyness - Amount of velocity absorbed by contact with collision object
  • The next three checkmarks are to help visualize the grid:
    • Show Particles
    • Show Grid velocity
    • Show Collider grid

The Solver is time-based so scrubbing the scene will break it, particularly going backward. Create previews to see a smooth animation if your scene is too heavy.

Example - Chocolate Sauce Donut Drape

Velocity

This node will construct a velocity grid for motion blur use.

  • Reference Grid - Use to populate the velocity grid on the active values
  • Velocity - Vector of velocity evaluated during grid building
  • Rebuild Velocity - Rebuild Velocity at each evaluation rather than creating a static field

You can use an envelope or a texture map to adjust the velocity grid over time for more control

OpenVDB Examples