Discussion Section 09 - Using Renderman and PoV-Ray

CNM190 2006-10-02 Updated Files

Overview : Renderman v. PoV-Ray

If you want to use a better renderer than what OpenGL provides, you should consider batch-rendering programs like Renderman and PoV-Ray. Renderman is the industry-standard renderer that has been used in just about every CG-intensive movie you've seen in the past 10 years. Through a special arrangement with Pixar, we have access to Renderman. This discussion section will highlight how to use Renderman for your cs184 final project. Oh, if you ever want to work for Pixar, having used Renderman for your cs184 final project certainly can't hurt. ;-)

PoV-Ray is a free ray-tracer available online in many platforms. Did I say free? Yes, free. But, it doesn't do many of the wonderful things Renderman does. So feel free to use it, but you'll have to learn to use it on your own. There's a pretty well-written tutorial online.

Renderman Overview

The basic idea of Renderman is that you write C code to output a RIB file, then call Renderman to produce a picture from your RIB file. Since the RIB files are ASCII, you can produce them yourself (using printf) or using procedural interface calls which results in the output of RIB. We'll use the latter.

Once you have a .rib file

How do you render it? Simple. Go to an HP or SGI (neither use OpenGL, so you in fact can log into an HP and send the display back to your non-OpenGL X display!) and go to the directory containing the .rib file. There are two ways to render, locally or on a distributed basis. Local rendering uses your machine and distributed rendering uses multiple machines, divides the task and then recombines the work at the end. As you can imagine, there is substantial overhead your machine takes on in dividing the rendering task into sizeable packets, flooding the network with these requests and then repackaging them up. Sometimes it's actually faster to render locally! Try it on your particular .rib files and see for yourself. In general, if the .rib file has very simple geometry but complicated lighting calculations then distributed rendering will win. Sometimes it's more efficient to use two or three machines rather than many machines. This all depends on the particular .rib file, the load on the network and the load on the render servers at the time. Your mileage may vary, but in general try local renderings first, then try distributed renderings using machines in the lab that aren't being used by anyone.

Local render

This is very simple, and only uses the HP/SGI you're logged in to. You simply call the render command with a single argument, the .rib file you want to render, and render will either display the output to the screen or to a file, depending on what your Display was set to. The interaction you should see (if you set it to write to a file) is:
unix% render foo.rib
unix% 
and as a side-effect, your file (let's call it foo.tif) has been created.

Distributed render

As of this writing, distributed rendering is broken. (1997-10-21)

This is a wee bit more complicated, but allows you to use more than one machine to handle your rendering chore. Here's how it works. You specify the machines to do your distributed rendering via the -h flag on your call to netrender. Here's an example:
unix% netrender -h holmes.cs -h shapiro.cs foo.rib
holmes.CS.Berkeley.EDU: Network RenderMan Server 1.1a
shapiro.CS.Berkeley.EDU: Network RenderMan Server 1.1a
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
unix%

ars - All Render Servers

Note that many times a few, hand-selected low-load machines will beat a whole lot of machines (because the final output has to wait for all machines to return with their render results before finally returning - the weakest-link problem). But, if you want to run your render on a whole slew of machines, we can help. In ~cs184/bin there is an executable called ars (this stands for "All Rendering Servers") which will return a list of machines optimized for the machine you are on. Unfortunately the HPs have an upper-limit on the number of machines which can be passed into netrender. The program ars determines which machine you are on and selects a close-to-optimal list of machines for you to render on. (You get twice the render servers if you use an SGI machine) So, all you ever have to do a distributed render is type:
unix% netrender `ars` foo.rib
which if you were on an SGI would return:
unix% netrender `ars` foo.rib
benet.CS.Berkeley.EDU: Network RenderMan Server 1.1a
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
ellison.CS.Berkeley.EDU: Network RenderMan Server 1.1a
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
heller.CS.Berkeley.EDU: Network RenderMan Server 1.1a
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
kilmer.CS.Berkeley.EDU: Network RenderMan Server 1.1a
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
melville.CS.Berkeley.EDU: Network RenderMan Server 1.1a
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
millay.CS.Berkeley.EDU: Network RenderMan Server 1.1a
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
miller.CS.Berkeley.EDU: Network RenderMan Server 1.1a
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
shapiro.CS.Berkeley.EDU: Network RenderMan Server 1.1a
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
sinclair.CS.Berkeley.EDU: Network RenderMan Server 1.1a
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
stowe.CS.Berkeley.EDU: Network RenderMan Server 1.1a
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
alcott.CS.Berkeley.EDU: Network RenderMan Server 1.1a
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
wright.CS.Berkeley.EDU: Network RenderMan Server 1.1a
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
thayer.CS.Berkeley.EDU: Network RenderMan Server 1.1a
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
thoreau.CS.Berkeley.EDU: Network RenderMan Server 1.1a
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
warren.CS.Berkeley.EDU: Network RenderMan Server 1.1a
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
holmes.CS.Berkeley.EDU: Network RenderMan Server 1.1a
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
walker.CS.Berkeley.EDU: Network RenderMan Server 1.1a
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
whitman.CS.Berkeley.EDU: Network RenderMan Server 1.1a
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
hughes.CS.Berkeley.EDU: Network RenderMan Server 1.1a
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
laviera.CS.Berkeley.EDU: Network RenderMan Server 1.1a
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
sandburg.CS.Berkeley.EDU: Network RenderMan Server 1.1a
PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
unix%

Finicky netrender

You may notice that sometimes you get errors with netrender for files that render fine using render, ala:
unix% render hard.rib
unix% netrender `ars` hard.rib
  (lots of these deleted for space reasons)
  machine.CS.Berkeley.EDU: Network RenderMan Server 1.1a
  PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
Bad bucket completion message.: Error 0
unix% 
or
unix% render hard.rib
unix% netrender `ars` hard.rib
  (lots of these deleted for space reasons)
  machine.CS.Berkeley.EDU: Network RenderMan Server 1.1a
  PhotoRealistic RenderMan 3.5d Copyright (C) 1988-94 Pixar
*** Error code 255
unix% 
In these cases, try replacing the ars with selected parts of what ars returns. So if ars returns:
unix% ars
-h benet.CS -h ellison.CS -h heller.CS -h kilmer.CS -h melville.CS -h millay.CS -h miller.CS -h shapiro.CS -h sinclair.CS -h stowe.CS
unix%
you might want to manually try a netrender to half of those, ala:
unix% netrender -h benet.CS -h ellison.CS -h heller.CS -h kilmer.CS -h melville.CS hard.rib
unix%

Displaying your .tif file(s)

unix% tiffdspy foo.tif
unix%
and if you have a sequence of files foo1.tif, foo2.tif, etc., you can use tiffdspy for multiple images (as long as they are the same size) as in:
unix% tiffdspy foo*.tif
unix%

Miscellaneous

Examples

To set this up, type the following from any HP or SGI:
unix% mkdir ~/renderman ; cd ~/renderman
unix% cp ~cs184/prman/example/* .
unix% 
You will find 4 files:
cube.c is a simple file in which we specify a unit cube centered around the origin whenever someone calls UnitCube(). The file simple.c specifies the full scene (lights, camera, etc) for our first .rib file. To compile this and automagically generate the .tif image, you just make the simple.pic, as in:
unix% gmake simple.pic
        gcc -ansi -I/usr/local/prman/tutorial -I/usr/local/prman/include  -c cube.c
        gcc -ansi -I/usr/local/prman/tutorial -I/usr/local/prman/include  -c simple.c
        gcc -ansi -I/usr/local/prman/tutorial -I/usr/local/prman/include  -o simple.gen simple.o cube.o /usr/local/prman/lib/librib.a -lm
        simple.gen >simple.rib
        render simple.rib
unix% 
this will create some new files: and similarly for hard.c which generates 3 images:

(Picture of hard0.tif) (Picture of hard1.tif) (Picture of hard2.tif)
hard0.tif - Note the wood texture and the recursive geometry. hard1.tif - Note the wood texture changing and the geometry rotating. hard2.tif - Note the wood texture morphed to blue and the geometry continued to rotate.

Makefile fun

The Makefile is pretty general. You can: and for the following keywords above (pic, rib, gen) you can just generate them for one file (and not for both simple and hard by just saying gmake file.keyword as in:

Animating your Renderman output

There are three ways to to this (that I know of - I'd love to learn more ways):
  1. Convert the TIFF files to SGI .rgb (through a simple script) and use the SGI movie player in ~cs184/bin.sgi/movie while sitting on an SGI (see below)
  2. Use mpeg_encode
  3. Use a Mac and turn the TIFFs to a Quicktime movie (see below)

Here are details:

  1. There are two ways of converting TIFFs to SGI rgbs to be viewed on an SGI:
    1. Use the IL (ImageVision Library) tool imgcopy (available on both HPs and SGIs, so this is preferred):

      unix% foreach i (hard*.tif)
      ? /usr/sbin/imgcopy -fSGI $i $i.rgb
      ? end
      

    2. Use the ppm toolkit (NOT avail on SGIs, so you have to have another window up to an HP/DEC machine - this is annoying)
      unix% foreach i (hard*.tif)
      ? tifftopnm $i | pnmtosgi > $i.rgb
      ? end
      
    Once you have your .rgb files, sit on an SGI and run the program ~cs184/bin.sgi/movie like so:
    unix% ~cs184/bin.sgi/movie *.rgb
    
    and the right mouse button allows you to control lots of cool things about the animation - loop it, slow it down, go frame by frame, etc. I've set up .rgb files from the hard.c animation (but I made the cube rotate a bit more for this animation) and they are in: ~cs184/prman/movie/hard[0-2][0-9].rgb. So you would see the movie I created by typing (sitting in front of an SGI):
    unix% ~cs184/bin.sgi/movie ~cs184/prman/movie/*
    
  2. MPEG is a pretty efficient but lossy format. It's great for compressing lots of files down to a small movie, but there's quite a bit of quality tradeoff. Laura may discuss how to crank the quality up.
  3. Quicktime is a format which supports a variety of compressors and decompressors (codecs) which span the spectrum of file-size vs. quality. If you have a mac (or access to a friend who has a mac), there are several utilities which allow you to make a Quicktime movie from PICT files. This means you have to convert the TIFF images to PICT files - two programs that I know of do this, DeBabelizer (commercial) and GraphicConverter (shareware). DeBabelizer will allow you to go straight to a Quicktime movie. If you use GraphicConverter, you have to then use another utility ("Picts to Movie", "MovieMaker" and "DeBabelizer" are three I know of) to convert the PICTS to a Quicktime movie. If students want to do this and have no other access to macs, I will allow them a one-time use of the 535 office Mac to make Quicktimes of final draft movies.

Cool Examples

This is from Dan Garcia's Computer Graphics Gallery (where you'll find more cool movies and images):
(3-level Menger cube with filled plastic crosses) "Menger cube with crosses"

(1280x1280 195Kb jpg) A filled 3-level fractal wooden Menger cube filled with brightly colored plastic fractal crosses. Aaron Isaksen helped me with the design of this object.

(3-level Menger cube with filled plastic crosses movie) "Menger cube with crosses"

(256x256 10fps 4.7Mb mov) A recursive animation showing how we create a filled 3-level fractal wooden Menger cube filled with brightly colored plastic fractal crosses. Aaron Isaksen helped me with the design of this object, and Thomas Jordan modified the static file above according to my directions to produce the animation. Loop it forwards/backwards for best effect.

References

Renderman

PoV-Ray


WWW Maven: Dan Garcia (ddgarcia@cs.berkeley.edu) (finger me) Send me feedback

Dan Garcia | UC Berkeley | Computer Science | CS184