Presentation is loading. Please wait.

Presentation is loading. Please wait.

Kansas State University Department of Computing and Information Sciences CIS 736: Advanced Computer Graphics Monday, 24 April 2006 Shaun Budhram (Slides.

Similar presentations


Presentation on theme: "Kansas State University Department of Computing and Information Sciences CIS 736: Advanced Computer Graphics Monday, 24 April 2006 Shaun Budhram (Slides."— Presentation transcript:

1 Kansas State University Department of Computing and Information Sciences CIS 736: Advanced Computer Graphics Monday, 24 April 2006 Shaun Budhram (Slides modified from Rich Pickler’s 2001 Tutorial) Department of Computing and Information Sciences, KSU Readings: Chapter 7, Advanced RenderMan Introduction to Renderman Lecture 38 of 42

2 Kansas State University Department of Computing and Information Sciences CIS 736: Advanced Computer Graphics Lecture Outline Readings: Advanced RenderMan, Chapter 7 Suggested Exercises: Stretching RenderMan – A Brief History Using BMRT The RIB File The Shading Language Writing a Shader Invaluable Resources

3 Kansas State University Department of Computing and Information Sciences CIS 736: Advanced Computer Graphics RenderMan – A Brief History Began at ILM research department, later Pixar 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 Directly Linked DSO Can be a standalone program or called from RIB.

4 Kansas State University Department of Computing and Information Sciences CIS 736: Advanced Computer Graphics Using BMRT A free implementation of the RenderMan standard Available at http://www.oneblackpixel.com/bmrt/ Rendrib – the command line renderer –Rendrib [flags] -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] -dso compile to machine code -o name output to specified name

5 Kansas State University Department of Computing and Information Sciences CIS 736: Advanced Computer Graphics The RIB File Structure State Machine similar to OpenGL C-linkage Options global to the entire animation Frame Block Image options Camera options World Block Attributes, lights, primitives Changed Options Another world block Next frame block

6 Kansas State University Department of Computing and Information Sciences CIS 736: Advanced Computer Graphics Types, Variables, Spaces Available types FloatThe only single number type. Use for counters as well as normal applications of floats. PointFloat Triplet VectorFloat Triplet NormalFloat Triplet ColorFloat Triplet Matrix4x4 Transformation Matrix StringUsed for filenames, etc.

7 Kansas State University Department of Computing and Information Sciences CIS 736: Advanced Computer Graphics Types, Variables, Spaces Variables global to all shaders Ultimate Goal: Ci, Oi point PPosition of the point you are shading. Changing this variable displaces the surface. normal NThe surface shading normal at P. Changing N causes bump mapping. normal NgThe true surface normal at P. This can differ from N; N can be overridden in various ways including bump mapping and user provide vertex normals, but Ng is always the true surface normal of the facet you are shading. vector IThe incident vector, pointing from the viewing position to the shading position P. color Cs, OsThe default surface color and opacity, respectively. float u,vThe 2D parametric coordinates of P (on the particular geometric primitive you are shading). float s, tThe 2D texturing coordinates of P. These values can default to u,v but a number of mechanisms override the original values. vector dPdu, dPdv The partial derivatives (ie, tangents) of the surface at P. TimeThe time of the current shading sample. float du, dvAn estimate of the amount that the surface parameters u and v change from sample to sample. vector L, color Cl These variables contain the information coming from the lights and may be accessed from inside illuminate loops only. color Ci, OiThe final surface color and opacity of the surface at P. Setting these two variables is the primary goal of a surface shader.

8 Kansas State University Department of Computing and Information Sciences CIS 736: Advanced Computer Graphics Types, Variables, Spaces Spaces Specified as a cast to variables –point blah = point “shader” (.5.5.5); Or using the transform functions: transform, vtransform, ntransform –point transform( string toSpaceName; point p_current); CurrentThe coordinate system that all points start in and the one in which all lighting calculations are carried out. Note that the choice of “current” space may be different on each renderer ObjectThe local coordinate system of the graphics primitive (sphere, patch, etc.) that we are shading. ShaderThe coordinate system active at the time that the shader was declared (by the Surface, Displacement, or LightSource statement). WorldThe coordinate system active at WorldBegin. CameraThe coordinate system with its origin at the center of the camera lens, x-axis pointing right, y-axis pointing up, z-axis pointing into the screen. ScreenThe perspective-corrected coordinate system of the camera’s image plane. Coordinate (0,0) in “screen” space is looking along the z-axis of “camera” space. RasterThe 2D projected space of the final output image, with units of pixels. Coordinate (0,0) in “raster” space is the upper left corner of the image, with x and y increasing to the right and down, respectively.

9 Kansas State University Department of Computing and Information Sciences CIS 736: Advanced Computer Graphics Writing a Shader (cont’d) Simple Sample: Phong shader surface phong ( float Ka=1, Kd=1, Ks=0.5, roughness=0.1; color specularcolor=1; ) { /* Simple Phong Illumination Model */ normal Nf = faceforward(normalize(N),I); vector V = -normalize(I); Ci = Cs * (Ka*ambient() + Kd*diffuse(Nf)) + Ks*specularcolor*specular(Nf,V,roughness); Oi = Os; Ci *=Oi; }

10 Kansas State University Department of Computing and Information Sciences CIS 736: Advanced Computer Graphics Writing a Shader (cont’d) Attaching to the RIB file *********** AttributeBegin Translate 0 -1.5 0 Rotate 20 0 0 1 Color [ 0.8 0.0 0.0 ] Surface "phong" "Ka" [.1] "Kd" [.8] "Ks" [1] "roughness" [0.1] "specularcolor" [1 1 1] Basis "bezier" 3 "bezier" 3 PatchMesh "bicubic" 13 "nonperiodic" 10 "nonperiodic" "P" [1.5 0 0 1.5 0.828427 0 0.828427 1.5 0 0 1.5 0 -0.828427 1.5 0 -1.5 0.828427 0 -1.5 0 0 -1.5 -0.828427 0 -0.828427 -1.5 0 0 -1.5 0 0.828427 -1.5 0 1.5 -0.828427 0 1.5 0 0 1.5 0 0.075 1.5 0.828427 0.075 0.828427 1.5 0.075 0 1.5 0.075 - 0.828427 1.5 0.075 -1.5 0.828427 0.075 -1.5 0 0.075 -1.5 -0.828427 0.075 -0.828427 -1.5 0.075 0 -1.5 0.075 0.828427 -1.5 0.075 1.5 -0.828427 0.075 1.5 0 0.075 2 0 0.3 2 1.10457 0.3 1.10457 2 0.3 0 2 0.3 - 1.10457 **************

11 Kansas State University Department of Computing and Information Sciences CIS 736: Advanced Computer Graphics Writing a Shader (cont’d) Other Shader types –Displacement Shaders – describe how surfaces wrinkle or bump. –Light Shaders – describe the directions, amounts and colors of illumination and distributed by a light source in the scene. –Volume Shaders – describe how light is affected as it passes through a participating medium such as smoke or haze. Advanced Topics –Anti-Aliasing – calculus! –Lens flares –Smoke, Clouds –Cartoon Shaders –Lighting models

12 Kansas State University Department of Computing and Information Sciences CIS 736: Advanced Computer Graphics Readings: Advance RenderMan, Chapter 7 Suggested Exercises: Stretching RenderMan – A Brief History Using BMRT The RIB File The Shading Language Writing a Shader Invaluable Resources –BMRT homepage – www.exluna.com/bmrtwww.exluna.com/bmrt –Renderman Newsgroup – comp.graphics.rendering.renderman –www.renderman.orgwww.renderman.org –The Renderman Interface Specification. Available at www.pixar.comwww.pixar.com Lecture Outline


Download ppt "Kansas State University Department of Computing and Information Sciences CIS 736: Advanced Computer Graphics Monday, 24 April 2006 Shaun Budhram (Slides."

Similar presentations


Ads by Google