Now Playing: Multiply Jamie Lidell from Multiply Released June 13, 2005.

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.
Computer Graphics - Class 10
OpenGL Son of the Survival Guide. Last Time on OpenGL Windowing … glut Rendering Primatives Transformations Projections State Management.
Shading in OpenGL CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
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.
CS5500 Computer Graphics March 26, Shading Reference: Ed Angel’s book.
Computer Graphics (Spring 2008) COMS 4160, Lecture 14: OpenGL 3
Illumination and Shading
Lighting & Material. Example 1/5 #include ” glut.h ” void display(); void reshape(int, int); void lighting(); int main(int argc, char** argv) { glutInit(&argc,
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
SET09115 Intro Graphics Programming
Computer Graphics Lighting.
1 Graphics CSCI 343, Fall 2013 Lecture 20 Lighting and Shading III.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Chapter 6: Shading Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Illumination & Reflectance Dr. Amy Zhang. Outline 2  Illumination and Reflectance  The Phong Reflectance Model  Shading in OpenGL.
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.
Shading and Illumination. OpenGL Shading Without ShadingWith Shading.
OpenGL - Lighting, Shading and Material Properties
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 |
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Chi-Cheng Lin, Winona State University CS430 Computer Graphics Lighting and Shading Part II.
OpenGL Color and Lighting 2003 Spring Keng Shih-Ling.
Lighting Review & Example Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, November 17, 2003.
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.
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.
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.
Where We Stand So far we know how to: –Transform between spaces –Rasterize –Decide what’s in front Next –Deciding its intensity and color.
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.
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.
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.
Chapter 5. Lighting Computer Graphics (spring, 2009) School of Computer Science University of Seoul.
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.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 55 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 55 Computer Graphics Three-Dimensional Graphics V.
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
@ 2017 by Jim X. Chen George Mason University
School of Computer Science
Open GL: Colors and Lighting
Computer Graphics, Lee Byung-Gook, Dongseo Univ.
Vectors, Normals, & Shading
Shading in OpenGL Ed Angel
Lighting Phong's Lighting Model normals
Illumination and Shading
Lighting and Materials
CS5500 Computer Graphics April 10, 2006.
Lighting – Material Properties
Last Time Liang-Barsky Details Weiler-Atherton clipping algorithm
Computer Graphics Material Colours and Lighting
Computer Graphics Shading in OpenGL
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

Now Playing: Multiply Jamie Lidell from Multiply Released June 13, 2005

Guinness ‘Noitulove’ Danny Kleinman Framestore CFC SIGGRAPH 2006 Available online: Available online:

Lighting and Shading in OpenGL / Artistic Shading Rick Skarbez, Instructor COMP 575 September 25, 2007

Announcements Programming Assignment 1 is due Thursday at 11:59pm

Submitting Programs Upload source and executable(s) (Windows or Mac) to digital dropbox on Blackboard blackboard.unc.edu Include a document that lists What optional components you did Instructions for use Any problems that you had, or components that do not work properly Please submit as a zip file with your name in the filename

Began our discussion of lighting and shading Discussed some of the simplifications of the lighting model made in OpenGL Last Time

Today Review lighting and shading Talk about how to implement lighting in OpenGL Demo of rendering with different lights and shading in OpenGL Discussion of artistic/non-photorealistic shading techniques

Light and Matter Specular reflection

Light and Matter Diffuse reflection

Light and Matter Diffuse Reflection

Light and Matter Translucency / Transparency

Point Lights Emit light evenly in all directions That is, photons (rays) from a point light all originate from the same point, and have directions evenly distributed over the sphere

Point light sources at an infinite (or near infinite) distance Can assume that all rays are parallel Directional Lights

Similar to point lights, but intensity of emitted light varies by direction Can think of it as only emitting rays over a patch on the sphere Spot Lights

Phong Reflection Model A simplification of the rendering equation Divided into 3 parts Ambient Diffuse Specular The sum of these components describes the color at a point

Phong Reflection Model I = I a (R a, L a ) + I d (n, l, R d, L d, a, b, c, d) + I s (r, v, R s, L s, n, a, b, c,d) R something represents how reflective the surface is L something represents the intensity of the light In practice, these are each 3-vectors One each for R, G, and B AmbientDiffuse Specular

Types of Shading There are several well-known / commonly-used shading methods Flat shading Gouraud shading Phong shading

Shading Comparison

Done with Review Different types of light interaction Ambient (pretends to be indirect) Diffuse Specular Different types of lights Point Spot Directional So how do we use lights in OpenGL?

Adding Lighting to Your Scene These are the steps required to add lighting to a scene: 1. Define normals for all vertices of all objects 2. Create, select, and position one or more lights 3. Create and select a lighting model 4. Define material properties of the objects in the scene

Defining Normals We discussed a method for computing normals last lecture Can assign your own normals by using glNormal3{bsidf}{v} The normal is applied to all subsequent glVertex calls, until a new glNormal is assigned Need to compute the normals yourself Helper functions light glutSolidSphere() define normals for you

Setting up Lights glLight{if}{v}(GLenum light, GLenum pname, TYPE param) Creates the light named light, which can be GL_LIGHT0, GL_LIGHT1,..., GL_LIGHT7 The API only guarantees support for 8 lights Sets the parameter pname to the value param

glLight Parameters GL_AMBIENT (L a in the Phong model) GL_DIFFUSE (L d ) GL_SPECULAR (L s ) These are all colors (vectors of 4 floats) GL_POSITION 3D osition of the light (vector of 4 floats)

glLight Parameters GL_CONSTANT_ATTENUATION (a) GL_LINEAR_ATTENUATION (b) GL_QUADRATIC_ATTENUATION (c) These are all single floating point values

glLight Parameters GL_SPOT_DIRECTION Direction (for light used as a spotlight) Vector of 3 floats GL_SPOT_EXPONENT Controls how “focused” the spot is GL_SPOT_CUTOFF Controls the angle of the spotlight

Selecting a Lighting Model An OpenGL lighting model has 4 components Global ambient light intensity Whether the viewer is local or infinitely far away Whether to light backfaces When to apply specular color

Setting up the Lighting Model glLightModel{if}{v}(GLenum pname, TYPE param) Sets the specified lighting model parameter to the specified value

glLightModel Parameters GL_LIGHT_MODEL_AMBIENT The ambient RGBA intensity of the entire scene Defaults to (0.2, 0.2, 0.2, 1.0) There is always some light GL_LIGHT_MODEL_TWO_SIDE Whether to compute lighting for back faces of polygons GL_TRUE or GL_FALSE

glLightModel Parameters GL_LIGHT_MODEL_LOCAL_VIEWER Whether to consider the viewer local to the scene Why would / wouldn’t we want to do this? GL_TRUE or GL_FALSE

glLightModel Parameters GL_LIGHT_MODEL_COLOR_CONTR OL Whether to apply specular highlights before or after texturing GL_SINGLE_COLOR or GL_SEPARATE_SPECULAR_COLOR

Turning on the Lights Need to enable lighting glEnable(GL_LIGHTING); Need to enable the lights you’ve set up glEnable(GL_LIGHT0); glEnable(GL_LIGHT1);...

Defining Material Properties glMaterial{if}{v}(GLenum face, GLenum pname, GLenum param) Sets the parameter pname to the value param for the face(s) specified by face face can be GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK

glMaterial Parameters GL_AMBIENT (R a in the Phong model) GL_DIFFUSE (R d ) GL_SPECULAR (R s ) All RGBA colors GL_AMBIENT_AND_DIFFUSE Used to set ambient and diffuse to the same color (just for convenience)

glMaterial Parameters GL_SHININESS (n in the Phong model) Exponent on the specular lighting component GL_EMISSION RGBA color of the materials “emitted” light Doesn’t actually emit light Makes the material appear to glow

Choosing a Shading Model OpenGL has flat and Gouraud shading models built in glShadeModel(GLenum mode) mode can be either GL_FLAT or GL_SMOOTH (for Gouraud shading)

Nate Robins’ OpenGL Demos Many of the demos I showed today were modified versions of Nate Robins’ GL Demos Download from

Summing up OpenGL Lighting and Shading Uses the Phong lighting model to compute color at vertices Can use flat or Gouraud shading Any questions about lighting and shading in OpenGL?

Realism in Shading We’ve discussed flat, Gouraud, and Phong shading These all attempt to imitate the appearance of objects in the real world This may not be desirable for all applications Consider biological drawings

Example

Non-Photorealistic Rendering Non-photorealistic rendering (NPR) is a broad term for rendering techniques that do not attempt to simulate the real world Also referred to as artistic rendering or artistic shading

Why NPR? Can be easier for a user to understand i.e. Enhancement of edge lines and highlights for technical illustrations Phong ShadingNPR

Why NPR? Can simulate artistic media i.e. Create an image that looks like watercolor paint on canvas

Why NPR? Can display the data that underlies the model i.e. scientific visualization

Why NPR? Because it looks cool i.e. movies, video games, etc. Viewtiful JoeOkami

NPR on Graphics Hardware Some of these techniques can now be used in real-time on modern graphics cards esp. Toon shading Doing so usually takes advantage of programmable shaders and texturing I may revisit toon shading as an example later in the semester

Next Time Moving on to vertex processing Projection Clipping Reminder: Programming assignment 1 due Thursday by 11:59pm Upload to blackboard.unc.edu