Title: RenderMan
1RenderMan
- Jae Woo Kim
- Doctoral Student, Institute for Computer Graphics
- The George Washington University
2The Goal of Today
3What is RenderMan
- API for graphics rendering
- Designed by Pixar in 1988
- Photosurrealistic Rendering
- Used in many movies with digital effects
- Shading Language
- Flexibility for complex digital effects
- Many RenderMan compliant Renderers
4RenderMan compliant Renderers
- PhotoRealistic RenderMan (PRMan)
- by Pixar
- 5,000 per cop
- Blue Moon Rendering Tools (BMRT)
- Made by Dr. Larry Gritz
- Maintained by Exluna Inc.
- Free for non-commercial use ( until last year I
guess )
5Comparison RenderMan vs. OpenGL / DirectX
RenderMan OpenGL/DirectX
Photorealism Reasonable quality
Offline rendering Immediate rendering
Flexible shading Hardware shading
Many compliant renderers Many hardware implementations
6RenderMan vs Commercial packages
RenderMan Commercial Packages
Both are for photorealistic rendering Both are for photorealistic rendering
API Full modeling/rendering /animation package
Flexible shading Shading provided by the packages
7Rendering Overview
Application Program
RenderMan compliant Renderer
Scene Description (RIB format)
Shading Requests / Results
Shading Requests / Results
User-defined Shading Modules
Standard Shading Modules
8Application Program
- All API calls starts with Ri prefix
- All API calls generate RIB(RenderMan Interface
Bytestream) output
RiAttributeBegin () RiTranslate (0.0, 14.0,
-8.3) RiSufrace (plastic, RI_NULL) RiSphere
(1.0, -1.0, 1.0, 360.0, RI_NULL) RiAttributeEnd
()
AttributeBegin Translate 0.0, 14.0, -8.3 Sufrace
plastic Sphere 1 1 1 360 AttributeEnd
RiAttributeBegin () RiTranslate (0.0, 14.0,
-8.3) RiSufrace (plastic, RI_NULL) RiSphere
(1.0, -1.0, 1.0, 360.0, RI_NULL) RiAttributeEnd
()
AttributeBegin Translate 0.0, 14.0, -8.3 Sufrace
plastic Sphere 1 1 1 360 AttributeEnd
9BMRT
- Most widely used public domain RenderMan
compliant renderer - Two versions of renderer
- rgl previewer based on OpenGL
- rendrib Photorealistic rendering with ray
tracing / radiosity - Input RIB stream
- Output image files or framebuffer
10How to Install BMRT
- Remove old version
- Unpack BMRT distribution
- Set BMRT environment variables
- Test BMRT
11Set MBRT Environment Variables
- Right click, select properties
- Select Advanced tab
- Click Environment Variables
- Set variables
My Computer
Variable Name Variable Value
PATH C\BMRT2.6\bin
BMRTHOME C\BMRT2.6\
SHADERS C\BMRT2.6\shadersÂ
12The first very simple program
13Listing 2.1
Geometry
Light
Surface property
14Program Structure
RiBegin() //Initialize RenderMan Interface
RiLightSource("distantlight",RI_NULL )
RiWorldBegin()
RiSurface("constant", RI_NULL )
RiPolygon( 4, RI_P, (RtPointer) square, RI_NULL
)
RiWorldEnd()
RiEnd() // End!!!
15Define a polygon
RiPolygon( 4, RI_P, (RtPointer) square, RI_NULL )
Last argument Terminating token
The number of vertices
Token-value pair An array of points giving
positions in 3D space
RtPoint square4 .5,.5,.5
,-.5,.5,.5, -.5,-.5,.5,.5,-.5,.5
16Define Surface Property
RiSurface("constant", RI_NULL )
RiPolygon( )
constant matte metal plastic
Surface shaders next week!
17Define a light source
RiLightSource("distantlight",RI_NULL )
Ambientlight Distantlight Pointlight spotlight
Light source shaders also next week!!
18The second very simple program
19Listing 2.2
Color
Translation
Rotation
Perspective projection
20Projection and Color
RiProjection( "perspective", RI_NULL )
perspective orthographic
static RtColor Color .2, .4, .6
R
G
B
RiSurface( ) RiColor(Color) RiPolygon( )
21Scope of Graphics Environment
RiSurface( ) RiColor(Color) RiPolygon(
) RiPolygon( ) RiColor(Color) RiPolygon(
)
- Affects all objects after it
- Modifies the previous attribute
22Graphics Environment
Attributes of objects
- Affects all objects after it
- Modifies the previous attribute (not
- for the transformations)
- Called before the object declaration
- Sticks to that object
- Default values (not for light sources)
Transformations Color Light sources Surface
properties Etc.
23Geometric Transformations
x
y
z
RiTranslate( 0.0, 0.0, 1.0 )
Specify the motion along the x, y, z axes
respectively
RiRotate( 40.0, -1.0, 1.0, 0.0 )
A point in 3D space
Amount of rotation In degrees
Axis of rotation
Left handed rotation!!!
24The Order of Geometric Transformations
RiTranslate() ? RiRotate()
RiRotate() ? RiTranslate()
25Geometric transformations accumulated!
A
B
C
D
RiTranslate(-0.3,0.0,0.0) Object A
RiTranslate(-0.1,0.0,0.0) Object
B RiTranslate(0.1,0.0,0.0) Object
C RiTranslate(0.3,0.0,0.0) Object D
0.1
0.3
- 0.1
- 0.3
0
- 0.3
- 0.4
26The third very simple program
27Six rectangles
28Declare a Cube (1)
A cube consists of six rectangles, so create six
rectangles (Listing 2.3)
Near, far, left, right, bottom, top defined in a
function UnitCube( )
Problem Readability Difficult to read and
understand
29Declare a Cube (2)
To use previously defined, simpler objects to
createmore complex ones
Cube is nothing but a set of squares in different
positions and orientation
Therefore, create six identical squares, and then
transform each square to be located appropriate
position in 3D space
Click me Listing 2.5
30Declare Cube
Square 1 / RiPolygon( ) / Rotate 90
degree / RiRotate( ) / Square 2 Rotate 90
degree Square 3 Rotate 90 degree Square 4
Square 4
Square 3
Square 1
Square 2
31Save and Restore Geometric Transformations
Save current transform.
RiTransformBegin() Square 1 Square 2
rotated Square 3 rotated Square 4
rotated RiTransformEnd() RiTransformBegin()
Square 5 RiTransformEnd() RiTransformBegin(
) Square 6 RiTransformEnd()
Accumulated
Restore current transform. Accumulated transform
cleared!!
32The fourth program a little complicated ?
33(No Transcript)
34Cubes
- A number of small cubes
- R, G, B values of the cube vary with x, y, z
coordinates - Near-lower-left corner is black, far-upper-right
corner is - white
- Each minicube given a color appropriate to its
position - Inner loop of ColorCube( ) cycles n times
through x, y, - z creating unit cubes, scaling them
appropriately, then - translating them into position
35Save and restore attributes
- RiAttibuteBegin( ), RiAttributeEnd( )
- Save and restore all the attributes of the
graphics environment - Not only geometric transformations
RiAttributeBegin()
RiTransformBegin()
Transformations
Attributes
Objects
Objects
RiAttributeEnd()
RiTransformEnd()
36Algorithm
Loop x 0 to n-1 Loop y 0 to n-1 Loop z
0 to n-1 Set color values
RiTransformBegin() Transformations
Scale Call UnitCube()
RiTransformEnd()
Listing 2.6
37Primitive Surfaces
Everything visible in a scene is ultimately
composed of surfaces
- Quadric Surfaces Defined by quadric equations
in two - dimensional space
- Polygonal SurfacesBoundaries are given by a
connected - series of line segments
- Parametric Surfaces Free form polynomial curved
surfaces
38Primitive Surfaces (I) Quadric Surfaces
39Sphere
Cylinder
Cone
Torus
Paraboloid
Hyperboloid
40Quadric surfaces
Finite curve in two dimensions is swept in
three-dimensional space about one axis to create
a surface
Sphere
Circle
Torus
Line segment, one end lying on the axis of
rotation
Cone
Cylinder
A line segment parallel to the axis
Generalization of a line segment, By rotating an
arbitrary line segment
Hyperboloid
Paraboloid
Paraola y x2
41Sphere
RiSphere(0.5, -0.5, 0.5, 360.0, RI_NULL)
RiSphere(radius, zmin, zmax, thetamax,
RI_NULL)
42Cone
RiCone(1.0, 0.5, 360.0, RI_NULL)
RiSphere(height, radius, thetamax,
RI_NULL)
43Cylinder
RiCylinder(0.5, -0.5, 0.5, 360.0,
RI_NULL) RiCylinder( radius, zmin, zmax,
thetamas, Parameterlist )
44Hyperboloid
RiHyperboloid(hyperpt1, hyperpt2, 360.0,
RI_NULL) RiHyperboloid(point1, point2,
thetamax, parameterlist)
45Paraboloid
RiParaboloid(0.5, 0.0, 0.9, 360.0,
RI_NULL) RiParaboloid(rmax, zmin, zmax,
thetamax, parameterlist)
46Torus
RiTorus(.4, .15, 0.0, 360.0, 360.0,
RI_NULL) RiTorus(majorrad, minorrad, phimin,
phimax, parameterlist)
47Disk
RiDisk(height, radius, thetamax, parameterlist)
48Primitive Surfaces (II) Polygons
49Polygons
- A simple, easy-to use class of surface
- Defined by boundary, given as an ordered series
of vertices - Square in Listing 2.x
RtPoint square4 .5,.5,.5
,-.5,.5,.5, -.5,-.5,.5,.5,-.5,.5 RiP
olygon( 4, RI_P, (RtPointer) square, RI_NULL )
50How to Use RIB Models
RiWorldBegin () RiSurface ("matte", RI_NULL)
RiReadArchive("bench.rib", RI_NULL,
RI_NULL) RiWorldEnd()
51teapot.rib
52trashcan.rib
53column.rib
54bench.rib
55pen.rib
562nd Day
57The goal of Today
58Geometric Transformations and Hierarchical
Modeling
59Geometric Transformations
60Basic geometric transformations in RenderMan
- RiTranslate( dx, dy, dz )
- RiRotate( angle, dx, dy, dz )
- RiScale( sx, sy, sz)
- RiSkew( angle, dx1, dy1, dz1, dx2, dy2, dz2 )
61Scale
RiScale( 0.2, 0.2, 0.2)
1.0
0.2
62Skew
RiSkew( 45.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0 )
63General Linear Transformation
RiConcateTransform( transform ) RiIdentity() RiTra
nsform( transform ) RtMatrix transform
RiScale( s1, s2, s3 )
RiConcateTransform( t )
RtMatrix t s1, 0.0, 0.0, 0.0, 0.0, s2, 0.0,
0.0, 0.0, 0.0, s3, 0.0, 0.0, 0.0, 0.0, 1.0
64Concatenation of transformation
- RiConcatTransform()
- Concatenates transformation specified by the
transform matrix onto the current transformation - RtMatrix is a 4 x 4 homogeneous transformation
matrix of RtFloat values - Row major order
65Clearing the current transformation
- RiIdentity()
- When it is necessary to define an object directly
in world space - To reset the current transformation
- May be enclosed in a transform block
66Example
RiWorldBegin() RiConcatTransform( t1 )
Object1 RiConcatTransform( t2 ) Object2
RiTransformBegin() RiIdentity()
RiConcatTransform( t3 ) Object3
RiTransformEnd() RiConcatTransform( t4 )
Object4 RiWorldEnd()
67More general transformation
- Replaces the current transformation with the
transformation specified by the transform matrix - RiTransform( transform )
- Equivalent to
RiIdentity() RiConcatTransform( transform
) RtMatrix transform
68Hierarchical Modeling
Combine simple objects into more complex ones
Conceptual convenience to think of a cube instead
of this square and that square and that square
69Why Hierarchical Modeling?
Quadric Polygonal Parametric
Dont have much inherent visual appeal
Building blocks from which real objects are built
Object
A set of surfaces grouped together
Treated as a single entity for purposes of
shading, motion, duplication, or assembling other
objects
70How to implement objects
RiAttributeBegin() Attribute setting
Primitive surfaces RiAttributeEnd()
OR
RiTransformBegin() Transformations
Primitive surfaces RiTransformEnd()
To avoid the waste of efforts
71Hierarchical Model
Body Upper_arm1 Lower_arm1
Upper_finger1 Lower_finger1
Upper_finger2 Lower_finger2
Upper_finger3 Lower_finger3
Upper_arm2 Lower_arm2
Upper_finger4
72RiAttributeBegin() Attributes Upper_arm1
RiAttributeBegin() Attributes
Lower_arm1 RiAttributeBegin()
Attributes Finger1 RiAttributeEnd()
RiAttributeBegin() Attributes
Finger2 RiAttributeEnd()
RiAttributeBegin() Attributes
Finger3 RiAttributeEnd()
RiAttributeEnd() RiAttributeEnd()
- Graphics environment stack,
- Different attributes for each part
- Local coordinate system
- Represent tree structure
73Solid Modeling
74Constructive Solid Geometry
- The ability to use one object to modify the shape
of another object - Example) a drilled machine part undrilled part
a cylinder removed from it - Defines an object by applying set operators to
the points in space inside other objects - Combination of primitives
- Union
- Intersection
- Difference
75Constructive Solid Geometry
RiSolidBegin(RI_PRIMITIVE) Sphere 3
cylinders RiSolidEnd()
RI_PRIMITIVE RI_UNION RI_INTERSECTION RI_DIFFERENC
E
76Why constructive solid geometry??
- Very difficult to represent using polygonal,
quadric, and parametric models
77Combination of Primitives (Program Solid)
78Difference(Program Bowling)
79Object Duplication
- Object may be gathered into an independent
description - RiObjectBegin() RiObjectEnd()
- A program can duplicate or instance the
description with a single routine call
80Example
Cube RiObjectBegin() UnitCube() RiObjectEnd
RiAttributeBegin() Attributes
RiObjectInstance(cube) RiAttributeEnd()
81Lighting and Shading
82What ??
- How to manipulate the appearance of objects
- How to create and position light sources
- How to color surfaces with something other than a
flat color - Change in emphasis, from shape to shading
83Information required
- To calculate the color of any surface point
- Object must be placed in a scene
- Surface properties
- Light sources for illuminating the object
- Camera position
- Atmosphere (e.g., smog )
84Shading Pipeline
- Illumination
- Determines intensity and color of light
- From various sources
- Reflection / Transmission
- Simulates interaction of light with surface
material - Calculates intensity and color of reflected light
- Atmospheric effects
- Modification of lights color as it travels from
object to viewer - Perhaps by particles in the atmosphere
85Shading Pipeline
(1)
Light source
- Light source shaders
- Surface shaders
- Volume shaders
(3)
(2)
Camera or Eye
Surface
86Shaders
Application Program
RenderMan compliant Renderer
Scene Description (RIB format)
User-defined Shading Modules
Standard Shading Modules
Shaders
87Shaders
- Programmed procedure
- Written in RenderMan Shading Language
- Invoked at realtime
- Controls part of shading calculation
- Two types of shaders
- Built-in shaders (point light source, distant
light source, plastic surface, matte surface,
etc.) - User-defined shaders
88Using Shaders
- Several instances of light sources
- There may be several light sources in a scene
- Each with different color, intensity, position
- Different shaders may use distinct instances of
the same shader - Current instance
- Part of graphics environment like surface color
- Default values for each unassigned instance
variable are provided by the shader
89Environment variables used by shaders
- Shaders use
- Instance variables
- Certain elements of graphics environment (color
and opacity) - RiColor( Cs ), RtColor Cs
- RiOpacity( Os ), RtColor Os
- Changes current surface color and opacity in the
graphics environment - Examples
- completely transparent surface has opacity 0 in
all channels - completely opaque surface has opacity 1 in all
chanells - A colored filter would have different values in
each channel
90Light Source Shaders
91Light source shaders
- Calculate intensity, color, direction of light
source to a point on a surface - RtLightHandle RiLightSource( name,
parameterlist ) - Adds new light source to a scene
- By creating an instance of shader identified by
name - RtLightHandle may be used later to turn the light
on and off - Only light source shaders have multiple instances
available at the same time (do not replaced but
added )
92Switching a light on and off
- Why turn on and off??
- Light sources remain, once they are created
- RiIlluminate( light, onoff )
- RtLightHandle light
- RtBoolean onoff / RI_TRUE RI_FALSE /
- The state of light source is part of graphics
environment - The list of light source is maintained outside of
the graphics state - But the state of each light is part of the
graphics state
93Predefined Light Sources
- Predefined Light sources
- Ambient light source
- Distant light source
- Point light source
- Spotlight light source
- No default light source
- So light sources must be declared explicitly
- Or use a constant surface shader
- Requires no light source
94Ambient Light
RiLightSource( ambientlight,
intensity, intensity,
lightcolor, color, RI_NULL )
RtFloat intensity RtColor color
- Distributes light uniformly throughout space in
all directions - So, throws the same light on every surface
regardless of the - surface positions and orientations
- Default values, intensity (1.0), color (maximum
white)
95Ambient Light, Intensity 1.0
Ka1.0
Ka0.8
Ka0.6
Ka0.4
Ka0.2
Ka0.1
96Distant Light
RiLightSource( distantlight,
intensity, intensity,
lightcolor, color, from,
from, to, to,
RI_NULL ) RtFloat intensity RtColor
color RtPoint from, to
- Flows light uniformly in space in one direction
- Surface of like orientation receive the same
amount of light - independent of location
- However, surfaces of different orientation are
illuminated - differently
- Default from ( 0, 0, 0 ), to ( 0, 0, 1 )
97Distant Light, Intensity 1.0
Kd1.0 Ks1.0
Kd0.8 Ks1.0
Kd0.6 Ks1.0
Ka0.4 Ks0.5
Ka0.2 Ks0.5
Ka0.1 Ks0.5
98Point Light
RiLightSource( pointlight,
intensity, intensity,
lightcolor, color, from,
from, RI_NULL ) RtFloat
intensity RtColor color RtPoint from
- Distributes light through space from a single
point - Shines evenly in all directions
- Intensity of light falls off with the square of
the distance - Default from ( 0, 0, 0 )
99Point Light, Intensity 1.0, at (0.0, 0.0, -0.5)
100Spotlight
RiLightSource( spotlight, intensity,
intensity, lightcolor, color, from, from,
to, to, coneangle, coneangle,
conedeltangle, conedeltangle,
beamdistribution, beamdistribution, RI_NULL
) RtFloat intensity RtColor color
RtPoint from, to RtFloat coneangle,
conedeltangle, beamdistribution
- A light source with both position and direction
- Simulates a cone of light emitted from one point
from toward - another point to
- Intensity falls off exponentially with angle
from the center of cone
101Point Light, Intensity 1.0, from (0.0, 0.0,
-0.5) to (0.0, 0.0, 0.0)
102Altogether!!
103Surface Shaders
104Surface Shaders
- To determine the color of light reflecting from a
point on a surface - Surface shading process
- The light arriving (obtained from light source
shader) - The nature of the surface
- The character of the surface
- Shader ( e.g., specular (shiny) )
- Shaders instance variables (shininess controlled)
105Elements of surface shading
- Used information
- The direction, color and intensity of the
arriving light - Color of the surface (RiColor())
- Opacity of the surface
- The orientation of the surface
- Viewing direction
106Color of reflections
- Determined by light color surface color
- Surface Color
- Gives the proportion of red, green or blue that
surface reflects
Example) Light 1.0, 1.0, 1.0 ? Surface color
appears
107Types of reflection
- Ambient, diffuse, specular reflections
- The principal difference between the shaders is
in how they handle those three components - The weight they give to each
108Example
Constant
matte
plastic
paintedplastic
shinymetal
metal
109Shaders
- User Defined Shaders
- slc myshader.sl
- myshader.sl
- How to use existing shaders
- Just name the shaders in shaders directory!
- RiSurface(shader_name, parameterlist)
110Examples
brick
funkyglass
ceramic
greenmarble
plank
screen
111Rendering
- program_name gt xxx.rib
- rgl xxx.rib
- rendrib d 16 xxx.rib
- rendrib xxx.rib
- iv xx.tif
112Further Studies
/BMRT2.6/examples
113Programming Assignment
- Draw a interesting, beautiful, wonderful,
fantastic, artistic image or images - Put some quadric and polygonal models
- Put some pre-existing models on the web
- Transform them to make the scene more interesting
- Use some light sources
- Use some shaders including the existing ones
114Example of assignment
Submitted by Pixar ?
115Resources
- Upstill, RenderMan Companion, 1989, ISBN
0201508680 - Apodaca and Gritz, Advanced RenderMan, 2000, ISBN
1558606181 - SIGGRAPH Course Note on RenderMan and more _at_
course webpage