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

Slides:



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

Local Reflection Model Jian Huang, CS 594, Fall 2002.
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
Light Issues in Computer Graphics Presented by Saleema Amershi.
Illumination and Shading
Based on slides created by Edward Angel
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Shading I.
University of New Mexico
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 III Week.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Lighting/Shading I Week.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Lighting and Shading Week.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Lighting/Shading II Week.
University of Texas at Austin CS395T - Advanced Image Synthesis Spring 2006 Don Fussell Previous lecture Reflectance I BRDF, BTDF, BSDF Ideal specular.
Rendering (彩現 渲染).
University of British Columbia CPSC 314 Computer Graphics May-June 2005 Tamara Munzner Lighting/Shading I, II,
1 CSCE 641: Computer Graphics Lighting Jinxiang Chai.
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.
1 Project 2: Navigation five ways to navigate Absolute Rotate/Translate Keyboard Absolute Lookat Keyboard move wrt global coordinate system Relative Rolling.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Lighting and Shading Week.
CS5500 Computer Graphics March 26, Shading Reference: Ed Angel’s book.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Lighting Week 5, Mon 29 Sep 2003 recap: picking, light sources lighting.
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,
Course Website: Computer Graphics 16: Illumination.
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
CS 480/680 Computer Graphics Shading I Dr. Frederick C Harris, Jr.
Illumination.
CS 445 / 645: Introductory Computer Graphics
Computer Graphics Lighting.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Lighting/Shading II Week.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS 445: Introduction to Computer Graphics David Luebke University of Virginia Visibility Calculations and Occlusion Culling.
CSC418 Computer Graphics n Illumination n Lights n Lightinging models.
CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.
David Luebke 1 10/26/2015 Lighting CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
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.
Advanced Illumination Models Chapter 7 of “Real-Time Rendering, 3 rd Edition”
Illumination.
Announcements Office hours today 2:30-3:30 Graded midterms will be returned at the end of the class.
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.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Lighting/Shading I Week.
Illumination and Shading
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Photo-realistic Rendering and Global Illumination in Computer Graphics Spring 2012 Material Representation K. H. Ko School of Mechatronics Gwangju Institute.
Lecture Fall 2001 Illumination and Shading in OpenGL Light Sources Empirical Illumination Shading Transforming Normals Tong-Yee Lee.
02/2/05© 2005 University of Wisconsin Last Time Reflectance part 1 –Radiometry –Lambertian –Specular.
Cornell CS465 Spring 2004 Lecture 4© 2004 Steve Marschner 1 Shading CS 465 Lecture 4.
Where We Stand So far we know how to: –Transform between spaces –Rasterize –Decide what’s in front Next –Deciding its intensity and color.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
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
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
David Luebke3/16/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
CPSC 314 LIGHTING AND SHADING UGRAD.CS.UBC.CA/~CS314 slide credits: Mikhail Bessmeltsev et al 1.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
Computer Graphics: Illumination
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.
Shading To determine the correct shades of color on the surface of graphical objects.
Lighting/Shading III Week 7, Wed Mar 3
CSE 470 Introduction to Computer Graphics Arizona State University
Isaac Gang University of Mary Hardin-Baylor
Lighting/Shading II Week 7, Mon Mar 1
CS 480/680 Computer Graphics Shading.
Presentation transcript:

University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Lighting/Shading II Week 6, Fri Feb 16

2 Correction/News Homework 2 was posted Wed due Fri Mar 2 Project 2 out today due Mon Mar 5

3 News midterms returned project 2 out

4 Midterm Grading

5 Project 2: Navigation five ways to navigate Absolute Rotate/Translate Keyboard Absolute Lookat Keyboard move wrt global coordinate system Relative Rolling Ball Mouse spin around with mouse, as discussed in class Relative Flying Relative Mouselook use both mouse and keyboard, move wrt camera template: colored ground plane

6 Roll/Pitch/Yaw

7

8

9 Demo

10 Hints: Viewing don’t forget to flip y coordinate from mouse window system origin upper left OpenGL origin lower left all viewing transformations belong in modelview matrix, not projection matrix

11 Hint: Incremental Relative Motion motion is wrt current camera coords maintaining cumulative angles wrt world coords would be difficult computation in coord system used to draw previous frame (what you see!) is simple at time k, want p' = I k I k-1 ….I 5 I 4 I 3 I 2 I 1 Cp thus you want to premultiply: p’=ICp but postmultiplying by new matrix gives p’=CIp OpenGL modelview matrix has the info! sneaky trick: dump out modelview matrix with glGetDoublev() wipe the stack with glIdentity() apply incremental update matrix apply current camera coord matrix be careful to leave the modelview matrix unchanged after your display call (using push/pop)

12 Caution: OpenGL Matrix Storage OpenGL internal matrix storage is columnwise, not rowwise a e i m b f j n c g k o d h l p opposite of standard C/C++/Java convention possibly confusing if you look at the matrix from glGetDoublev()!

13 Reading for Wed/Today/Next Time FCG Chap 9 Surface Shading RB Chap Lighting

14 Review: Computing Barycentric Coordinates 2D triangle area half of parallelogram area from cross product A =  P1 +  P2 +  P3  P1 /A  P2 /A  P3 /A (  ) = (1,0,0) (0,1,0) (0,0,1) weighted combination of three points [demo]

15 Review: Light Sources directional/parallel lights point at infinity: (x,y,z,0) T point lights finite position: (x,y,z,1) T spotlights position, direction, angle ambient lights

16 Lighting I

17 Light Source Placement geometry: positions and directions standard: world coordinate system effect: lights fixed wrt world geometry demo: alternative: camera coordinate system effect: lights attached to camera (car headlights) points and directions undergo normal model/view transformation illumination calculations: camera coords

18 Types of Reflection specular (a.k.a. mirror or regular) reflection causes light to propagate without scattering. diffuse reflection sends light in all directions with equal energy. mixed reflection is a weighted combination of specular and diffuse.

19 Types of Reflection retro-reflection occurs when incident energy reflects in directions close to the incident direction, for a wide range of incident directions. gloss is the property of a material surface that involves mixed reflection and is responsible for the mirror like appearance of rough surfaces.

20 Reflectance Distribution Model most surfaces exhibit complex reflectances vary with incident and reflected directions. model with combination + + = specular + glossy + diffuse = reflectance distribution

21 Surface Roughness at a microscopic scale, all real surfaces are rough cast shadows on themselves “mask” reflected light: shadow Masked Light

22 Surface Roughness notice another effect of roughness: each “microfacet” is treated as a perfect mirror. incident light reflected in different directions by different facets. end result is mixed reflectance. smoother surfaces are more specular or glossy. random distribution of facet normals results in diffuse reflectance.

23 Physics of Diffuse Reflection ideal diffuse reflection very rough surface at the microscopic level real-world example: chalk microscopic variations mean incoming ray of light equally likely to be reflected in any direction over the hemisphere what does the reflected intensity depend on?

24 Lambert’s Cosine Law ideal diffuse surface reflection the energy reflected by a small portion of a surface from a light source in a given direction is proportional to the cosine of the angle between that direction and the surface normal reflected intensity independent of viewing direction depends on surface orientation wrt light often called Lambertian surfaces

25 Lambert’s Law intuitively: cross-sectional area of the “beam” intersecting an element of surface area is smaller for greater angles with the normal.

26 Computing Diffuse Reflection depends on angle of incidence: angle between surface normal and incoming light I diffuse = k d I light cos  in practice use vector arithmetic I diffuse = k d I light (n l) always normalize vectors used in lighting!!! n, l should be unit vectors scalar (B/W intensity) or 3-tuple or 4-tuple (color) k d : diffuse coefficient, surface color I light : incoming light intensity I diffuse : outgoing light intensity (for diffuse reflection) nl 

27 Diffuse Lighting Examples Lambertian sphere from several lighting angles: need only consider angles from 0° to 90° [demo] Brown exploratory on reflection exploratories/applets/reflection2D/reflection_2d_java_browser.html

28 diffuse plus specular Specular Reflection shiny surfaces exhibit specular reflection polished metal glossy car finish specular highlight bright spot from light shining on a specular surface view dependent highlight position is function of the viewer’s position

29 Specular Highlights Michiel van de Panne

30 Physics of Specular Reflection at the microscopic level a specular reflecting surface is very smooth thus rays of light are likely to bounce off the microgeometry in a mirror-like fashion the smoother the surface, the closer it becomes to a perfect mirror

31 Optics of Reflection reflection follows Snell’s Law: incoming ray and reflected ray lie in a plane with the surface normal angle the reflected ray forms with surface normal equals angle formed by incoming ray and surface normal  (l)ight =  (r)eflection

32 Non-Ideal Specular Reflectance Snell’s law applies to perfect mirror-like surfaces, but aside from mirrors (and chrome) few surfaces exhibit perfect specularity how can we capture the “softer” reflections of surface that are glossy, not mirror-like? one option: model the microgeometry of the surface and explicitly bounce rays off of it or…

33 Empirical Approximation we expect most reflected light to travel in direction predicted by Snell’s Law but because of microscopic surface variations, some light may be reflected in a direction slightly off the ideal reflected ray as angle from ideal reflected ray increases, we expect less light to be reflected

34 Empirical Approximation angular falloff how might we model this falloff?

35 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)

36 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

37 Phong Examples varying l varying n shiny

38 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

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

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

41 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 

42 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 

43 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!

44 Phong Lighting: Intensity Plots

45 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

46 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

47 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

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

49 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: multiply components red light (1,0,0) x green surface (0,1,0) = black (0,0,0)

50 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