RenderMan Introduction CS 551/645 Fall 2000
Evaluate Me! Please visit the SEAS main website and use the ‘Course Evaluations’ button to rate this class.
Administrivia RenderMan assignment due 9:00 a.m. on December 5 th, one week from today Extra Credit assignment due 7:00 p.m. on December 11 th –I have handouts to help explain the ray tracing algorithm. Grab one after class.
Remember BMRT.org download is closed until Friday – has older Windows versionwww.rhino3d.com – has recent Linux versionwww.tucows.com –My account on Small Hall has recent SGI version
Renderman Sites state.edu/~smay/RManNotes/rmannotes.htmlhttp:// state.edu/~smay/RManNotes/rmannotes.html ookindex.htmlhttp://minerva.ca.scad.edu/faculty/kesson/CA301/b ookindex.html
RenderMan Defines an interface between scene design and scene rendering –RenderMan Interface (Ri) is the formal spec –BMRT and Pixar’s PRMan (aka RenderMan) are two implementations of rendering software that accept the RenderMan Interface input files (RIB)
RenderMan Standards High-level object primitives –Polygon, Quadric Surfaces, Parametric Surfaces Hierarchical graphics state Model and viewing transformations Programmable shading language Anti-aliasing Texture Maps Robust definition of image size and depth
RenderMan I/O Inputs –RenderMan Interface Bytestream (RIB) files Scene description –Shaders Programs that describe shading (lighting and coloring) algorithms –Maps Images, shadow regions, etc. Outputs –Maps For use as inputs in future rendering stages –Images The final product of the rendering
RIB Files You can write these by hand (ASCII or binary) You can have them generated using C++ code and RenderMan C++ libraries Maya plugin - MTOR Roll your own RIB writer
Sample RIB File ##RenderMan RIB version 3.03 Display "RenderMan" "framebuffer" "rgb" Format LightSource "distantlight" 1 Translate WorldBegin Surface "metal" Color [ ] Polygon "P" [ ] WorldEnd
Shaders Write from scratch Obtained from software app, Slim or ShadeTree Must be compiled to object code
Sample Shader surface metal (float Ka=1, Ks=1, roughness=.1) { normal Nf; vector V; Nf = faceforward(normalize(N), I) ; V = normalize(-I) ; Oi = Os; Ci = Os * Cs * ( Ka*ambient() + Ks*specular(Nf,V,roughness) ); } /* metal */
Shaders Examples There are a million shaders on the web It is amazing to see the complex effects generated with simple functional descriptions Shader writing is the bread and butter of special effects houses (the fur on Stuart Little, for example)
Shaders Many extra shaders are included with the BMRT distribution Look in the shaders directory Read the.sl shaders and follow the structure of the input parameters when using Remember, RenderMan graphics state stores variables about camera position, light positions, etc.
How To Generate this:
.rib Code # bulb.rib # Author: Scott Iverson # Date: 6/9/95 # Display "bulb.tiff" "file" "rgb" Projection "perspective" "fov" 25 Format Rotate Rotate Rotate Translate Comments Output to file (TIFF) Perspective, 25 deg FOV Image Size Camera Rotation (NOOP) Angle, X, Y, Z Move Camera
.rib Code WorldBegin Light 1 is ambient with intensity.4 LightSource "ambientlight 1 "intensity".4 Light 2 is distant with intensity.6 and direction (-.3, -.2, 1) LightSource "distantlight" 2 "intensity".6 "from" [0 0 0] "to" [ ] AttributeBegin is like GL_PUSH AttributeBegin Rotate –90 degrees about x-axis Rotate Use interpolation to determine shading of pixels that fall between sampled points. Could be “constant” ShadingInterpolation "smooth"
.rib Code # base Apply the material “metal” to all future geometry Surface "metal“ Apply the color “blue” to all future geometry Color Again, push to isolate the upcoming changes AttributeBegin Change the “handedness” of the coordinate system. Because we’re about to draw a quadric surface, the handedness effects the normal direction Orientation "rh“ Create a quadric surface, a disk Disk Pop the state (the handedness) AttributeEnd
.rib Code The Blue color remains and we draw a cylinder Cylinder We move up a little (to the top of the cylinder) Translate We change to another surface shader Surface "matte” We change to color “yellow” Color We draw a hyperboloid around base of bulb Hyperboloid
.rib Code Translate Surface "metal" Color Translate Torus Translate Torus Translate Torus Translate Torus Translate Torus Translate Translate Move up a little Change the surface shader Change the color to be more red Draw the torii for the threads
.rib Code # the glass part Change the shader Surface "plastic" "roughness".4 Change the color to “white” Color Here is the truncated call to generate the bulb surface PatchMesh "bicubic" 13 "nowrap" 7 "nowrap" "P" [ …] Pop Stack AttributeEnd End of scene description WorldEnd
Things to remember The default coordinate system is left-handed Camera initially at origin looking along positive-z All camera movements are defined before the “World Begin” command Think backwards about camera movement. You’re moving the world, not the camera Object transformations accumulate (note the torus sequence) but for each object, the transformations are applied last -> first
C++ Library Straightforward relationship to.rib file we just reviewed Uses –include/ri.h (for Rt data types and function headers) –lib/libribout.a (for function code)
C++ Library One weird thing about RenderMan Interface –Shaders accept parameter list arguments token-value pairs Terminated by RI_NULL –Explicit type casting RtToken, RtPointer –Pass by address
parameter list Define the name of the texture map file Char *mytmap = “ grid.tiff ” Create a new token name and define its type tmap will now be of type uniform string RiDeclare ( “ tmap ”, ” uniform string ” ); Use the shader, mytexture.sl, for the future geometry Provide the input parameter, mytmap, for the location of the texture map RiSurface ( ” mytexture ”, (RtToken) ” tmap ”, (RtPointer) &mytmap, RI_NULL);
What you need to do Create RiLookat() –Arguments: eyePoint(xyz), lookatpoint(xyz), upvector(xyz) –Once this is created, remove the explicit rotate and translate commands I have in the code
What you need to do Create an environment map –Use the command in the class handout Apply the environment map to the surface of the teapot –Any surface shader that accepts a texture argument will work (shinymetal, for example)
What you need to do Apply a marble or wood shader to the pedestal –It should look good
What you need to do Apply the images you used to generate the environment map to texture map the walls of the room –If you wish, you can apply another kind of shader to the floor of the room (even though this would result in an unrealistic reflection on the teapot)
Applying Texture Maps Again, a shader like paintedplastic will accept a texturemap argument –Just use it as an RiSurface before rendering the walls of the room –Make sure each wall gets a different texture However, polygons do not have simple ways to adjust texture coordinates and texture may wrap or tile Alternative: BILINEAR patch
RiPatch RiPatch (“bilinear”, RI_P, (RtPointer) corners, RI_ST, (RtPointer) textcoords, RI_NULL); –RtPoint corners[4]; –static struct {RtFloat x,y} textcoords [4];
What you need to do Put 3 lights in the scene –1 point, 1 directional, 1 spot Forget about the shadows –I’ll send out with instructions for those who are still interested