HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Procedural Primitives For Mantra

Mantra Procedurals: Table Of Contents

Procedural Primitives

A procedural primitive (RAY_Procedural) provides a way to generate geometry during the rendering process. Rather than loading geometry from disk or the IFD, a procedural can generate geometry on the fly.

If the geometry is small in screen-space (i.e. far from the viewing camera), the procedural can generate less geometry than if the geometry were large in screen space.

In the simplest sense, a procedural is represented as a bounding box (UT_BoundingBox) and a method to render the procedural (RAY_Procedural::render()).

When mantra determines that the bounding box needs to be rendered, the render method is called. At this point, the procedural can either generate geometry (RAY_Procedural::openGeometryObject()) or it can generate further procedurals (RAY_Procedural::openProceduralObject()).

For example, there could be a forest of trees specified as a procedural. The render method could then generate a sub-forest by dividing the forest into more manageable chunks. Or, it could generate multiple tree geometry objects.

How To Create A Geometry SHOP

Once your procedural is created, you can create a SHOP interface by starting Houdini and using File->New Operator Type. Choose a new SHOP type, then choose Geometry/Procedural Shader as the network type.

You can then edit the parameters of the SHOP.

You may want to set the Render Mask to * (in the Basic tab of the type properties).

Another approach is to take an existing SHOP and create a copy using the Operator Type Manager, editing the properties so that your procedural can be configured.

Installing Procedurals using the VRAYprocedural file

Mantra looks for dynamic objects in the MANTRA_DSO_PATH, calling the registerProcedural method to install procedurals.

Previously, mantra used a table to define procedurals. For backward compatibility, when mantra starts up, it loads a file (VRAYprocedural) that specifies the location of the procedural dynamic objects.

Mantra searches for the VRAYprocedural file in the standard Houdini path. Only the first file found is parsed. The VRAYprocedural file is processed using Houdini's CPP (C pre-processor), so it's possible to use #if conditionals, and #include directives to include multiple files. For example, to include multiple VRAYprocedural files, you might have a file which looks like:

#sinclude "File1"
#sinclude "File2"
#sinclude "File3"
#sinclude "File4"

Note: #sinclude performs "silent" includes (no warnings on missing files).

Tip: Running the command "mantra -V8 < /dev/null" will print out all the procedurals registed by mantra.

Tip: You can set the "HOUDINI_DSO_ERROR=3" to see the .so files loaded by mantra.

Example Procedural Primitives

RAY/RAY_DemoBox.C

This simple example will render a polygonal box during the rendering process. The surface shader is set to the "constant" shader.

RAY/RAY_DemoFile.C

This is a slightly more interesting example. The procedural defers loading of a disk file until the procedural is rendered. The procedural can also set motion blur (either velocity blur or deformation blur).

RAY/RAY_DemoStamp.C

Instead of generating geometry directly, this example file will stamp box primitives through a volume. It does this by creating new procedural objects which then get rendered.

RAY/RAY_DemoMountain.C

This procedural renders a fractal triangle. If the level of detail of the procedural primitive is too large, the primitive will split into 4 child procedural primitives. If the primitive is small in screenspace, triangle geometry will be rendered directly.

RAY/RAY_DemoVolumeSphere.C

This is an example of generating a procedural volume primitive.

Rather than adding geometry or a procedural, the render() method creates a new volume primitive (defined in the example).

See Also
RAY_Procedural, RAY_ProceduralArg, RAY_Volume