530 likes | 723 Views
RenderMan (Introduction). Objective. Understanding of graphics algorithms Rendering pipeline Understanding of Technical Director’s role Learning the Shading Language Notion of Shader. Lecture Outline. Computer graphical Image Synthesis RenderMan – A Brief History Using BMRT The RIB File
E N D
Objective • Understanding of graphics algorithms • Rendering pipeline • Understanding of Technical Director’s role • Learning the Shading Language • Notion of Shader
Lecture Outline • Computer graphical Image Synthesis • RenderMan – A Brief History • Using BMRT • The RIB File • The Shading Language • Writing a Shader
Computer graphical Image Synthesis : Image Synthesis Three routes to image synthesis
Computer graphical Image Synthesis : Rendering A renderer being fed a scene description
Computer graphical Image Synthesis : Rendering RenderMan converts RIB inputs into images RIB: Renderman Interface Bytestream
Computer graphical Image Synthesis : Rendering Object Space Clipping Culling World Space Final Result Camera View Stages in a classical rendering pipeline
The RenderMan History • Proposed by Pixar in 1989 • Its design is based on • Lucasfilm’s REYES (Renders Everything You Ever Saw) in 1981 (Pixar is originally the computer division of Lucasfilm) • Robert Cook’s Shade Trees [COOK84] • Since then RenderMan is referred as the industry standard of high-quality graphics production
What is RenderMan? • An open specification – anybody can implement the standard • Pixar RenderMan, BMRT, RenderDotC • A scenefile description for 3D rendering like PostScript is for 2D • Programmable shading language • C Programming Interface • Can be a standalone program or called from RIB.
What is RenderMan • Separation of Modeling and Rendering • RenderMan serves as the interface. • Scene = Shape + Shading • Two “languages” • Geometry(Shape) - set of C subroutines • Shading - a C-like language • Geometry code can be run directly, or output to RIB file • Shading code is compiled to byte-code • The power of RenderMan is in the shading part
RenderMan Interface • RenderMan Interface Bytestream (RIB): Geometry • The scene description language (.rib) can be created by a C program, generated by the modeler, or typed manually • The scene description file defined the geometry and some rendering parameters • Shading Language (SL): Shading • A skillful programmer develops the shader (.sl), a C-like program, to control how a surface is shaded. It is then complied to intermediate code (.slo) • The intermediate shader code is interpreted to control the shading process • The .rib and .slo are fed to the renderer for rendering
RenderMan Interface RIB as an interface between modelers and renderers
Rendering program • RenderMan compliant renderer • Pixar’s Photorealistic RenderMan (PRMan) • Exluna’s BMRT, Entropy • ART’s RenderDrive
BMRT (Blue Moon Rendering Toolkit) • A free implementation of the RenderMan standard • A public-domain implementation of Pixar Photorealistic RenderMan (PRMan). • Three main components: • Rendrib: the renderer • Rgl: quick rendering for preview • Slc: shading language compiler • Download • Pixar Renderman BMRT Render 2.6.rar
How to Install BMRT • Unpack the BMRT Distribution • Choose a directory into which BMRT will be installed (e.g. “c:\BMRT2.6”) • Set BMRT Environment Variables • Variable: PATH Value:[…];C:\BMRT2.6\bin (i.e., add C:\BMRT2.6\bin to the end of the current PATH value.) • Variable: BMRTHOMEValue: C:\BMRT2.6\ • Variable: SHADERS Value: C:\BMRT2.6\shaders
How to Install BMRT • Testing BMRT • Command cmd • C:\> cd BMRT2.6\examples C:\BMRT2.6\examples\> • Test rgl • C:\BMRT2.6\examples\> c:\BMRT2.6\bin\rgl teapots.rib hit the esc key or q to close the window after it finishes rendering. • C:\BMRT2.6\examples\> c:\BMRT2.6\bin\rgl limbo.rib • Test slc • C:\BMRT2.6\shaders\> c:\BMRT2.6\bin\slc funkyglass.sl • C:\BMRT2.6\shaders\> c:\BMRT2.6\bin\slc screen_aa.sl • C:\BMRT2.6\shaders\> c:\BMRT2.6\bin\slc screen.sl • Test rendrib • C:\BMRT2.6\examples\> c:\BMRT2.6\bin\rendrib -d 16 shadtest.rib • The -d option to rendrib will display the results directly to the screen • press the w key while over the window to write out a TIFF file • the esc key or q will quit and close the window • Testiv • C:\BMRT2.6\examples\> c:\BMRT2.6\bin\iv balls1.tif
Using BMRT • Rendrib – the command line renderer • Rendrib [flags] <filename> • -d • Forces display to screen • Put a number afterward and it will render in multiple passes • -v – verbose. Tells you more about what is happening while you render. • -stats – displays some statistics after rendering about CPU usage, etc. • Slc – the shading language compiler • Slc [flags] <filename> • -dso compile to machine code • -o name output to specified name
A Simple Scene #min.rib - a minimal scene Display "min.tiff" "file" "rgb" Projection "perspective" WorldBegin Translate 0 0 2 Sphere 1 -1 1 360 WorldEnd • Making RIB • # : comment (주석) • Display • Create a file “min.tiff” • Color information “rgb” • “file” write to “file” • “framebuffer” on the screen • Projection • “perspective” projection • WorldBegin / WorldEnd • WorldBegin prepare to draw • WorldEnd the scene is finished • Transformation / Modeling • Translation z 축으로 2만큼 이동 • Sphere radius: 1, zmin: -1, zmax: 1, theta: 360
Transformation # beginend.rib Display "beginend.tiff" "file" "rgb" Projection "perspective" WorldBegin # move everything back 2 units Translate 0 0 2 TransformBegin # Everything that follows is one unit left Translate -1 0 0 Sphere 1 -1 1 360 TransformEnd TransformBegin # Everything that follows is one unit right Translate 1 0 0 Sphere 1 -1 1 360 TransformEnd WorldEnd • Transformation • Translate x y z • Scale x y z • Rotate angle x y z • TransformBegin • TransformEnd
Color # Display "beginend.tiff" "file" "rgb" Projection "perspective" WorldBegin Translate 0 0 2 Color [ 1 0 0 ] AttributeBegin Translate -1 0 0 Color [ 1 1 0 ] Sphere 1 -1 1 360 AttributeEnd #This resets the colour back to red AttributeBegin Translate 1 0 0 Sphere 1 -1 1 360 AttributeEnd WorldEnd • Color Color [ red green blue ] 0~1 • AttributeBegin : 속성 설정 시작 • AttributeEnd : 속성 설정 종료
Color • Opacity Opacity [ red green blue ] 0: Transparency (투명) 1: Opaque (불투명) Display "opacity.tiff" "file" "rgb" Projection "perspective" #PixelSamples 3 3 WorldBegin #move everything back 2 units Translate 0 0 2 Color [ 1 0 0 ] AttributeBegin Translate -0.25 0 0 Color [ 0 1 0 ] Opacity [ 0.5 0.5 0.5 ] Sphere 1 -1 1 360 AttributeEnd AttributeBegin Translate 0.25 0 0 # Opacity [ 0.3 0.3 0.3 ] Sphere 1 -1 1 360 AttributeEnd WorldEnd
Camera Setup • Camera • Format : 이미지 크기 • “fov” • Field of View # fov.rib Display "fov.tiff" "file" "rgb" Format 640 480 1.0 Projection "perspective" "fov" [ 25 ] # Projection "perspective" "fov" [ 90 ] Translate 0 0 10 WorldBegin Sphere 2 -2 2 360 WorldEnd
Blocks • WorldBegin, WorldEnd • FrameBegin, FrameEnd frameno • AttributeBegin, AttributeEnd • TransformBegin, TransformEnd • Stacking must always be balanced • AttributeBegin • TransformBegin • AttributeEnd • TransformEnd is not legal
Simple Surface • Parametric Quadrics • Sphere • Cone • Cylinder • Disk • Hyperboloid • Paraboloid • Torus
Simple Surface • Sphere Sphere <radius> <zmin> <zmax> <sweep_angle> # sweep.rib Display “sweep.tiff" “file" "rgb" Projection "perspective" WorldBegin Translate 0 0 4 Sphere 2 -2 2 270 WorldEnd
Simple Surface • Cylinder Cylinder <radius> <zmin> <zmax> <sweep_angle> # Cylin.rib Display "Cylin.tiff" "file" "rgb" Projection "perspective" WorldBegin Translate 0 0 7 Rotate 90 1 0 0 Cylinder 2 -3 3 270 WorldEnd
Simple Surface • Cone Cone <height> <radius> <sweep_angle> # Cone.rib Display "Cone.tiff" "file" "rgb" Projection "perspective" WorldBegin Translate 0 -2.5 7 Rotate -90 1 0 0 Cone 5 2 90 WorldEnd
Simple Surface • Paraboloid Paraboloid <radius_at_zmax> <zmin> <zmax> <sweep_angle> # Para.rib Display "Para.tiff" "file" "rgb" Projection "perspective" WorldBegin Translate 0 -0.5 1.5 Rotate 90 0 1 0 Rotate -90 1 0 0 Paraboloid 0.6 0.0 1.0 360 # Paraboloid 1.0 0.25 0.9 330 WorldEnd
Simple Surface • Hyperboloid Hyperboloid <x1> <y1> <z1> <x2> <y2> <z2> <sweep_angle> # Hyper.rib Display "Hyper.tiff" "file" "rgb" Projection "perspective" WorldBegin Translate 0 0 2.0 Rotate 90 0 1 0 Rotate -90 1 0 0 Hyperboloid 0.15 -0.8 -0.5 0.25 0.25 0.6 360 # Hyperboloid 0.4 1.0 -0.5 0.5 0.5 1.0 300 WorldEnd
Simple Surface • Torus Torus <major_radius> <minor_radius> <start_angle> <end_angle> <sweep_angle> # Torus.rib Display "Torus.tiff" "file" "rgb" Projection "perspective" WorldBegin Translate 0 0 1.5 # Rotate -120 1 0 0 Torus 0.5 0.25 0 360 360 # Torus 0.6 0.1 0 360 120 # Torus 0.55 0.35 0 100 360 WorldEnd
Simple Surface • Disk Disk <height_along_z> <radius> <sweep_angle> # Disk.rib Display "Disk.tiff" "file" "rgb" Projection "perspective" WorldBegin Translate 0 0 1.0 Disk 0 0.5 360 # Disk 0 0.7 270 WorldEnd
Convex Concave Simple Surface • Polygon Polygon "P" [...... points..] GeneralPolygon [ poly_vert# vert_hole1# vert_hole2# .....] “P” [....points...] # GPolygon.rib Display "GPolygon.tiff" "file" "rgb" Projection "perspective" WorldBegin Translate -0.5 -0.5 1.0 GeneralPolygon [4 3] "P" [ 0 0 0 1 0 0 1 1 0 0 1 0 0.1 0.1 0 0.9 0.1 0 0.5 0.9 0 ] WorldEnd # Polygon.rib Display "Polygon.tiff" "file" "rgb" Projection "perspective" WorldBegin Translate -0.5 -0.5 1.0 Polygon "P" [ 0 0 0 1 0 0 1 1 0 0 1 0 ] WorldEnd
Convex Concave Simple Surface • PointsPolygon PointsPolygon [ face1_vert# face2_vert# …. ] [ face1_index1 face1_index2 …. face2_index1 face2_index2 …. …. ] "P" [...... points..] PointsGeneralPolygon [2 (face, hole) 1 (no hole) ….] [ face1_vert# (face) face1_vert# (hole) face2_vert# (face) …. ] [ face1_index1 face1_index2 …. face2_index1 face2_index2 …. …. ] "P" [...... points..] # PPolygon.rib Display "PPolygon.tiff" "file" "rgb" Projection "perspective" WorldBegin Translate 0 0 1.5 Rotate -10 1 0 0 PointsPolygons [3 3 3 3] # 4 faces, each with 3 verts, 12 total [2 1 0 1 0 3 2 0 3 2 1 3] # indices of the 12 verts # following is the vertex array with (x,y,z) pt "P" [ 0.664 0.000 -0.469 0.000 -0.664 0.469 0.000 0.664 0.469 -0.664 0.000 -0.469 ] WorldEnd
Patches # patch.rib Display “patch.tiff" "file" "rgb" Projection "perspective“ “fov” [20] Translate -0.5 -0.5 3 WorldBegin LightSource "ambientlight" 1 "intensity" [ 0.1] LightSource "pointlight" 2 "from" [-2 2 -2] "intensity" [ 7 ] Color [ 1 0 0 ] Surface "plastic" Patch "bilinear" "P" [ 0 0 0 1 0 0 0 1 0 1 1 0] WorldEnd • Patches • Provide curved surface Patch “type” “P” [...... points..] • Type : bilinear , bicubic Ordering of Points
Patches • Bilinear #curved.rib Display "curved.tiff" "file" "rgb" Projection "perspective" "fov" [ 20 ] Translate -0.5 -0.5 4 WorldBegin LightSource "ambientlight" 1 "intensity" [ 0.1] LightSource "pointlight" 2 "from" [-2 2 -2] "intensity" [ 7 ] Color [ 1 0 0 ] Surface "plastic" Patch "bilinear" "P" [0 0 0 1 0 0 0.4 1 1 #MOVED BACK 0.6 1 -1] #MOVED FORWARDS WorldEnd
Patches • Bicubic #cubic.rib Display "cubic.tiff" "file" "rgb" Projection "perspective" "fov" [ 30 ] Translate -0.5 -0.5 3 WorldBegin LightSource "ambientlight" 1 "intensity" [ 0.1] LightSource "pointlight" 2 "from" [-2 2 -2] "intensity" [ 10 ] Color [ 1 0 0 ] Surface "plastic" Rotate 40 1 0 0 Patch "bicubic" "P" [ 0 0 0 0.4 0 0 0.6 0 0 1 0 0 0 0.4 0 0.4 0.4 3 0.6 0.4 -3 1 0.4 0 0 0.6 0 0.4 0.6 -3 0.6 0.6 3 1 0.6 0 0 1 0 0.4 1 0 0.6 1 0 1 1 0] WorldEnd
Lighting • Lighting • Point light • Distant light • Spot light • Ambient light
Point light intensity [7] intensity [14] • Point light • Pointlight creates a light that shines equally in all direction • LightSource • “pointlight” : 점광원 • “from” : 광원의 위치 • “intensity” : 빛의 세기 • 광원과 물체의 거리에 따라 빛 감쇠 • Surface • 물체의 재질감표현 • “plastic”: standard CGI shader #pointlight.rib Display "pointlight.tiff" "file" "rgb" Format 640 480 1.0 Projection "perspective" "fov" [ 30 ] Translate 0 0 5 WorldBegin LightSource "pointlight" 1 "from" [ -2 2 -2 ] "intensity" [ 7 ] Surface "plastic" Color [ 1 0 0 ] Sphere 1 -1 1 360 WorldEnd
#illuminate.rib Display "illuminate.tiff" "file" "rgb" Projection "perspective" "fov" [20] Translate 0 0 10 WorldBegin LightSource "pointlight" 1 "from" [4 3 -5] "intensity" [16] LightSource "pointlight" 2 "from" [-4 3 -5] "intensity" [16] Surface "plastic" Color [ 1 0 0 ] AttributeBegin Illuminate 1 1 Translate -0.5 0 0 Sphere 1 -1 1 360 AttributeEnd AttributeBegin Illuminate 1 0 Translate 0.5 0 0 Sphere 1 -1 1 360 AttributeEnd WorldEnd Illuminate • Illuminate • Illuminate [0/1] [0/1] [0/1] … • 광원 on/off
Distant light • Distant light • LightSource • “distantlight” • “to” : 광원의 방향 • 거리에 상관없이 빛의 세기 일정 #distantlight.rib Display "distantlight.tiff" "file" "rgb" Projection "perspective" "fov" [ 30 ] Translate 0 0 5 WorldBegin LightSource "distantlight" 1 "to" [ 1 0 0 ] "intensity" [ 1 ] Color [ 1 0 0 ] Surface "plastic" Sphere 1 -1 1 360 WorldEnd
Spot light delta [0.05] delta [0.25] • Spot light • LightSource • “spotlight” • “from” : 광원의 위치 • “to” : 광원의 방향 • “coneangle” : out cone • “conedeltaangle” : inner cone #spotlight.rib Display "spotlight.tiff" "file" "rgb" Projection "perspective" "fov" [ 30 ] Translate 0 0 5 WorldBegin LightSource "spotlight" 2 "from" [-2 2 -2] "to" [ 0 0 0 ] "intensity" [ 7 ] "coneangle" [0.25] "conedeltaangle" [0.05] Color [ 1 0 0 ] Surface "plastic" Sphere 1 -1 1 360 WorldEnd
Ambient light #spotambient.rib Display "spotambient.tiff" "file" "rgb" Projection "perspective" "fov" [ 30 ] Translate 0 0 5 WorldBegin LightSource "ambientlight" 1 "intensity" [ 0.1] LightSource "spotlight" 2 "from" [-2 2 -2] "to" [ 0 0 0 ] "intensity" [ 7 ] "coneangle" [0.25] "conedeltaangle" [0.05] Color [ 1 0 0 ] Surface "plastic" Sphere 1 -1 1 360 WorldEnd • Ambient light • LightSource • “ambientlight” : 주변광 • “intensity” : 빛의 밝기 • “color” [r g b] : 빛의 색깔 Ambient Ambient & Spot light
Shading Language • Many types of shaders are possible: • Light source shaders • Surface shaders • Atmosphere shaders • Volume shaders…etc. • We will discuss only the surface shaders.
Standard Shaders • Standard Shaders • Constant • Matte • Metal • Plastic • Painted plastic • Displacement
Constant #constant.rib Display "constant.tiff" "file" "rgb" Projection "perspective" "fov" [ 30 ] Translate 0 0 5 WorldBegin LightSource "ambientlight" 1 "intensity" [ 0.1] LightSource "spotlight" 2 "from" [-2 2 -2] "to" [ 0 0 0 ] "intensity" [ 7 ] "coneangle" [0.25] "conedeltaangle" [0.05] Color [ 1 0 0 ] Surface "constant" Sphere 1 -1 1 360 WorldEnd • Constant • “constant” : simplest surface • Simpler than the default shader • Surface “constant”
Matte • Matte • Simulate the diffuse scattering of light from a rough surface • Surface “matte” #matte.rib Display “matte.tiff" "file" "rgb" Projection "perspective" "fov" [ 30 ] Translate 0 0 5 WorldBegin LightSource "ambientlight" 1 "intensity" [ 0.1] LightSource "spotlight" 2 "from" [-2 2 -2] "to" [ 0 0 0 ] "intensity" [ 7 ] "coneangle" [0.25] "conedeltaangle" [0.05] Color [ 1 0 0 ] Surface “matte" Sphere 1 -1 1 360 WorldEnd
Metal • Metal • Metal Objects • Reflect bright light, creating a sharp specular highlight • Surface “metal” #metal.rib Display “metal.tiff" "file" "rgb" Projection "perspective" "fov" [ 30 ] Translate 0 0 5 WorldBegin LightSource "ambientlight" 1 "intensity" [ 0.1] LightSource "spotlight" 2 "from" [-2 2 -2] "to" [ 0 0 0 ] "intensity" [ 7 ] "coneangle" [0.25] "conedeltaangle" [0.05] Color [ 1 0 0 ] Surface “metal" Sphere 1 -1 1 360 WorldEnd