i total k s i ambient i i i specular k s i light v r n
play

I total = k s I ambient + I i ( I specular = k s I light ( v r ) n - PowerPoint PPT Presentation

University of British Columbia Reading for Today Reading for Next Time Review: Light Source Placement CPSC 314 Computer Graphics FCG Chap 9 Surface Shading FCG Chap 10 Ray Tracing geometry: positions and directions Jan-Apr 2007


  1. University of British Columbia Reading for Today Reading for Next Time Review: Light Source Placement CPSC 314 Computer Graphics • FCG Chap 9 Surface Shading • FCG Chap 10 Ray Tracing • geometry: positions and directions Jan-Apr 2007 • RB Chap Lighting • only 10.1-10.7, 10.9, 10.11.2 • standard: world coordinate system Tamara Munzner • FCG Chap 22 Image-Based Rendering • effect: lights fixed wrt world geometry • alternative: camera coordinate system Lighting/Shading III • effect: lights attached to camera (car headlights) Week 7, Mon Feb 26 http://www.ugrad.cs.ubc.ca/~cs314/Vjan2007 2 3 4 Review: Reflectance Review: Reflection Equations Phong Lighting Model l n • specular : perfect mirror with no scattering • combine ambient, diffuse, specular components I diffuse = k d I light (n • l) • gloss : mixed, partial specularity θ # lights k d ( n • l i ) + k s ( v • r i ) n shiny ) • diffuse : all directions with equal energy ∑ I total = k s I ambient + I i ( I specular = k s I light ( v • r ) n shiny i = 1 Lighting II + + = • commonly called Phong lighting • once per light • once per color component specular + glossy + diffuse = reflectance distribution 2 ( N ( N · L )) – L = R • reminder: normalize your vectors when calculating! 5 6 7 8 Phong Lighting: Intensity Plots Blinn-Phong Model Light Source Falloff Light Source Falloff • variation with better physical interpretation • quadratic falloff • non-quadratic falloff • Jim Blinn, 1977 • brightness of objects depends on power per • many systems allow for other falloffs I out ( x ) = k s ( h • n ) n shiny • I in ( x );with h = ( l + v )/2 unit area that hits the object • allows for faking effect of area light sources • the power per unit area for a point or spot light • h : halfway vector • OpenGL / graphics hardware decreases quadratically with distance • h must also be explicitly normalized: h / |h| • I o : intensity of light source • highlight occurs when h near n Area 4 Area 4 π π r r 2 2 • x : object point n n • r : distance of light from x h h v v 1 l I in ( x ) I l = ⋅ 0 ar 2 br c + + Area Area 4 4 π π (2 (2 r) r) 2 2 9 10 11 12 Lighting Review Lighting in OpenGL Lighting in OpenGL glLightfv(GL_LIGHT0, GL_AMBIENT, amb_light_rgba ); • light source: amount of RGB light emitted • lighting models glLightfv(GL_LIGHT0, GL_DIFFUSE, dif_light_rgba ); • value represents percentage of full intensity glLightfv(GL_LIGHT0, GL_SPECULAR, spec_light_rgba ); • ambient e.g., (1.0,0.5,0.5) glLightfv(GL_LIGHT0, GL_POSITION, position); • normals don’t matter glEnable(GL_LIGHT0); • every light source emits ambient, diffuse, and specular light • Lambert/diffuse glMaterialfv( GL_FRONT, GL_AMBIENT, ambient_rgba ); Shading glMaterialfv( GL_FRONT, GL_DIFFUSE, diffuse_rgba ); • materials: amount of RGB light reflected • angle between surface normal and light glMaterialfv( GL_FRONT, GL_SPECULAR, specular_rgba ); • value represents percentage reflected glMaterialfv( GL_FRONT, GL_SHININESS, n ); • Phong/specular e.g., (0.0,1.0,0.5) • warning: glMaterial is expensive and tricky • surface normal, light, and viewpoint • interaction: multiply components • use cheap and simple glColor when possible • red light (1,0,0) x green surface (0,1,0) = black (0,0,0) • see OpenGL Pitfall #14 from Kilgard’s list http://www.opengl.org/resources/features/KilgardTechniques/oglpitfall/ 13 14 15 16

  2. Lighting vs. Shading Applying Illumination Applying Illumination Flat Shading • lighting • polygonal/triangular models • simplest approach calculates illumination at a • we now have an illumination model for a point single point for each polygon • process of computing the luminous intensity • each facet has a constant surface normal on a surface (i.e., outgoing light) at a particular 3-D point, • if light is directional, diffuse reflectance is • if surface defined as mesh of polygonal facets, usually on a surface constant across the facet which points should we use? • shading • why? • fairly expensive calculation • the process of assigning colors to pixels • several possible answers, each with different implications for visual quality of result • (why the distinction?) • obviously inaccurate for smooth surfaces 17 18 19 20 Flat Shading Approximations Improving Flat Shading Vertex Normals Gouraud Shading • if an object really is faceted, is • what if evaluate Phong lighting model at each pixel • vertex normals may be • most common approach, and what OpenGL does this accurate? of the polygon? • provided with the model • perform Phong lighting at the vertices • no! • better, but result still clearly faceted • computed from first principles • linearly interpolate the resulting colors over faces • for point sources, the direction to • for smoother-looking surfaces • along edges light varies across the facet • approximated by we introduce vertex normals at each • along scanlines edge: mix of c 1 , c 2 C 1 averaging the normals vertex • for specular reflectance, direction of the facets that does this eliminate the facets? to eye varies across the facet • usually different from facet normal share the vertex • used only for shading C 3 • think of as a better approximation of the real surface that the polygons approximate C 2 interior: mix of c1, c2, c3 edge: mix of c1, c3 21 22 23 24 Gouraud Shading Artifacts Gouraud Shading Artifacts Gouraud Shading Artifacts Gouraud Shading Artifacts • Mach bands • Mach bands • perspective transformations • often appears dull, chalky • eye enhances discontinuity in first derivative • affine combinations only invariant under affine, • lacks accurate specular component C 1 not under perspective transformations • very disturbing, especially for highlights • if included, will be averaged over entire • thus, perspective projection alters the linear polygon C 4 interpolation! C 3 Image C 1 C 1 plane C 2 C 3 C 3 Discontinuity in rate of color change C 2 this vertex shading spread occurs here C 2 Z – into the scene this interior shading missed! over too much area 25 26 27 28 Gouraud Shading Artifacts Phong Shading Phong Shading Phong Shading Difficulties • perspective transformation problem • linearly interpolate the vertex normals • computationally expensive • linearly interpolating surface normal across the facet, • colors slightly “swim” on the surface as objects • compute lighting equations at each pixel • per-pixel vector normalization and lighting applying Phong lighting model at every pixel move relative to the camera • same input as Gouraud shading computation! • can use specular component • usually ignored since often only small difference • pro: much smoother results • floating point operations required • con: considerably more expensive # lights • usually smaller than changes from lighting ( ) n shiny ∑ I total = k a I ambient + I i k d n ⋅ l i ( ) + k s v ⋅ r i ( ) • lighting after perspective projection variations • not the same as Phong lighting N 1 i = 1 • messes up the angles between vectors • to do it right • common confusion remember: normals used in diffuse and specular terms • either shading in object space • Phong lighting: empirical model to calculate illumination at • have to keep eye-space vectors around a point on a surface N 4 • or correction for perspective foreshortening • no direct support in pipeline hardware N 3 • expensive – thus hardly ever done for colors discontinuity in normal’s rate of • but can be simulated with texture mapping change harder to detect N 2 29 30 31 32

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend