Presentation is loading. Please wait.

Presentation is loading. Please wait.

RenderMan Jae Woo Kim Doctoral Student, Institute for Computer Graphics The George Washington University.

Similar presentations


Presentation on theme: "RenderMan Jae Woo Kim Doctoral Student, Institute for Computer Graphics The George Washington University."— Presentation transcript:

1 RenderMan Jae Woo Kim Doctoral Student, Institute for Computer Graphics The George Washington University

2 The Goal of Today

3 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

4 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 … )

5 Comparison: RenderMan vs. OpenGL / DirectX RenderManOpenGL/DirectX PhotorealismReasonable quality Offline renderingImmediate rendering Flexible shadingHardware shading Many compliant renderers Many hardware implementations

6 RenderMan vs Commercial packages RenderManCommercial Packages Both are for photorealistic rendering APIFull modeling/rendering /animation package Flexible shadingShading provided by the packages

7 Rendering Overview Application Program RenderMan compliant Renderer User-defined Shading Modules Standard Shading Modules Scene Description (RIB format) Shading Requests / Results

8 Application Program 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 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 All API calls starts with Ri prefix All API calls generate RIB(RenderMan Interface Bytestream) output

9 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

10 How to Install BMRT 1.Remove old version 2.Unpack BMRT distribution 3.Set BMRT environment variables 4.Test BMRT

11 Set MBRT Environment Variables 1.Right click, select properties 2.Select Advanced tab 3.Click Environment Variables 4.Set variables My Computer Variable Name Variable Value PATHC:\BMRT2.6\bin BMRTHOMEC:\BMRT2.6\ SHADERSC:\BMRT2.6\shaders

12 The first very simple program

13 Listing 2.1 Light Geometry Surface property

14 Program Structure RiBegin() //Initialize RenderMan Interface RiEnd() // End!!! RiWorldBegin() RiWorldEnd() RiPolygon( 4, RI_P, (RtPointer) square, RI_NULL ); RiLightSource("distantlight",RI_NULL ); RiSurface("constant", RI_NULL );

15 Define a polygon RiPolygon( 4, RI_P, (RtPointer) square, RI_NULL ); 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} }; Last argument Terminating token

16 Define Surface Property RiSurface("constant", RI_NULL ); RiPolygon( … ); constant matte metal plastic Surface shaders … next week!

17 Define a light source RiLightSource("distantlight",RI_NULL ); Ambientlight Distantlight Pointlight spotlight Light source shaders … also next week!!

18 The second very simple program

19 Listing 2.2 Color Perspective projection Translation Rotation

20 Projection and Color RiProjection( "perspective", RI_NULL ); perspective orthographic RiSurface( … ); RiColor(Color); RiPolygon( … ); static RtColor Color = {.2,.4,.6 }; R GB

21 Scope of Graphics Environment RiSurface( … ); RiColor(Color); RiPolygon( … ); RiColor(Color); RiPolygon( … ); Affects all objects after it Modifies the previous attribute

22 Graphics Environment Transformations Color Light sources Surface properties Etc. 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)

23 Geometric Transformations RiTranslate( 0.0, 0.0, 1.0 ); Specify the motion along the x, y, z axes respectively x y z RiRotate( 40.0, -1.0, 1.0, 0.0 ); Amount of rotation In degrees A point in 3D space Axis of rotation “Left handed rotation!!!”

24 The Order of Geometric Transformations RiTranslate()  RiRotate()RiRotate()  RiTranslate()

25 Geometric transformations accumulated! 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 A BCD 0 - 0.4

26 The third very simple program

27 Six rectangles

28 Declare a Cube (1) A cube consists of six rectangles, so create six rectangles (Listing 2.3)Listing 2.3 Near, far, left, right, bottom, top defined in a function UnitCube( ) Problem: Readability – Difficult to read and understand

29 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

30 Declare Cube Square 1; /* RiPolygon( ) */ Rotate 90 degree; /* RiRotate( ) */ Square 2; Rotate 90 degree; Square 3; Rotate 90 degree; Square 4; Square 1 Square 3 Square 2 Square 4

31 Save and Restore Geometric Transformations RiTransformBegin(); Square 1; Square 2 rotated; Square 3 rotated; Square 4 rotated; RiTransformEnd(); RiTransformBegin(); Square 5; RiTransformEnd(); RiTransformBegin(); Square 6; RiTransformEnd(); Save current transform. Restore current transform. Accumulated transform cleared!! Accumulated

32 The fourth program – a little complicated …

33

34 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

35 Save and restore attributes RiAttibuteBegin( ), RiAttributeEnd( ) Save and restore all the attributes of the graphics environment –Not only geometric transformations RiAttributeBegin(); RiAttributeEnd(); RiTransformBegin(); RiTransformEnd(); Transformations… Objects… Attributes … Objects …

36 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

37 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

38 Primitive Surfaces (I): Quadric Surfaces

39 Sphere TorusParaboloidHyperboloid CylinderCone

40 Quadric surfaces Finite curve in two dimensions is swept in three-dimensional space about one axis to create a surface Sphere Torus Cone Cylinder Hyperboloid Paraboloid Circle Line segment, one end lying on the axis of rotation A line segment parallel to the axis Generalization of a line segment, By rotating an arbitrary line segment Paraola y = x 2

41 Sphere RiSphere(0.5, -0.5, 0.5, 360.0, RI_NULL); RiSphere(radius, zmin, zmax, thetamax, RI_NULL);

42 Cone RiCone(1.0, 0.5, 360.0, RI_NULL); RiSphere(height, radius, thetamax, RI_NULL);

43 Cylinder RiCylinder(0.5, -0.5, 0.5, 360.0, RI_NULL); RiCylinder( radius, zmin, zmax, thetamas, Parameterlist )

44 Hyperboloid RiHyperboloid(hyperpt1, hyperpt2, 360.0, RI_NULL); RiHyperboloid(point1, point2, thetamax, parameterlist);

45 Paraboloid RiParaboloid(0.5, 0.0, 0.9, 360.0, RI_NULL); RiParaboloid(rmax, zmin, zmax, thetamax, parameterlist);

46 Torus RiTorus(.4,.15, 0.0, 360.0, 360.0, RI_NULL); RiTorus(majorrad, minorrad, phimin, phimax, parameterlist);

47 Disk RiDisk(height, radius, thetamax, parameterlist);

48 Primitive Surfaces (II): Polygons

49 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 );

50 How to Use RIB Models RiWorldBegin (); RiSurface ("matte", RI_NULL); RiReadArchive("bench.rib", RI_NULL, RI_NULL); RiWorldEnd();

51 teapot.rib

52 trashcan.rib

53 column.rib

54 bench.rib

55 pen.rib

56 2 nd Day

57 The goal of Today

58 Geometric Transformations and Hierarchical Modeling

59 Geometric Transformations

60 Basic 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 )

61 Scale RiScale( 0.2, 0.2, 0.2); 1.0 0.2

62 Skew RiSkew( 45.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0 );

63 General Linear Transformation RiConcateTransform( transform ) RiIdentity() RiTransform( 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 };

64 Concatenation 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

65 Clearing 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

66 Example RiWorldBegin(); RiConcatTransform( t1 ); Object1 RiConcatTransform( t2 ); Object2 RiTransformBegin(); RiIdentity(); RiConcatTransform( t3 ); Object3; RiTransformEnd(); RiConcatTransform( t4 ); Object4; RiWorldEnd();

67 More general transformation Replaces the current transformation with the transformation specified by the transform matrix RiTransform( transform ) Equivalent to RiIdentity(); RiConcatTransform( transform ) RtMatrix transform

68 Hierarchical 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 …”

69 Why Hierarchical Modeling? Quadric Polygonal Parametric Building blocks from which real objects are built Don’t have much inherent visual appeal Object : A set of surfaces grouped together Treated as a single entity for purposes of shading, motion, duplication, or assembling other objects

70 How to implement objects RiAttributeBegin(); Attribute setting Primitive surfaces RiAttributeEnd(); OR RiTransformBegin(); Transformations Primitive surfaces RiTransformEnd(); To avoid the waste of efforts …

71 Hierarchical Model Body Upper_arm1 Lower_arm1 Upper_finger1 Lower_finger1 Upper_finger2 Lower_finger2 Upper_finger3 Lower_finger3 Upper_arm2 Lower_arm2 Upper_finger4 ………

72 RiAttributeBegin(); Attributes Upper_arm1 RiAttributeBegin(); Attributes Lower_arm1 RiAttributeBegin(); Attributes Finger1 RiAttributeEnd(); RiAttributeBegin(); Attributes Finger2 RiAttributeEnd(); RiAttributeBegin(); Attributes Finger3 RiAttributeEnd(); Graphics environment stack, Different attributes for each part Local coordinate system Represent tree structure

73 Solid Modeling

74 Constructive 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

75 Constructive Solid Geometry RiSolidBegin(RI_PRIMITIVE); Sphere; 3 cylinders; RiSolidEnd(); RI_PRIMITIVE RI_UNION RI_INTERSECTION RI_DIFFERENCE

76 Why constructive solid geometry?? Very difficult to represent using polygonal, quadric, and parametric models

77 Combination of Primitives (Program Solid)

78 Difference (Program Bowling)

79 Object Duplication Object may be gathered into an independent description RiObjectBegin() – RiObjectEnd() A program can duplicate or instance the description with a single routine call

80 Example Cube = RiObjectBegin(); UnitCube(); RiObjectEnd; RiAttributeBegin(); … Attributes; RiObjectInstance(cube); RiAttributeEnd();

81 Lighting and Shading

82 What ?? 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 …

83 Information 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 … )

84 Shading 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 light’s color as it travels from object to viewer –Perhaps by particles in the atmosphere

85 Shading Pipeline Light source Surface Camera or Eye (1) (2) (3) (1)Light source shaders (2)Surface shaders (3)Volume shaders

86 Shaders Application Program RenderMan compliant Renderer User-defined Shading Modules Standard Shading Modules Scene Description (RIB format) Shaders

87 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

88 Using 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

89 Environment 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

90 Light Source Shaders

91 Light 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 )

92 Switching 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

93 Predefined 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

94 Ambient 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)

95 Ka=1.0 Ka=0.8Ka=0.6 Ka=0.4Ka=0.2Ka=0.1 Ambient Light, Intensity = 1.0

96 Distant 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 )

97 Kd=1.0 Ks=1.0 Kd=0.8 Ks=1.0 Kd=0.6 Ks=1.0 Ka=0.4 Ks=0.5 Ka=0.2 Ks=0.5 Ka=0.1 Ks=0.5 Distant Light, Intensity = 1.0

98 Point 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 )

99 Point Light, Intensity = 1.0, at (0.0, 0.0, -0.5)

100 Spotlight 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

101 Point Light, Intensity = 1.0, from (0.0, 0.0, -0.5) to (0.0, 0.0, 0.0)

102 Altogether!!

103 Surface Shaders

104 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) ) –Shader’s instance variables (shininess controlled)

105 Elements 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

106 Color 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

107 Types 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

108 Example Constantmatteplastic paintedplastic shinymetalmetal

109 Shaders User Defined Shaders  slc myshader.sl  myshader.sl How to use existing shaders Just name the shaders in shaders directory! RiSurface(shader_name, parameterlist)

110 Examples brickfunkyglassceramic greenmarbleplankscreen

111 Rendering  program_name > xxx.rib  rgl xxx.rib  rendrib –d 16 xxx.rib  rendrib xxx.rib  iv xx.tif

112 Further Studies /BMRT2.6/examples

113 Programming 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

114 Example of assignment Submitted by Pixar

115 Resources Upstill, RenderMan Companion, 1989, ISBN 0201508680 Apodaca and Gritz, Advanced RenderMan, 2000, ISBN 1558606181 SIGGRAPH Course Note on RenderMan and more @ course webpage


Download ppt "RenderMan Jae Woo Kim Doctoral Student, Institute for Computer Graphics The George Washington University."

Similar presentations


Ads by Google