The VDB Modify operator can be used to mathematically transform voxels in a VDB.
The VDB Modify operator is at the heart of all VDB operations within tyFlow. It can be used to initialize various grid types (velocity, uvw), composite voxel values together, transfer surface properties, etc. Understanding how this operator works, and harnessing its abilities, is the key to effectively working with VDBs within tyFlow.
UVW/Velocity grids contain vector values (ex: a single cell might contain a value like [2.1, 0.125, 41.93]) and Density grids contain scalar values (ex: a single cell might contain a value like: 1.213).
Initialize from density/SDF: controls which existing grid to intialize any missing grid types from.
Keep grid sparse: when enabled, intializations from SDF grids will not fill in internal cells with dense data. For example, if you convert a sphere object to an SDF grid and then initialize a density grid from that SDF with this setting enabled, the grid cells inside the sphere may be much larger (ie, more sparse) than the surface cells. This conserves memory but may not be ideal in situations where you want a dense grid layout inside objects (ex: if you want to render fog or some other volumetric surface).
The operation dropdown in these rollouts controls how the existing VDB data in the selected grid will be changed by input values.
For each cell in the source grid:
Add: input values will be added to existing values.
Cross: existing values will be set to the cross product of existing values and input values.
Divide: existing values will be divided by input values.
Min: the existing value will be changed to the minimum of the input/existing values.
Max: the existing value will be changed to the maximum of the input/existing values.
Modify: the existing values will only be affected by changes made in the “modify output” rollout.
Multiply: existing values will be multiplied by input values.
Remove Divergence: existing values will be modified to remove any divergence between them.
Set: existing values will be set to input values.
Subtract: input values will be subtracted from existing values.
Tangent: existing values will be set to the tangent of existing and input values.
The value type dropdown in these rollouts controls which input values will be used to change the existing grid values. For example, if you choose to modify a Density grid with Noise, the existing value of each cell will be changed (according to the operation type) with a noise function evaluated for the world-space position of each cell.
Depending on which value type is chosen, additional rollouts may appear which require further input (ex: a “Distance to Surface” value type will require the user to select surface(s) as input).
These rollouts allow you to adjust input scalars before any operations, and output scalars after any operations. Output scalars are simply the values assigned to the grid after the specified operation is completed.
For example, if a cell in the input grid has a value of 0.25f, and you retarget from 0-1 and to 0-100, the resulting value for that cell will be 25.
Retarget with curve: by enabling this setting, you can retarget using a specified curve as the interpolation method instead of a basic linear interpolation. This allows you to bias retargeted values in a non-linear manner.
Clamp: enables cell value clamping, so that resulting values do not outstep a specified minimum/maximum amount.
Exponent: raises cell values to a specified power.
Multiplier: multiplies cell values by a specified amount.
Offset: adds a specified, constant amount to cell values.
The clamp, exponent, multiplier and offset operations are performed in that order.
These rollouts allow you to adjust input vectors before any operations, and output vectors after any operations. Output scalars are simply the values assigned to the grid after the specified operation is completed.
Normalize: all cells values will be retarged so that their magnitude lies within the range of 0-1.
Clamp magnitude: all cell values will have their magnitude clamped to be within the specified min/max threshold.
Multiplier: multiplies cell values by a specified amount.
Interpolation: linearly interpolates existing cell values towards the resulting output values by the specified amount.
By enabling vector analysis in this rollout, you can view important information about grid cell values, allowing you to make more informed decisions about how to modify them. For example, if you want to retarget scalar values, being able to see the existing min/max values of the grid will allow you to set more precise from/to retarget thresholds.