RenderMan Introduction

32
RenderMan Introduction CS 551/645 Fall 2000

description

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 - PowerPoint PPT Presentation

Transcript of RenderMan Introduction

Page 1: RenderMan Introduction

RenderMan Introduction

CS 551/645

Fall 2000

Page 2: RenderMan Introduction

Evaluate Me!

• Please visit the SEAS main website and use the ‘Course Evaluations’ button to rate this class.

Page 3: RenderMan Introduction

Administrivia

• RenderMan assignment due 9:00 a.m. on December 5th, one week from today

• Extra Credit assignment due 7:00 p.m. on December 11th

– I have handouts to help explain the ray tracing algorithm. Grab one after class.

Page 4: RenderMan Introduction

Remember

• BMRT.org download is closed until Friday– www.rhino3d.com has older Windows version– www.tucows.com has recent Linux version– My account on Small Hall has recent SGI version

Page 5: RenderMan Introduction

Renderman Sites

• http://www.cgrg.ohio-state.edu/~smay/RManNotes/rmannotes.html

• http://www.renderman.org/RMR/ • http://home.earthlink.net/~satysharon/RMan/• http://www.rendermania.com • http://www.bmrt.org • http://minerva.ca.scad.edu/faculty/kesson/CA301/

bookindex.html

Page 6: RenderMan Introduction

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)

Page 7: RenderMan Introduction

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

Page 8: RenderMan Introduction

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

Page 9: RenderMan Introduction

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

Page 10: RenderMan Introduction

Sample RIB File

##RenderMan RIB version 3.03 Display "RenderMan" "framebuffer" "rgb" Format 256 192 -1 LightSource "distantlight" 1 Translate 0 0 5 WorldBegin Surface "metal" Color [0.2 0.4 0.6] Polygon "P" [0.5 0.5 0.5 0.5 -0.5 0.5 -0.5 -0.5

0.5 -0.5 0.5 0.5] WorldEnd

Page 11: RenderMan Introduction

Shaders

• Write from scratch

• Obtained from software app, Slim or ShadeTree

• Must be compiled to object code

Page 12: RenderMan Introduction

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 */

Page 13: RenderMan Introduction

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)

Page 14: RenderMan Introduction

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.

Page 15: RenderMan Introduction

How To

• Generate this:

http://www.renderman.org/RMR/RIBS/bulb.rib

Page 16: RenderMan Introduction

.rib Code

# bulb.rib# Author: Scott Iverson

<[email protected]># Date: 6/9/95#

Display "bulb.tiff" "file" "rgb"Projection "perspective" "fov" 25Format 380 380 -1Rotate 0 0 0 1Rotate -0.570093918 1 0 0Rotate 5.71059326 0 1 0Translate -1 -2 10

Comments

Output to file (TIFF)Perspective, 25 deg FOVImage SizeCamera Rotation (NOOP)Angle, X, Y, Z

Move Camera

Page 17: RenderMan Introduction

.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" [-.3 -.2 1] AttributeBegin is like GL_PUSH AttributeBegin Rotate –90 degrees about x-axis Rotate -90 1 0 0 Use interpolation to determine shading of pixels that fall

between sampled points. Could be “constant” ShadingInterpolation "smooth"

Page 18: RenderMan Introduction

.rib Code

# base Apply the material “metal” to all future geometry Surface "metal“ Apply the color “blue” to all future geometry Color 0 0 1 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 0 .18 360 Pop the state (the handedness) AttributeEnd

Page 19: RenderMan Introduction

.rib Code

The Blue color remains and we draw a cylinder

Cylinder .18 0 .1 360

We move up a little (to the top of the cylinder)

Translate 0 0 .1

We change to another surface shader

Surface "matte”

We change to color “yellow”

Color 1 1 0

We draw a hyperboloid around base of bulb

Hyperboloid .18 0 0 .4 0 .15 360

Page 20: RenderMan Introduction

.rib CodeTranslate 0 0 .15Surface "metal"Color 1 .7 0Translate 0 0 .05Torus .4 .05 -90 90 360Translate 0 0 0.10Torus .4 .05 -90 90 360Translate 0 0 0.10Torus .4 .05 -90 90 360Translate 0 0 0.10Torus .4 .05 -90 90 360Translate 0 0 0.10Torus .4 .05 -90 90 360Translate 0 0 0.10Translate 0 0 -0.05

Move up a littleChange the surface shaderChange the color to be more red

Draw the torii for the threads

Page 21: RenderMan Introduction

.rib Code

# the glass partChange the shaderSurface "plastic" "roughness" .4Change the color to “white”Color 1 1 1Here is the truncated call to generate the bulb surfacePatchMesh "bicubic" 13 "nowrap" 7 "nowrap" "P" [

0.40 0.00 0 0.40 0.220913867…]Pop StackAttributeEndEnd of scene descriptionWorldEnd

Page 22: RenderMan Introduction

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

Page 23: RenderMan Introduction

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)

Page 24: RenderMan Introduction

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

Page 25: RenderMan Introduction

parameter list

Define the name of the texture map fileChar *mytmap = “grid.tiff”Create a new token name and define its typetmap will now be of type uniform stringRiDeclare (“tmap”, ”uniform string”);Use the shader, mytexture.sl, for the future geometryProvide the input parameter, mytmap, for the location

of the texture mapRiSurface (”mytexture”, (RtToken) ”tmap”, (RtPointer) &mytmap, RI_NULL);

Page 26: RenderMan Introduction

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

Page 27: RenderMan Introduction

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)

Page 28: RenderMan Introduction

What you need to do

• Apply a marble or wood shader to the pedestal– It should look good

Page 29: RenderMan Introduction

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)

Page 30: RenderMan Introduction

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

Page 31: RenderMan Introduction

RiPatch

• RiPatch (“bilinear”, RI_P, (RtPointer) corners, RI_ST, (RtPointer) textcoords, RI_NULL);– RtPoint corners[4];– static struct {RtFloat x,y} textcoords [4];

Page 32: RenderMan Introduction

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 email with instructions for those

who are still interested