1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.

Slides:



Advertisements
Similar presentations
Computer Graphics - Shading -
Advertisements

Computer Graphics Shading Lecture 13 John Shearer
Computer Graphics I, Fall 2010 Shading II.
1 Graphics CSCI 343, Fall 2013 Lecture 18 Lighting and Shading.
CAP 4703 Computer Graphic Methods Prof. Roy Levow Chapter 6.
CS 480/680 Computer Graphics Shading 2 Dr. Frederick C Harris, Jr.
Based on slides created by Edward Angel
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Shading I.
University of New Mexico
Shading II CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Lighting and Shading Wen-Chieh (Steve) Lin
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 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2006 Shading II Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
CS5500 Computer Graphics March 26, Shading Reference: Ed Angel’s book.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
CS 480/680 Computer Graphics Shading I Dr. Frederick C Harris, Jr.
Illumination.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Shading I Shandong University Software College Instructor: Zhou Yuanfeng
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Chapter 6: Shading Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Illumination & Reflectance Dr. Amy Zhang. Outline 2  Illumination and Reflectance  The Phong Reflectance Model  Shading in OpenGL.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Copyright  1999 by James H. Money. All rights reserved. Except as permitted under United States Copyright Act of 1976, no part of this publication may.
Introduction to Computer Graphics with WebGL
Curves and Surfaces Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico 1 Angel: Interactive.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Illumination.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
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.
Introduction to Computer Graphics with WebGL
Rendering Curves and Surfaces Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico 1 Angel:
Shading. For Further Reading Angel 7 th Ed: ­Chapter 6 2.
Specular Reflection Lecture 27 Mon, Nov 10, 2003.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
OpenGL Shading. 2 Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material interactions Build.
Lighting and Reflection Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Computer Graphics Lecture 25 Fasih ur Rehman. Last Class Shading.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
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.
Shading To determine the correct shades of color on the surface of graphical objects.
Introduction to Computer Graphics with WebGL
Shading II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico Angel: Interactive Computer.
Rendering Curves and Surfaces
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
CS5500 Computer Graphics April 10, 2006.
Introduction to Computer Graphics with WebGL
Isaac Gang University of Mary Hardin-Baylor
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
CS 480/680 Computer Graphics Shading.
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science
Lighting Calculations
Shading II Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science Laboratory University of New Mexico Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

2 Lighting and Shading II Ed Angel Professor Emeritus of Computer Science University of New Mexico Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

3 Objectives Continue discussion of shading Introduce modified Phong model Consider computation of required vectors Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

4 Ambient Light Ambient light is the result of multiple interactions between (large) light sources and the objects in the environment Amount and color depend on both the color of the light(s) and the material properties of the object Add k a I a to diffuse and specular terms reflection coef intensity of ambient light Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

5 Distance Terms The light from a point source that reaches a surface is inversely proportional to the square of the distance between them We can add a factor of the form 1/(a + bd +cd 2 ) to the diffuse and specular terms The constant and linear terms soften the effect of the point source Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

6 Light Sources In the Phong Model, we add the results from each light source Each light source has separate diffuse, specular, and ambient terms to allow for maximum flexibility even though this form does not have a physical justification Separate red, green and blue components Hence, 9 coefficients for each point source ­I dr, I dg, I db, I sr, I sg, I sb, I ar, I ag, I ab Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

7 Material Properties Material properties match light source properties ­Nine absorbtion coefficients k dr, k dg, k db, k sr, k sg, k sb, k ar, k ag, k ab ­Shininess coefficient  Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

8 Adding up the Components For each light source and each color component, the Phong model can be written (without the distance terms) as I = k d I d l · n + k s I s ( v · r )  + k a I a For each color component we add contributions from all sources Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

9 Modified Phong Model The specular term in the Phong model is problematic because it requires the calculation of a new reflection vector and view vector for each vertex Blinn suggested an approximation using the halfway vector that is more efficient Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

10 The Halfway Vector h is normalized vector halfway between l and v h = ( l + v )/ | l + v | Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

11 Using the halfway vector Replace ( v · r )  by ( n · h )   is chosen to match shininess Note that halfway angle is half of angle between r and v if vectors are coplanar Resulting model is known as the modified Phong or Phong-Blinn lighting model ­Specified in OpenGL standard Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

12 Example Only differences in these teapots are the parameters in the modified Phong model Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

13 Computation of Vectors l and v are specified by the application Can computer r from l and n Problem is determining n For simple surfaces is can be determined but how we determine n differs depending on underlying representation of surface OpenGL leaves determination of normal to application ­Exception for GLU quadrics and Bezier surfaces was deprecated Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

Computing Reflection Direction Angle of incidence = angle of reflection Normal, light direction and reflection direction are coplaner Want all three to be unit length 14 Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

15 Plane Normals Equation of plane: ax+by+cz+d = 0 From Chapter 4 we know that plane is determined by three points p 0, p 2, p 3 or normal n and p 0 Normal can be obtained by n = (p 2 -p 0 ) × (p 1 -p 0 ) Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

16 Normal to Sphere Implicit function f(x,y.z)=0 Normal given by gradient Sphere f(p)=p·p-1 n = [ ∂ f/ ∂ x, ∂ f /∂ y, ∂ f/ ∂ z] T =p Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

17 Parametric Form For sphere Tangent plane determined by vectors Normal given by cross product x=x(u,v)=cos u sin v y=y(u,v)=cos u cos v z= z(u,v)=sin u ∂p/∂u = [∂x/∂u, ∂y/∂u, ∂z/∂u]T ∂p/∂v = [∂x/∂v, ∂y/∂v, ∂z/∂v]T n = ∂p/∂u × ∂p/∂v Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

18 General Case We can compute parametric normals for other simple cases ­Quadrics ­Parametric polynomial surfaces Bezier surface patches (Chapter 11) Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015