University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Lighting/Shading III Week.

Slides:



Advertisements
Similar presentations
1 Graphics CSCI 343, Fall 2013 Lecture 18 Lighting and Shading.
Advertisements

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 Computer Graphics By : Mohammed abu Lamdy ITGD3107 University of Palestine Supervision: Assistant Professor Dr. Sana’a Wafa Al-Sayegh.
Illumination and Shading
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Shading I.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Lighting/Shading III Week.
Computer Graphics - Class 10
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Lighting/Shading II Week.
University of British Columbia CPSC 314 Computer Graphics May-June 2005 Tamara Munzner Lighting/Shading I, II,
IMGD 1001: Illumination by Mark Claypool
Lighting and Shading Wen-Chieh (Steve) Lin
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Lighting/Shading II Week.
3/23/2005 © Dr. Zachary Wartell 1 Illumination Models and Surface- Rendering Methods.
7M836 Animation & Rendering
Objectives Learn to shade objects so their images appear three- dimensional Learn to shade objects so their images appear three- dimensional Introduce.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Lighting and Shading Week.
6.1 Vis_04 Data Visualization Lecture 6 - A Rough Guide to Rendering.
CS5500 Computer Graphics March 26, Shading Reference: Ed Angel’s book.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Shading Week 5, Wed 1 Oct 2003 recap: lighting shading.
Illumination and Shading
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Lighting and Shading Week.
Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
CS 480/680 Computer Graphics Shading I Dr. Frederick C Harris, Jr.
CS 445 / 645: Introductory Computer Graphics
Computer Graphics Lighting.
1 Graphics CSCI 343, Fall 2013 Lecture 20 Lighting and Shading III.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Lighting/Shading II Week.
CS 445 / 645 Introduction to Computer Graphics Lecture 18 Shading Shading.
Shading (introduction to rendering). Rendering  We know how to specify the geometry but how is the color calculated.
COMPUTER GRAPHICS CS 482 – FALL 2014 AUGUST 27, 2014 FIXED-FUNCTION 3D GRAPHICS MESH SPECIFICATION LIGHTING SPECIFICATION REFLECTION SHADING HIERARCHICAL.
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.
Shading & Texture. Shading Flat Shading The process of assigning colors to pixels. Smooth Shading Gouraud ShadingPhong Shading Shading.
CSC418 Computer Graphics n Illumination n Lights n Lightinging models.
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.
David Luebke 1 10/26/2015 Lighting CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
Taku KomuraComputer Graphics Local Illumination and Shading Computer Graphics – Lecture 10 Taku Komura Institute for Perception, Action.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Lighting/Shading III Week.
Steve Sterley. Real World Lighting Physical objects tend to interact with light in three ways: Absorption (black body) Reflection (mirror) Transmission.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Basic Rendering Pipeline and Shading Spring 2012.
Komputer Grafik 2 (AK045206) Shading 1/17 Realisme : Shading.
Illumination and Shading
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
CS 445 / 645 Introduction to Computer Graphics Lecture 15 Shading Shading.
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.
Illumination Model How to compute color to represent a scene As in taking a photo in real life: – Camera – Lighting – Object Geometry Material Illumination.
Lighting/Shading University of British Columbia
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
David Luebke3/16/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
Illumination Models. Introduction 1 Illumination model: Given a point on a surface, what is the perceived color and intensity? Known as Lighting Model,
CPSC 314 LIGHTING AND SHADING UGRAD.CS.UBC.CA/~CS314 slide credits: Mikhail Bessmeltsev et al 1.
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
Shading To determine the correct shades of color on the surface of graphical objects.
Chapter 14 Shading Models.
Lighting/Shading III Week 7, Wed Mar 3
Illumination and Shading
Lighting/Shading II Week 7, Mon Mar 1
ייצוג בעולם 3D ייצוג מצולעים (פוליגונים) צלע קודקוד צלעe0 : {v1,v2}
Computer Graphics Material Colours and Lighting
Computer Graphics (Fall 2003)
Chapter 14 Shading Models.
Presentation transcript:

University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Lighting/Shading III Week 7, Fri Feb 29

2 News reminder: extra TA office hours in lab 2-4 so no office hours for me today 2-3

3 Reading for Lighting/Shading FCG Chap 9 Surface Shading RB Chap Lighting

4 Review: Light Source Placement geometry: positions and directions standard: world coordinate system effect: lights fixed wrt world geometry alternative: camera coordinate system effect: lights attached to camera (car headlights)

5 Review: Reflectance specular: perfect mirror with no scattering gloss: mixed, partial specularity diffuse: all directions with equal energy + + = specular + glossy + diffuse = reflectance distribution

6 Review: Diffuse Reflection I diffuse = k d I light (n l) nl 

7 n shiny : purely empirical constant, varies rate of falloff k s : specular coefficient, highlight color no physical basis, works ok in practice v Phong Lighting most common lighting model in computer graphics (Phong Bui-Tuong, 1975)

8 Phong Lighting: The n shiny Term Phong reflectance term drops off with divergence of viewing angle from ideal reflected ray what does this term control, visually? Viewing angle – reflected angle

9 Phong Examples varying l varying n shiny

10 Calculating Phong Lighting compute cosine term of Phong lighting with vectors v: unit vector towards viewer/eye r: ideal reflectance direction (unit vector) k s : specular component highlight color I light : incoming light intensity how to efficiently calculate r ? v

11 Calculating R Vector P = N cos  = projection of L onto N L P N 

12 Calculating R Vector P = N cos  = projection of L onto N P = N ( N · L ) L P N 

13 Calculating R Vector P = N cos  |L| |N| projection of L onto N P = N cos  L, N are unit length P = N ( N · L ) L P N 

14 Calculating R Vector P = N cos  |L| |N| projection of L onto N P = N cos  L, N are unit length P = N ( N · L ) 2 P = R + L 2 P – L = R 2 (N ( N · L )) - L = R L P P R L N 

15 Phong Lighting Model combine ambient, diffuse, specular components commonly called Phong lighting once per light once per color component reminder: normalize your vectors when calculating!

16 Phong Lighting: Intensity Plots

17 Blinn-Phong Model variation with better physical interpretation Jim Blinn, 1977 h : halfway vector h must also be explicitly normalized: h / |h| highlight occurs when h near n l n v h

18 Light Source Falloff quadratic falloff brightness of objects depends on power per unit area that hits the object the power per unit area for a point or spot light decreases quadratically with distance Area 4  r 2 Area 4  (2r) 2

19 Light Source Falloff non-quadratic falloff many systems allow for other falloffs allows for faking effect of area light sources OpenGL / graphics hardware I o : intensity of light source x : object point r : distance of light from x

20 Lighting Review lighting models ambient normals don’t matter Lambert/diffuse angle between surface normal and light Phong/specular surface normal, light, and viewpoint

21 Lighting in OpenGL light source: amount of RGB light emitted value represents percentage of full intensity e.g., (1.0,0.5,0.5) every light source emits ambient, diffuse, and specular light materials: amount of RGB light reflected value represents percentage reflected e.g., (0.0,1.0,0.5) interaction: component-wise multiply red light (1,0,0) x green surface (0,1,0) = black (0,0,0)

22 Lighting in OpenGL glLightfv(GL_LIGHT0, GL_AMBIENT, amb_light_rgba ); glLightfv(GL_LIGHT0, GL_DIFFUSE, dif_light_rgba ); glLightfv(GL_LIGHT0, GL_SPECULAR, spec_light_rgba ); glLightfv(GL_LIGHT0, GL_POSITION, position); glEnable(GL_LIGHT0); glMaterialfv( GL_FRONT, GL_AMBIENT, ambient_rgba ); glMaterialfv( GL_FRONT, GL_DIFFUSE, diffuse_rgba ); glMaterialfv( GL_FRONT, GL_SPECULAR, specular_rgba ); glMaterialfv( GL_FRONT, GL_SHININESS, n ); warning: glMaterial is expensive and tricky use cheap and simple glColor when possible see OpenGL Pitfall #14 from Kilgard’s list

23 Shading

24 Lighting vs. Shading lighting process of computing the luminous intensity (i.e., outgoing light) at a particular 3-D point, usually on a surface shading the process of assigning colors to pixels (why the distinction?)

25 Applying Illumination we now have an illumination model for a point on a surface if surface defined as mesh of polygonal facets, which points should we use? fairly expensive calculation several possible answers, each with different implications for visual quality of result

26 Applying Illumination polygonal/triangular models each facet has a constant surface normal if light is directional, diffuse reflectance is constant across the facet why?

27 Flat Shading simplest approach calculates illumination at a single point for each polygon obviously inaccurate for smooth surfaces

28 Flat Shading Approximations if an object really is faceted, is this accurate? no! for point sources, the direction to light varies across the facet for specular reflectance, direction to eye varies across the facet

29 Improving Flat Shading what if evaluate Phong lighting model at each pixel of the polygon? better, but result still clearly faceted for smoother-looking surfaces we introduce vertex normals at each vertex usually different from facet normal used only for shading think of as a better approximation of the real surface that the polygons approximate

30 Vertex Normals vertex normals may be provided with the model computed from first principles approximated by averaging the normals of the facets that share the vertex

31 Gouraud Shading most common approach, and what OpenGL does perform Phong lighting at the vertices linearly interpolate the resulting colors over faces along edges along scanlines C1C1 C2C2 C3C3 edge: mix of c 1, c 2 edge: mix of c1, c3 interior: mix of c1, c2, c3 does this eliminate the facets?

32 Gouraud Shading Artifacts often appears dull, chalky lacks accurate specular component if included, will be averaged over entire polygon C1C1 C2C2 C3C3 this interior shading missed! C1C1 C2C2 C3C3 this vertex shading spread over too much area

33 Gouraud Shading Artifacts Mach bands eye enhances discontinuity in first derivative very disturbing, especially for highlights

34 Gouraud Shading Artifacts C1C1 C2C2 C3C3 C4C4 Discontinuity in rate of color change occurs here Mach bands