1.17k likes | 1.54k Views
RenderMan. Jae Woo Kim Doctoral Student, Institute for Computer Graphics The George Washington University. The Goal of Today. What is RenderMan. API for graphics rendering Designed by Pixar in 1988 Photosurrealistic Rendering Used in many movies with digital effects Shading Language
E N D
RenderMan Jae Woo Kim Doctoral Student, Institute for Computer Graphics The George Washington University
What 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
RenderMan 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 … )
Rendering Overview Application Program RenderMan compliant Renderer Scene Description (RIB format) Shading Requests / Results Shading Requests / Results User-defined Shading Modules Standard Shading Modules
Application 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 (); 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 AttributeBegin Translate 0.0, 14.0, -8.3 Sufrace “plastic” Sphere 1 –1 1 360 AttributeEnd
BMRT • 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
How to Install BMRT • Remove old version • Unpack BMRT distribution • Set BMRT environment variables • Test BMRT
Set MBRT Environment Variables • Right click, select properties • Select Advanced tab • Click Environment Variables • Set variables My Computer
Listing 2.1 Geometry Light Surface property
Program 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!!!
Define 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 square[4] = { {.5,.5,.5 },{-.5,.5,.5}, {-.5,-.5,.5},{.5,-.5,.5} };
Define Surface Property RiSurface("constant", RI_NULL ); RiPolygon( … ); constant matte metal plastic Surface shaders … next week!
Define a light source RiLightSource("distantlight",RI_NULL ); Ambientlight Distantlight Pointlight spotlight Light source shaders … also next week!!
Listing 2.2 Color Translation Rotation Perspective projection
Projection and Color RiProjection( "perspective", RI_NULL ); perspective orthographic static RtColor Color = { .2, .4, .6 }; R G B RiSurface( … ); RiColor(Color); RiPolygon( … );
Scope of Graphics Environment RiSurface( … ); RiColor(Color); RiPolygon( … ); RiPolygon( … ); RiColor(Color); RiPolygon( … ); • Affects all objects after it • Modifies the previous attribute
Graphics 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.
Geometric Transformations y x 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!!!”
The Order of Geometric Transformations RiTranslate() RiRotate() RiRotate() RiTranslate()
Geometric 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.3 - 0.3 - 0.1 0.1 - 0.3 0 - 0.4
Declare 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
Declare 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
Declare 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
Save 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!!
Cubes • 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
Save 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();
Algorithm 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
Primitive 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
Sphere Cone Cylinder Hyperboloid Paraboloid Torus
Quadric 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
Sphere RiSphere(0.5, -0.5, 0.5, 360.0, RI_NULL); RiSphere(radius, zmin, zmax, thetamax, RI_NULL);
Cone RiCone(1.0, 0.5, 360.0, RI_NULL); RiSphere(height, radius, thetamax, RI_NULL);
Cylinder RiCylinder(0.5, -0.5, 0.5, 360.0, RI_NULL); RiCylinder( radius, zmin, zmax, thetamas, Parameterlist )
Hyperboloid RiHyperboloid(hyperpt1, hyperpt2, 360.0, RI_NULL); RiHyperboloid(point1, point2, thetamax, parameterlist);
Paraboloid RiParaboloid(0.5, 0.0, 0.9, 360.0, RI_NULL); RiParaboloid(rmax, zmin, zmax, thetamax, parameterlist);
Torus RiTorus(.4, .15, 0.0, 360.0, 360.0, RI_NULL); RiTorus(majorrad, minorrad, phimin, phimax, parameterlist);
Disk RiDisk(height, radius, thetamax, parameterlist);
Polygons • A simple, easy-to use class of surface • Defined by boundary, given as an ordered series of vertices • Square in Listing 2.x RtPoint square[4] = { {.5,.5,.5 },{-.5,.5,.5}, {-.5,-.5,.5},{.5,-.5,.5} }; RiPolygon( 4, RI_P, (RtPointer) square, RI_NULL );
How to Use RIB Models RiWorldBegin (); RiSurface ("matte", RI_NULL); RiReadArchive("bench.rib", RI_NULL, RI_NULL); RiWorldEnd();