CS 481 Preview, Some Lighting Details Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, November 19, 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.
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.
Computer Graphics - Class 10
Shading in OpenGL CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 11: OpenGL 3
Shading in OpenGL Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Now Playing: Multiply Jamie Lidell from Multiply Released June 13, 2005.
CS5500 Computer Graphics March 26, Shading Reference: Ed Angel’s book.
Computer Graphics (Spring 2008) COMS 4160, Lecture 14: OpenGL 3
Computer Graphics Lighting.
1 Graphics CSCI 343, Fall 2013 Lecture 20 Lighting and Shading III.
Programmable Pipelines. Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
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 and Illumination. OpenGL Shading Without ShadingWith Shading.
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.
More on Advanced Interfaces, Image Basics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, November 21, 2003.
VR UI, Notes on Projects, Intro. to Object Descriptions Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday,
More on Drawable Objects, Hierarchical Objects Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, January.
Intro. to Advanced Lighting, Basic Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, April.
More on Environment Mapping Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, December 10, 2003.
Chi-Cheng Lin, Winona State University CS430 Computer Graphics Lighting and Shading Part II.
Lighting Review & Example Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, November 17, 2003.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
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.
Project 5 Lamp Shader Fri, Nov 7, 2003 Due Mon, Nov 17, 2003.
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.
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.
11/5/2002 (c) University of Wisconsin, CS 559 Last Time Local Shading –Diffuse term –Specular term –All together –OpenGL brief overview.
Where We Stand So far we know how to: –Transform between spaces –Rasterize –Decide what’s in front Next –Deciding its intensity and color.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
Details of Texture Mapping Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, December 1, 2003.
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.
More on Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, April 14, 2004.
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.
03/19/2002(c) University of Wisconsin, CS 559 Last Time BSP Tree rendering and exact visibility in mazes Local Shading –Diffuse term –Specular term.
Introduction to 3-D Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 27, 2003.
Illumination Models and Surface-Rendering Methods CEng 477 Introduction to Computer Graphics.
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.
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
Open GL: Colors and Lighting
Shading in OpenGL Ed Angel
Lighting Glenn G. Chappell
Lighting Phong's Lighting Model normals
Illumination and Shading
More on Widgets, Misc. Topics
Lighting and Materials
Lighting – Light Sources
Computer Graphics 4Practical Lesson
Last Time Liang-Barsky Details Weiler-Atherton clipping algorithm
Computer Graphics Shading in OpenGL
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

CS 481 Preview, Some Lighting Details Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, November 19, 2003

19 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??

19 Nov 2003CS 3813 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 *.

19 Nov 2003CS 3814 Review: Moving Lights Example 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! Idea: For positional lights (not directional lights), always call the above with (0, 0, 0, 1) as the position. Then you can make a “visible light source” by drawing an object centered at (0, 0, 0) at the same time.

19 Nov 2003CS 3815 CS 481 Preview [1/2] The second semester of CG is CS 481/681, which will be taught next semester. *Class procedures will be much the same as in CS 381, except: The last few assignments will be replaced by a project. Requirements will be negotiated individually. There will be one take-home midterm exam instead of two in-class exams. A number of class meetings will be outside the classroom. For example, in the ARSC Discovery Lab.

19 Nov 2003CS 3816 CS 481 Preview [2/2] *CS 481/681 topics include: Virtual Reality We have received permission from ARSC for students in the class to get access (door cards & computer accounts) to the Discovery Lab. Specifying 3-D Objects Including making models for a 3-D printer. Students will each be able to “print” (at least) one 3-D model. Advanced Lighting Techniques Bump mapping, environment mapping, BRDF’s, ray tracing, etc. A Little on Shader Languages The latest advance in graphics processor control methods allow programmers to write code in a high-level language to be run by the graphics processor. And any other CG topic you might want to do a project on … *This assumes I will be the instructor, which is very likely, but not certain.

19 Nov 2003CS 3817 Some Lighting Details: Overview Now we look at some of the more advanced (and/or obscure) lighting features available in OpenGL: Two-sided lighting. Spotlights. Local-viewer mode.

19 Nov 2003CS 3818 Some Lighting Details: Two-Sided Lighting [1/2] OpenGL’s two-sided lighting mode allows the front and back of a polygon to be lit differently. When you use glMaterial *, you specify front or back or both. Thus, there are two current materials: front and back. Normally, you use only the front material. When two-sided lighting is enabled, the front material is used for the front side, and the back material for the back side.

19 Nov 2003CS 3819 Some Lighting Details: Two-Sided Lighting [2/2] Enable two-sided lighting with glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1); Make that a zero to disable it. You probably want to put this in the initialization; there is rarely any reason to disable it. No, I don’t know why they didn’t just use glEnable. When two-sided lighting is enabled: The front side (determined by clockwise/counterclockwise vertex ordering) of a polygon is lit as usual. The front material is used. The back side is lit using: The back material. A reversed normal vector. Your normals had better point the correct direction! Example Time

19 Nov 2003CS Some Lighting Details: Spotlights A “spotlight” is a light source that sends light only in, or close to, a particular direction. Spotlights should always be positional, having a position in 3-D space. Three lighting parameters, all set using glLight *, affect spotlights. Spot Direction Use GL_SPOT_DIRECTION with glLightfv. Parameter is an array of 3 GLfloat ’s: a vector indicating which way the spotlight is pointing. Spot Cutoff Use GL_SPOT_CUTOFF with glLightf. Parameter is a single GLfloat : an angle, in degrees, indicating how far from the spot direction the spotlight works. Legal values: 0-90, 180. Spot Exponent Use GL_SPOT_EXPONENT with glLightf. Parameter is a single GLfloat : an exponent for the cosine of the angle between the direction to a given vertex and the spot direction.. Legal values: (just like shininess). Hint: Exponents generally work better than cutoffs. (Why?)

19 Nov 2003CS Some Lighting Details: Local-Viewer Mode The specular component of the Phong Model takes the viewing direction into account. In OpenGL, by default, this is speeded up by replacing the viewer direction with (0, 0, 1). Force OpenGL to do the “correct” Phong Model computation by setting local-viewer mode. Enable local-viewer mode with glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); Other comments on enabling & disabling as for two-sided. I have generally found: The default (no local viewer) works fine for nearly all applications. Local-viewer mode might be helpful when flying. Local-viewer mode is necessary in virtual reality.