HDK
|
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.
Once your procedural is created, you can create a SHOP interface by starting Houdini and using File->New Asset.... Choose a new VOP 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 VOP and create a copy using the Operator Type Manager, editing the properties so that your procedural can be configured.
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:
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.
This simple example will render a polygonal box during the rendering process. The surface shader is set to the "constant" shader.
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).
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.
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.
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).