Polygon Rendering Flat Rendering Goraud Rendering Uses Phong Reflectance Phong Rendering.

Slides:



Advertisements
Similar presentations
2IV60 Computer graphics set 8: Illumination Models and Surface-Rendering Methods Jack van Wijk TU/e.
Advertisements

2 COEN Computer Graphics I Evening’s Goals n Discuss the fundamentals of lighting in computer graphics n Analyze OpenGL’s lighting model n Show.
Computer Graphics(Fall 2003) COMS 4160, Lecture 7: OpenGL 3 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
CSPC 352: Computer Graphics
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
1 MAE152 Computer Graphics for Scientists and Engineers Lighting in OpenGL.
Computer Graphics - Class 10
Shading in OpenGL CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Rendering (彩現 渲染).
Shading in OpenGL Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
7M836 Animation & Rendering
6.1 Vis_04 Data Visualization Lecture 6 - A Rough Guide to Rendering.
CS5500 Computer Graphics March 26, Shading Reference: Ed Angel’s book.
Illumination and Shading
Computer Graphics Lighting.
Shading (introduction to rendering). Rendering  We know how to specify the geometry but how is the color calculated.
COMPUTER GRAPHICS CS 482 – FALL 2014 AUGUST 27, 2014 FIXED-FUNCTION 3D GRAPHICS MESH SPECIFICATION LIGHTING SPECIFICATION REFLECTION SHADING HIERARCHICAL.
Shading in OpenGL.
19/17/ :25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.
Shading 03/19/2003. Lighting Principles Lighting based on how objects reflect light –Surface characteristics –Light color and direction –Global lighting.
CS 481 Preview, Some Lighting Details Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, November 19, 2003.
OpenGL - Lighting, Shading and Material Properties
Computer Graphics I, Fall 2010 Shading in OpenGL.
Lecture 9: Lighting and Shading 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271
Lecture 14 Shading models 1.Shading Constant Shading (to be implemented) Gouraud Shading Phong Shading 2.Light and shading with OpenGL 1.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Basic Rendering Pipeline and Shading Spring 2012.
CSE 381 – Advanced Game Programming GLSL Lighting.
Lighting Review & Example Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, November 17, 2003.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Illumination and Shading
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
Lecture Fall 2001 Illumination and Shading in OpenGL Light Sources Empirical Illumination Shading Transforming Normals Tong-Yee Lee.
11/5/2002 (c) University of Wisconsin, CS 559 Last Time Local Shading –Diffuse term –Specular term –All together –OpenGL brief overview.
Local Illumination and Shading
Illumination and Shading Prof. Lizhuang Ma Shanghai Jiao Tong University.
Where We Stand So far we know how to: –Transform between spaces –Rasterize –Decide what’s in front Next –Deciding its intensity and color.
Lighting and Shading Part 2. Global Ambient Light There are at least 8 OpenGL lights and 1 Global Ambient Setting the Global Ambient globalAmbient[] =
In the name of God Computer Graphics. Where We Stand So far we know how to: –Transform between spaces –Draw polygons Next –Deciding a pixel’s intensity.
Lighting Dave Shreiner. 2 Lighting Principles Lighting simulates how objects reflect light Lighting simulates how objects reflect light material composition.
Render methods. Contents Levels of rendering Wireframe Plain shadow Gouraud Phong Comparison Gouraud-Phong.
Illumination and Shading Sang Il Park Sejong University.
Lighting and Reflection Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Shading NOTE: Some of these slides are from Ed Angel’s presentation at SIGGRAPH February 27, 2008.
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
Illumination Models and Surface-Rendering Methods CEng 477 Introduction to Computer Graphics.
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
Illumination and Shading Prof. Lizhuang Ma Shanghai Jiao Tong University.
Computer Graphics (fall,2010) School of Computer Science University of Seoul Minho Kim.
CSC Graphics Programming
© University of Wisconsin, CS559 Spring 2004
Shading To determine the correct shades of color on the surface of graphical objects.
Unit-7 Lighting and Shading
School of Computer Science
Chapter 14 Shading Models.
Vectors, Normals, & Shading
Shading in OpenGL Ed Angel
Lighting Phong's Lighting Model normals
Illumination and Shading
Lighting – Light Sources
Introduction to Meshes
Illumination and Shading
Last Time Liang-Barsky Details Weiler-Atherton clipping algorithm
Texture Mapping 고려대학교 컴퓨터 그래픽스 연구실.
Chapter 14 Shading Models.
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
Computer Graphics Shading in OpenGL
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

Polygon Rendering Flat Rendering Goraud Rendering Uses Phong Reflectance Phong Rendering

Flat Rendering One normal per triangle Constant color per triangle Computed using reflectance model. Best for flat surfaces to give a faceted appearance Advantages: simple and fast

Diffuse Illumination & Flat Rendering Image courtesy, Foley, van Dam, Feiner, Hughes (Image removed, see Prof. Varshney’s slides).

Gouraud Rendering One normal per vertex Compute color per vertex Interpolate color per pixel (one add per R, G, B channel) Tolerable results for curved surfaces

Diffuse & Gouraud Shading Image courtesy, Foley, van Dam, Feiner, Hughes (Image removed, see Prof. Varshney’s slides).

Specular & Gouraud Shading Image courtesy, Foley, van Dam, Feiner, Hughes (Image removed, see Prof. Varshney’s slides).

Phong Rendering One normal per vertex Interpolate normal per pixel Interpolate each component of normal and then normalize Compute color per pixel Good for curved and shiny surfaces Not available in OpenGL

How do we interpolate a surface normal? Keep in mind that a normal is a unit vector. We can’t just interpolate the x,y,z components of the normal, because we wind up with a non- unit normal. Here’s a simple example: N1 = (0,.436, -.9). N2 = (0, -.436,.9) If we take the average of these, we get (0,0,.9), which is not a unit normal. We have to normalize this to get (0,0,1).

Specular & Phong Rendering Image courtesy, Foley, van Dam, Feiner, Hughes (Image removed, see Prof. Varshney’s slides).

Gouraud vs. Phong Gouraud is faster Interpolate 1 value instead of 3 Don’t need to normalize Don’t need to render at each point. Phong much more accurate Especially when lighting effects change rapidly with surface normal. True for shiny objects And for cast shadows.

Discussion Light Source and/or Viewer at infinity simplifies calculations at the cost of realism Need to either clamp colors at max value or normalize them preserving their relative weights (R = R/(R + G + B),.... )

OpenGL Support for Illumination Ambient, Diffuse, Specular illuminations are supported Users have to define lights position, type, color Users also define object material Front and/or back facing polygons, color

OpenGL Lights GLfloat lightA_position[ ] = {1.0, 1.0, 1.0, 0.0}; GLfloat lightB_position[ ] = {1.0, 2.0, 3.0, 1.0}; glLightfv(GL_LIGHT0, GL_POSITION, lightA_position); glLightfv(GL_LIGHT1, GL_POSITION, lightB_position); The above defines a directional light source coming from the direction (1, 1, 1), and a positional light source located at the point (1, 2, 3) in the world coordinates.

OpenGL Lights OpenGL specifies at least 8 light sources GL_LIGHT0.. GL_LIGHT7 To get maximum lights in your implementations use: glGetIntegerv(GL_MAX_LIGHTS, GLint *num_lights); You need to enable each light that you plan to use and enable OpenGL lighting (they are all disabled by default): glEnable(GL_LIGHT0); glEnable(GL_LIGHT1); … glEnable(GL_LIGHTING);

glLight*() glLight{if}(GLenum light, GLenum pname, TYPE param) glLight{if}v(GLenum light, GLenum pname, TYPE *param) light can be GL_LIGHT0.. GL_LIGHT7 pname can be one of following: GL_POSITION: light position GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR : light colors GL_SPOT_DIRECTION, GL_SPOT_EXPONENT, GL_SPOT_CUTOFF: spotlight parameters GL_CONSTANT_ATTENUATION, GL_LINEAR_ATTENUATION, GL_QUADRATIC_ATTENUATION: parameters for attenuation

Spotlight Direction Cutoff

glLight*() GLfloat light0_ambient[ ] = {0.0, 0.1, 0.0, 1.0}; GLfloat light0_diffuse[ ] = {0.0, 0.0, 1.0, 1.0}; GLfloat light0_specular[ ] = {1.0, 1.0, 1.0, 1.0}; GLfloat light0_position[ ] = {1.0, 2.0, 3.0, 1.0}; glLightfv(GL_LIGHT0, GL_POSITION, light0_position); glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, light0_specular); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING);

Object Materials Object colors under illumination are computed as a component-wise multiplication of the light colors and material colors Just as light colors are specified differently for ambient, diffuse, and specular illuminations, material colors are also specified for each of these three illuminations. In addition to this emissive material color is also defined: Lights don’t influence emissive material Emissive objects don’t add further light to environment

glMaterial*() glMaterial{if}(GLenum face, GLenum pname, TYPE param) glMaterial{if}v(GLenum face, GLenum pname, TYPE *param) face can be: GL_FRONT, GL_BACK, GL_FRONT_AND_BACK pname can be: GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR, GL_EMISSION: material colors GL_SHININESS: Specular (Phong) illumination exponent

glMaterial*() GLfloat mat0_ambient[ ] = {0.2, 0.2, 0.2, 1.0}; GLfloat mat0_diffuse[ ] = {0.7, 0.0, 0.0, 1.0}; GLfloat mat0_specular[ ] = {1.0, 1.0, 1.0, 1.0}; GLfloat mat0_shininess[ ] = {5.0}; glMaterialfv(GL_FRONT, GL_AMBIENT, mat0_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat0_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, mat0_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat0_shininess);

glColorMaterial() If only one material property is to be changed, it is more efficient to use glColorMaterial( ) glColorMaterial( ) causes material to track glColor*( ) glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT, GL_DIFFUSE); glColor3f(0.2, 0.5, 0.8); // this changes the diffuse material color Draw objects here glColorMaterial(GL_FRONT, GL_SPECULAR); glColor3f(0.9, 0.0, 0.2); // this changes the specular material color Draw objects here glDisable(GL_COLOR_MATERIAL);

OpenGL Shading OpenGL supports flat and Gouraud shading. No support for Phong shading yet. glShadeModel(GL_FLAT) Flat shading glShadeModel(GL_SMOOTH) Gouraud shading Remember to supply normals with triangles or vertices to get correct lighting and shading

Phong Shading with Specular Illumination Image courtesy, Foley, van Dam, Feiner, Hughes (Image removed, see Prof. Varshney’s slides).

Phong Shading + Specular Illum. on Curved Surfaces Image courtesy, Foley, van Dam, Feiner, Hughes (Image removed, see Prof. Varshney’s slides).

More and Better Lights Image courtesy, Foley, van Dam, Feiner, Hughes (Image removed, see Prof. Varshney’s slides).

Image Textures Image courtesy, Foley, van Dam, Feiner, Hughes (Image removed, see Prof. Varshney’s slides).

Displacement Textures + Shadows Image courtesy, Foley, van Dam, Feiner, Hughes (Image removed, see Prof. Varshney’s slides).