Lighting Review & Example Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, November 17, 2003.

Slides:



Advertisements
Similar presentations
SI23 Introduction to Computer Graphics
Advertisements

2IV60 Computer graphics set 8: Illumination Models and Surface-Rendering Methods Jack van Wijk TU/e.
Polygon Rendering Flat Rendering Goraud Rendering Uses Phong Reflectance Phong Rendering.
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.
1 Graphics CSCI 343, Fall 2013 Lecture 18 Lighting and Shading.
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
Computer Graphics - Class 10
Shading in OpenGL CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
VECTORS Computer Graphics. A REVIEW OF VECTORS:  Scalar Quantity  Vector Quantity  2D vectors  Graphical Representation of Vectors  Magnitude of.
Rendering (彩現 渲染).
IMGD 1001: Illumination by Mark Claypool
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.
Objectives Learn to shade objects so their images appear three- dimensional Learn to shade objects so their images appear three- dimensional Introduce.
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);
Computer Graphics (Spring 2008) COMS 4160, Lecture 14: OpenGL 3
Course Website: Computer Graphics 16: Illumination.
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
Color in OpenGL (Chapter 4) Presented by: Stacy C. Lovell.
SET09115 Intro Graphics Programming
Shading (introduction to rendering). Rendering  We know how to specify the geometry but how is the color calculated.
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.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
Lecture 14 Shading models 1.Shading Constant Shading (to be implemented) Gouraud Shading Phong Shading 2.Light and shading with OpenGL 1.
Shadows via Projection Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, November 5, 2003.
CSE 381 – Advanced Game Programming GLSL Lighting.
OpenGL Lighting Jian-Liang Lin 2002 Hidden-Surface Removal -1 Original Code: while (1) { get_viewing_point_from_mouse_position(); glClear(GL_COLOR_BUFFER_BIT);
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.
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E.
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.
Specular Reflection Lecture 27 Mon, Nov 10, 2003.
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.
Details of Texture Mapping Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, December 1, 2003.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
More on Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, April 14, 2004.
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.
Some Notes on 3-D Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, October 24, 2003.
Computer Graphics Lecture 30 Mathematics of Lighting and Shading - IV Taqdees A. Siddiqi
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
Introduction to 3-D Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 27, 2003.
Computer Graphics: Illumination
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.
Chapter 5. Lighting Computer Graphics (spring, 2009) School of Computer Science University of Seoul.
Computer Graphics (fall,2010) School of Computer Science University of Seoul Minho Kim.
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 고려대학교 컴퓨터 그래픽스 연구실.
© University of Wisconsin, CS559 Spring 2004
Shading To determine the correct shades of color on the surface of graphical objects.
School of Computer Science
Lighting Glenn G. Chappell
Projection in 3-D Glenn G. Chappell
Lighting and Materials
Lighting – Light Sources
Lighting – Material Properties
Chapter IX Lighting.
Last Time Liang-Barsky Details Weiler-Atherton clipping algorithm
Computer Graphics Shading in OpenGL
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science
Lighting Calculations
Presentation transcript:

Lighting Review & Example Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, November 17, 2003

17 Nov 2003CS 3812 Review: The Phong Model Here is a summary of the three components of the Phong Model, along with the recommended colors to use for each type of light & reflection. Type of LightType of Reflection Ambient Light Direct Light Diffuse Reflection Specular Reflection Phong Model Ambient Component Diffuse Component Specular Component Color: Paint color Color: White?? Color: Direct light color Color: Dim version of direct light color OR black??

17 Nov 2003CS 3813 Review: The Phong Model [2/4] To compute the ambient component of the Phong Model, we need: The light color of the ambient light (A R, A G, A B ). The paint color of the material of the surface the vertex lies on (M R, M G, M B ). The resulting color is found via componentwise multiplication: (A R M R, A G M G, A B M B ).

17 Nov 2003CS 3814 The diffuse component works much like the ambient, except that it matters at what angle the light hits the surface. Do the lighting computation as for ambient. Use the direct-light color, not the ambient-light color. Multiply R, G, B the Lambert cosine k. This is the dot product of the normal and light-direction vectors, assuming these are unit vectors. If we are doing attenuation, multiply R, G, B by 1/d 2. For the specular component, both the illumination and viewing directions matter. Do the lighting computation as for ambient. Use the direct-light color, as with diffuse. And use the specular-reflection color, not the paint color. Multiply R, G, B by (R·V) s, where V is the viewing direction, and s is the shininess. If desired, do attenuation as for diffuse. Review: The Phong Model [3/4]

17 Nov 2003CS 3815 Review: The Phong Model [4/4] We have seen how the Phong Model computes the effects of ambient, diffuse, and specular reflection. Now, what is the color of the vertex? How about just adding these up? Final red = ambient red + diffuse red + specular red. Similarly for green & blue. But this may result in RGB components greater than 1. Solution: If any of R, G, B ends up being greater than 1, set it equal to 1. This is not entirely satisfactory, but at least it gives legal results.

17 Nov 2003CS 3816 Review: Basic OpenGL Lighting OpenGL implements the Phong Model. We still generally need to compute normals ourselves. We set up lights and materials; OpenGL does the rest. How it works: Set up and enable one or more lights (light sources). Use glLight *, glEnable. Various other lighting properties can be set. With glLightModel *, glShadeModel, etc. Enable/disable lighting as appropriate. Enable with “ glEnable(GL_LIGHTING); ”. When drawing, set material properties. Use glMaterial *. Forget about glColor *, for now. Before each glVertex * command, specify a normal vector. Use glNormal *.

17 Nov 2003CS 3817 Review: Normal Vectors When we do lighting, each polygon vertex needs an associated normal vector. This should be a unit vector pointing straight out from the surface at the vertex. In OpenGL We specify a normal with glNormal *, inside glBegin - glEnd. A glNormal* call comes before the associated glVertex *. Example: glNormal3d(0., 0., 1.); glVertex3d(1., 2., 3.); The tricky part is computing the normals. We discussed three methods. Facet normals using cross products. See the code fragment drawtriangle.cpp, on the web page. Normals based on the mathematical formula for the surface. Other methods.

17 Nov 2003CS 3818 Moving Lights Example: Lights and Model/View A light is something to be positioned within the world, just like a polygon. Therefore, it is natural that light positions pass through the model/view transformation. The matrix used is the current one at the time when glLightfv( …, GL_POSITION, … ) is called. Not the current one when a lit object is drawn! Therefore, you probably want to position your lights in the display function … If you want a light to move. If you want to make a light source visible by drawing an object at its location. If you have any other reason to be interested in exactly where your lights are. You can still set a light’s colors in the initialization, then set its position in the display function.

17 Nov 2003CS 3819 Moving Lights Example: An Object at the Light Position Suppose we want to draw an object at the light position. It should appear to be the light source. We want to position the object using model/view. If we use this same model/view matrix for setting the light position, then we will specify the light position as: (0, 0, 0, 1). We probably want the color of the object to match the color of the direct light. Make the light color a global? OpenGL material spec’s add an “emission” color to the Phong model. Its effect on the vertex color ignores light-source colors and angles. In short, it’s rather like glColor *, except that it is added to the other components in the Phong Model. Use GL_EMISSION to set the emission color.

17 Nov 2003CS Moving Lights Example: Example Animate the following scene: A rotating object in the center. A moving light revolving about the object. The light should be “visible”.