Visualizing procedural bounding boxes

Procedural primitives are a powerful mechanism for efficiently rendering complex scenes.  In a scene file a procedural primitive is defined with the Procedural RIB command:

Procedural “type” [arguments] [minx maxx miny maxy minz maxz]

The array of 6 floats at the end defines a bounding box for all objects that might be created by the procedural.  The procedural prim acts a placeholder in the scene.  The procedural e is evaluated only when and if the renderer needs to access the interior of the bounding box.  If the bound is never encountered by the renderer – because say the bounding box is off-screen or occluded by other objects – the procedural primitive is never evaluated.

Because of the on-demand manner in which a procedural primitive is created, it is important that the bounding box be accurate.  If the bound is too large, the renderer may unnecessarily evaluate a procedural prim whose contents are hidden.  If the bound is too small, objects of created by the procedural primitive may be rendered incorrectly (usually appearing to be clipped along bucket boundaries or the boundaries of the bounding box).

Here is a small RIB filter plugin to aid in visualizing the bounding box for a procedural primitive:

Unzip the archive to the procedurals directory of your Air installation, and Air will be able to find the showprocbd plugin without a path reference.

You can use the -rif command line switch to apply the showprocbd RIB filter to a scene:

air -rif showprocbd myscene.rib

Here’s an example showing a small group of agents from the Massive crowd simulation program.  Massive uses a procedural primitive to generate agents geometry at render time.

By default the showprocbd filter replaces each procedural primitive with a box representing the procedural bound. This can be help accelerate preview rendering in cases where the full expanded geometry is not needed.

Showprocbd has a number of options for customizing its behavior.  For example, you can set the alpha and color for the box:

air -rif “showprocbd boxalpha 0.5 boxcolor 1 .8 .6” myscene.rib

Including a “replace 0” in the argument list retains the contents of the procedural primitive:

air -rif “showprocbd boxalpha 0.5 replace 0” myscene.rib

In this scene we can see that for some agents the elbows protrude slightly outside the bounding box.

The box can be represented by lines instead of or in addition to polygons:

air -rif “showprocbd boxalpha 0 linewidth 3 linecolor .7 .8 .5” myscene.rib

Box corners can also be rendered:

air -rif “showprocbd boxalpha 0 cornerwidth 20 cornercolor 1 0 0 linewidth 5” myscene.rib

Finally, instead of applying the filter as a command line option, you can define the current filter for an object as a RIB attribute:

Attribute “render” “rifilter” “showprocbd replace 0 boxalpha 0.5”

This entry was posted in RIB Filters and tagged , , , . Bookmark the permalink.