Lecture 9: Lighting and Shading 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271

Slides:



Advertisements
Similar presentations
Polygon Rendering Flat Rendering Goraud Rendering Uses Phong Reflectance Phong Rendering.
Advertisements

1 Graphics CSCI 343, Fall 2013 Lecture 18 Lighting and Shading.
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.
Illumination and Shading
1. What is Lighting? 2 Example 1. Find the cubic polynomial or that passes through the four points and satisfies 1.As a photon Metal Insulator.
Computer Graphics - Class 10
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Lighting/Shading III Week.
Shading in OpenGL CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
IMGD 1001: Illumination by Mark Claypool
CS 4731: Computer Graphics Lecture 16: Illumination Models Part 2 Emmanuel Agu.
Shading in OpenGL Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
1 CSCE 641: Computer Graphics Lighting Jinxiang Chai.
1 Lecture 10 Lighting in OpenGL. 2 Sources of light GLfloat myLightPosition[] = {3.0, 6.0, 5.0, 1.0}; GLLightfv(GL_LIGHT0, GL_POSITION, myLightPosition);
CS5500 Computer Graphics March 26, Shading Reference: Ed Angel’s book.
Computer Graphics (Spring 2008) COMS 4160, Lecture 14: OpenGL 3
Illumination and Shading
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
CS 445 / 645: Introductory Computer Graphics
Computer Graphics Lighting.
1 Graphics CSCI 343, Fall 2013 Lecture 20 Lighting and Shading III.
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.
Shading and Illumination. OpenGL Shading Without ShadingWith Shading.
Computer Graphics I, Fall 2010 Shading in OpenGL.
Lecture 14 Shading models 1.Shading Constant Shading (to be implemented) Gouraud Shading Phong Shading 2.Light and shading with OpenGL 1.
08 |Lighting and Shading Eriq Muhammad Adams J |
Lecture 6: 3D graphics Concepts 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271 
Steve Sterley. Real World Lighting Physical objects tend to interact with light in three ways: Absorption (black body) Reflection (mirror) Transmission.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
11/04/04© University of Wisconsin, CS559 Fall 2004 Last Time Visibility –Z-Buffer and transparency –A-buffer –Area subdivision –BSP Trees –Exact Cell-Portal.
Illumination and Shading
Course Introduction to virtual engineering Óbuda University John von Neumann Faculty of Informatics Institute of Applied Mathematics Lecture and laboratory.
COMPUTER GRAPHICS Hochiminh city University of Technology Faculty of Computer Science and Engineering CHAPTER 6: Lighting and Shading.
RENDERING Introduction to Shading models – Flat and Smooth shading – Adding texture to faces – Adding shadows of objects – Building a camera in a program.
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
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[] =
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
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 and Reflection Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
Shading NOTE: Some of these slides are from Ed Angel’s presentation at SIGGRAPH February 27, 2008.
Illumination CSE 410. Basic steps of lighting Enable smooth shading Set global ambient light glShadeModel(GL_SMOOTH); glEnable(GL_NORMALIZE); GLfloat.
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
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.
1 Dr. Scott Schaefer Lighting. 2/49 Lighting/Illumination Color is a function of how light reflects from surfaces to the eye Global illumination accounts.
Graphics Graphics Korea University kucg.korea.ac.kr 1 Lights & Material 고려대학교 컴퓨터 그래픽스 연구실.
CSC Graphics Programming
Shading To determine the correct shades of color on the surface of graphical objects.
Illumination and Shading
Shading in OpenGL Ed Angel
Lighting and Shading Lab 8:.
Lighting Phong's Lighting Model normals
Illumination and Shading
Lighting and Materials
Lighting – Light Sources
CS5500 Computer Graphics April 10, 2006.
Lighting – Material Properties
Lighting and Shading Lab 8:.
ייצוג בעולם 3D ייצוג מצולעים (פוליגונים) צלע קודקוד צלעe0 : {v1,v2}
Last Time Liang-Barsky Details Weiler-Atherton clipping algorithm
CS 480/680 Computer Graphics Shading.
Presentation transcript:

Lecture 9: Lighting and Shading 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271

Lecture 9: Lighting and Shading 2 Lighting and Shading  Today - shading models in 3D graphics  How OpenGL supports shading  Interaction of lights with shade models  Lights in OpenGL  Material properties of objects  OpenGL materials - interaction of materials, lighting and shading  Tutorial examples

Lecture 9: Lighting and Shading 3 Shading models in 3D graphics Flat shading all the pixels in the same quad, triangle or polygon have the same colour value

Lecture 9: Lighting and Shading 4 Shading models in 3D graphics Smooth shading pixel colour values are re-calculated across a polygon according to how the light is reflected from a light source towards the viewer

Lecture 9: Lighting and Shading 5 Shading models  There are a variety of shading models in 3D using different algorithms to give a more realistic effect  Gouraud  Phong  They try to approximate the changes in colour values of pixels across a polygon matching its angle in the scene  Sometimes artifacts are visible from shading models:  Try movelight.cpp and you might see slight rings on the torus shape showing where the polygon edges meet  More realistic shading models need more calculation so simpler models are used for interactive graphics

Lecture 9: Lighting and Shading 6 Shading in OpenGL  Shading in OpenGL is controlled by  The shading model  glShadeModel(GL_FLAT)  glShadeModel(GL_SMOOTH)  The lights in the scene  The materials of the objects  The final appearance of an object is calculated from the shade model used, the combined effects of any lights and the reflective properties of the materials (plus textures)

Lecture 9: Lighting and Shading 7 Lights in OpenGL 1  Most 3D graphics API’s support some form of lighting  Directional lights which can be a parallel beam or a cone light a spot light  Point source lights which shine equally in all directions  Today we will concentrate on point source lights.  Lights are created in OpenGL by calling glLightfv() with a light ID followed by some attributes  OpenGL only has eight light ID’s  GL_LIGHT0, GL_LIGHT1, … GL_LIGHT7  However we can reuse lights if necessary

Lecture 9: Lighting and Shading 8 Lights in OpenGL 1  Firstly we enable lighting  glEnable(GL_LIGHTING);  For point source lights we need to specify a position in the 3D scene  e.g. glLightfv(GL_LIGHT0, GL_POSITION, position);  where position is an array of position values in x, y, and z  e.g. GLfloat position[] = {0.0, 0.0, 1.5, 1.0};  movelight.cpp shows the effect of moving a light with the mouse with flat and smooth shading

Lecture 9: Lighting and Shading 9 Lights in OpenGL 2  We can also specify the colour of the light  glLightfv(GL_LIGHT0, GL_DIFFUSE, light_colour);  where light_colour is an array of colour values  e.g. GLfloat light_colour[] = {0.0, 1.0, 1.0, 1.0};   For Direction lights we can specify additional attributes such as the angle of the light cone and its attenuation - how much the light fades with distance

Lecture 9: Lighting and Shading 10 Material properties of objects  The shape and angular position of polygons is one way of modeling illumination  We can also set the material properties of polygons in terms of their reflective behaviour  For example:  The ambient reflectiveness of the object - how it reflects all light  The specular reflectiveness - how it reflects at highlights  Shininess - how bright are the highlights  Emission - the object itself shines

Lecture 9: Lighting and Shading 11 Material properties in OpenGL  We can set the different material properties to model different light reflections in OpenGL.  For example, lightlab.cpp shows examples of  A metallic (brass) surface  A more diffuse reflective (plastic) surface  A reflective gem-stone surface (emerald)  A non-reflective (slate) surface

Lecture 9: Lighting and Shading 12  Material values are set via glMaterialfv(),  e.g glMaterialfv(GL_FRONT, GL_AMBIENT, ambient);  Again ambient is an array of colour values  We can control how shiny the object is with glMaterialfv(GL_FRONT, GL_SPECULAR, specular); glMaterialf(GL_FRONT, GL_SHININESS, shininess);  Where shininess can be a low value ( 20) for shiny surfaces  Polygons have two sides so we must specify which is illuminated (we can ignore the back side mostly)

Lecture 9: Lighting and Shading 13 Example Plastic Brass Emerald

Lecture 9: Lighting and Shading 14 Example...  With lightlab.cpp you can experiment with the interaction of  shading model - flat or smooth  material properties  lighting colour  Having many lights in a scene requires a lot of computation  So OpenGL lights are usually reserved for moving lights  We can mimic the effects of lights by textures  Rather than apply an image texture map we apply an light map  This is used in many games engines for speed

Lecture 9: Lighting and Shading 15 Tutorial  Copy and compile the two example programs  lightlab.cpp and movelight.cpp  With movelight.cpp experiment with different values for light_colour  With lightlab.cpp  Create a new material  copy and paste an existing definition and alter its values  Change the menu options to use your new material