RenderMan Procedural Primitives
|
Introduction
A helper app is an executible that is loaded by a RenderMan complient renderer
as a result of reading a Procedural "RunProgram" ["H:/rman/helpers/hairball" "2.0 200 0.03"] [-2 2 -2 2 -2 2]
In this example, the call to "2.0 200 0.03"
are values that are passed to the program. The six values, "-2 2 -2 2 -2 2"
define the size of the bounding box of the geometry the helper app will create.
When the renderer calls a helper app it not only passes the parameter values,
it also calculates the number of pixels the bounding box of the object
will cover in the rendered image. This value can help the app make level of detail
decisions ie. should it generate a low, medium or a hi-res version of the geometry?
H:/rman/helpers/demo <.c .py .tcl> /home/$USER/rman/helpers/demo <.c .py .tcl> /Users/$USER/Documents/rman/helpers/demo <.c .py .tcl> |
Basic CodeThe following template code is based on the web notes, "Writing Procedural Primitives with RenderDotC" www.dotcsw.com/doc/procedurals.html#runprogram
Other sources of information about helper apps can be found by searching
the RenderMan documents that accompany Pixars prman. Pages 119/120 of
"Advanced RenderMan" by
Tony Apodaca and Larry Gritz is also an excellent source of information about this
topic. A sample python helper scipt that generates an arbitary number of
polygons can be found in the tutorial
"RSL:Color By Height".
Listing 1 (rib)
|
Tcl ImplementationListing 3 (demo.tcl)
In the rib file the script would be invoked as follows, # Windows Procedural "RunProgram" ["tclsh H:/rman/helpers/demo.tcl" "1"] [-1 1 -1 1 -1 1] # Linux Procedural "RunProgram" ["/usr/bin/tclsh /home/$USER/rman/helpers/demo.tcl" "1"] [-1 1 -1 1 -1 1] # MocOSX Procedural "RunProgram" ["/usr/bin/tclsh /Users/$USER/Documents/rman/helpers/demo.tcl" "1"] [-1 1 -1 1 -1 1] |
'C' Language ImplementationThe code in listing 2 will build a helper app called demo. Listing 4 (demo.c)
In the rib file this app would be invoked as follows, # Windows Procedural "RunProgram" ["H:/rman/helpers/demo" "1"] [-1 1 -1 1 -1 1] # Linux Procedural "RunProgram" ["/home/$USER/rman/helpers/demo" "1"] [-1 1 -1 1 -1 1] # MocOSX Procedural "RunProgram" ["/Users/$USER/Documents/rman/helpers/demo" "1"] [-1 1 -1 1 -1 1] |
How it Works
Although it is not apparent from the code, the demo app automatically has
access to three streams by which it can receive and send data, namely,
stdin, stdout and stderr. Ordinarily, the first stream
is connected to the keyboard, the others are connected to the console.
When the renderer invokes a helper app it redirects its own the stdin and stdout
streams to those of the helper app so that, for example, input and output from
functions/procs such as |
© 2002- Malcolm Kesson. All rights reserved.