Next: , Previous: Geomview.m, Up: Mathematica


9.3 Using Mathematica to generate RenderMan files

In addition to the WriteOOGL and Geomview commands described above, the package OOGL.m also defines the command WriteRIb which writes a 3D graphics object to a RenderMan RIB file: WriteRIB[file, graphics] writes graphics to file file. RenderMan is a commercial rendering system available from Pixar, Inc., which can produce extremely high quality images.

     In[1] := <<OOGL.m
     
     In[2] := <<Graphics/Polyhedra.m
     
     In[3] := Graphics3D[Cube[]]
     
     Out[3] := -Graphics3D-
     
     In[4] := WriteRIB["cube.rib", %3]
     
     Out[4] := -Graphics3D-

This generates the file math.rib. This is a ready-to-render RIB file of the given geometry, using a default camera position, lighting, and the “plastic” shader. In a shell window, type render cube.rib to generate the image file mma.tiff. Of course, you need to have RenderMan installed for this to work. A shortcut to render from inside Mathematica is WriteRIB["!render", foo].

WriteRIb works by first converting the Mathematica graphics object to OOGL format using WriteOOGL and then calls an external program oogl2rib to convert OOGL to RIB format. The oogl2rib program takes several options which you can specify in a string as an optional third argument to WriteRIb. The default option string is " -n mma.tiff ", which indicates that the RIB file should generate a rendered TIFF file named mma.tiff. A particularly useful option is -g, which tells oogl2rib to convert only the geometry into a RIB fragment. You can insert that fragment into a full RIB file of your own making with camera positions and shaders of your choice, to harness the full power of RenderMan.

The full usage of oogl2rib is:

     oogl2rib [-n name] [-B r,g,b] [-w width] [-h height] [-fgb] [infile] [outfile]

By default it reads from stdin and writes to stdout. Either infile or outfile may be -, which means use stdin/stdout. The options are:

-n name
Use name for the name of the rendered TIFF file (default "geom.tiff") or framebuffer window (default "geom.rib").
-B r,g,b
Use background color (r,g,b). Each component ranges from 0 to 1. Default: none.
-w width -h height
Rendered frame will be width by height pixels.
-f
RIB file renders to on-screen framebuffer instead of TIFF file.
-g
Output only the geometry in RIB format.
-b
Output only a Quick Renderman clip object. Ignores -nBwhf.