OpenVDB

OpenVDB

  • Note

    The Katana scene file for this example - volume_openVDB.katana - is included in $KATANA_RESOURCES/Examples/katana_files/.

Description

OpenVDB is an open source hierarchical data structure for volumes.

For more information about OpenVDB, see the OpenVDB FAQ.

How To Read an OpenVDB File

Currently, there is no openVDB reader or visualizer in RenderMan for Katana.

To read in openVDB, you will need to create a LocationCreate node and an AttributeScript node to set the parameters for RiVolume.

images/rfkOpenVDB.png

In the LocationCreate node, set the type to volume, then set the volume's location path that will appear in the scene graph.

images/rfkOpenVDBLocationCreate.png

In the AttributeScript node for the volume you will need to set the appropriate parameters for RiVolume:

# Emit the bounds for RiVolume
bounds = [-19.1463, 19.878, -7.68293, 80.8537, -18.6585, 18.4146]
SetAttr("bound", ScenegraphAttr.Attr("DoubleAttr", bounds))

# Emit the blobbydso:impl_openvdb
SetAttr("geometry.type", ScenegraphAttr.Attr("StringAttr", ["rivolumedso"]))
SetAttr("geometry.dso", ScenegraphAttr.Attr("StringAttr", ["impl_openvdb"]))

# Emit the blobbydso stringargs
SetAttr("geometry.stringargs", ScenegraphAttr.Attr("StringAttr",["fire.vdb", "density"]))

# Emit the blobbydso:threshold
SetAttr("geometry.threshold", ScenegraphAttr.Attr("FloatAttr",[0.0]))

# density type declaration (varying float[])
SetAttr('geometry.arbitrary.density.scope', ["point"])
SetAttr('geometry.arbitrary.density.inputType', ["float"])
SetAttr('geometry.arbitrary.density.value', [0.0])

# example of reading another grid such as "temperature"
SetAttr('geometry.arbitrary.temperature.scope', ["point"])
SetAttr('geometry.arbitrary.temperature.inputType', ["float"])
SetAttr('geometry.arbitrary.temperature.value', [0.0])

The above example will emit the following to the RIB:

Volume "blobbydso:impl_openvdb" [-19.2683 20 -7.80488 80.9756 -18.7805 18.5366] [0 0 0]
       "constant string[2] blobbydso:stringargs" ["fire.vdb" "density"]
       "varying float density" [] "varying float temperature" [] "constant float blobbydso:threshold" [0]

See Appendix D: Standard Attributes/Location Type Conventions in the Katana Technical Guide - $KATANA_HOME/docs/pdf/Katana_TechnicalGuide.pdf - for how to specify other types and attributes.

Motion Blur

To specify "time" for motion blur, we pass the velocity attribute to RiVolume.

# Emit the bounds for RiVolume
bounds = [-19.1463, 19.878, -7.68293, 80.8537, -18.6585, 18.4146]
SetAttr("bound", ScenegraphAttr.Attr("DoubleAttr", bounds))

# Emit the blobbydso:impl_openvdb
SetAttr("geometry.type", ScenegraphAttr.Attr("StringAttr", ["rivolumedso"]))
SetAttr("geometry.dso", ScenegraphAttr.Attr("StringAttr", ["impl_openvdb"]))

# Emit the blobbydso stringargs (velocity grid name is "v" in this example)
SetAttr("geometry.stringargs", ScenegraphAttr.Attr("StringAttr",["explosion.vdb", "density", "v"]))

# density type declaration (varying float[])
SetAttr('geometry.arbitrary.density.scope', ["point"])
SetAttr('geometry.arbitrary.density.inputType', ["float"])
SetAttr('geometry.arbitrary.density.value', [0.0])

# Emit "constant float[2] time"
SetAttr('geometry.arbitrary.time.scope', ["primitive"])
SetAttr('geometry.arbitrary.time.inputType', ["float"])
SetAttr('geometry.arbitrary.time.elementSize', 2)
SetAttr('geometry.arbitrary.time.value', [0.0, 1.0])

The above example will emit the following to the RIB.

Volume "blobbydso:impl_openvdb" [-19.1463 19.878 -7.68293 80.8537 -18.6585 18.4146] [0 0 0]
       "varying float density" [] "constant float[2] time" [0 1]
       "constant string[3] blobbydso:stringargs" ["explosion.vdb" "density" "v"]

OpenVDB Shading Network

To access the openVDB grid data, such as density, we simply use PxrPrimvar.

images/rfkOpenVDBDensity.png

Connect the result of PxPrimvar to the appropriate shading node, for example, PxrVolume, as in the image below:

images/rfkOpenVDBVolumeShading.png