From BlenderWiki

Jump to: navigation, search
Note: This is an archived version of the Blender Developer Wiki. The current and active wiki is available on wiki.blender.org.

Volume Object (WIP)

Motivation

Volumes have a lot of applications in computer graphics, particularly in visual effects where they play a central role in physical simulations. Although the most common usage of volumes is found in computational fluid dynamics, they are also used for collision detection, fracturing, bringing stability to a particular solver.

In recent years, several data structures were created to handle volumetric data, with an accent put on memory usage, with the most popular being VDB, available through the OpenVDB library.

Proposed Implementation

The proposed implementation is making use of the VDB data structure as the backend for the volume object.

typedef struct VolumeData {
	struct VolumeData *next, *prev;
 
	struct OpenVDBPrimitive *prim;
 
	char name[64];  /* MAX_NAME */
	short type;     /* data type: float, int, vector... */
	...
} VolumeData;
 
typedef struct Volume {
	ID id;
 
	ListBase fields;
} Volume;

Special care needs to be taken to ensure the grid's transformation matrix is aligned/updated with the object's one. Note that some of this API is already implemented in some form or another in both the particle mesher (D1008) and in the openvdb branch.

Applications

Such an approach would allow any object operator or modifier to create an OpenVDB grid which will live for as long as the underlying object lives. The direct (very short term) usages will be:

  • pass the vdb grids to Cycles directly from Blender, instead of relying on files, will really pay off in terms of level set rendering.
  • importing of external files, not being able to transform an external VDB to fit in Blender's unit system is the only showstopper here, they (density volumes) can already be rendered in Cycles e.g. (but with a wrong scale/orientation)

In the future, some dedicated OpenVDB modifiers (most likely nodes) could be considered to manipulate the grids directly. Some operators could also be considered to perform tasks which are typically more stable to perform on volumes, voxels and/or level sets.