Computer Graphics IS F311 - Computer Science & Information

Computer Graphics IS F311 BITS Pilani
Pilani | Dubai | Goa | Hyderabad
Sundaresan Raman Illumina9on and Shading •  To determine color for pixels so that the image looks realis9c •  Model interac9on of light with objects •  Many physical processes too complex for prac9cal purposes or not accurately known •  Using “hacks” or empirical models that makes it work and efficient 4 Illumina9on and Shading •  Two different yet closely related issues •  Ligh9ng/illumina9on model –  Express factors related to light, which determines a surface color at a given point •  Shading model –  Determine when an illumina9on model will be invoked and with which arguments. –  Some shading model invokes an illumina9on model for each pixel, whereas others use interpola9on 5 Illumina9on models •  Ambient light •  Diffuse reflec9on (lamber9an) –  Light sources aVenua9on –  Colored light and surfaces •  Atmospheric aVenua9on •  Specular reflec9on –  The Phong illumina9on model •  Improving the point source model •  Mul9ple light sources 6 Ambient light • 
• 
• 
• 
Simplest case is self-­‐luminous objects I = Ki I = resul9ng intensity Ki is the object’s intrinsic intensity •  Can compute once per object and is independent of posi9on of the point being shaded 7 Ambient light •  Consider adding a light to the scene •  Imagine a diffuse, non-­‐direc9onal light source whose light has bounced around the scene many 9mes. We consider this to be ambient light. •  Intensity = (Ambient light Intensity) * (coefficient of ambient reflec9on) 8 Ambient light •  Constant color for every object independent of posi9ons, angles etc. •  I = Ia Ka •  I = resul9ng intensity •  Ia = intensity of ambient light •  Ka = ambient reflec9on coefficient, between 0 and 1 •  Not very useful by itself 9 Diffuse reflec9on •  Consider illumina9ng an object with a point light source •  Object’s brightness varies from one point to another based on direc9on of and distance to light source 11 Diffuse reflec9on •  Lamber9an reflec9on (for dull, maVe surface): These surfaces appear equally bright from all viewing angles as they reflect light with equal intensity in all direc9ons For a given surface, brightness depends only on angle q between L and N 13 Example Beam that intercepts a surface covers an area whose size is inversely propor9onal to the cosine of the angle the beam makes with N 14 Lambert’s law Lambert’s law: Amount of light reflected from a unit differen9al area dA toward the viewer is directly propor9onal to the cosine of the angle between the direc9on to the viewer and N. 15 Lamber9an reflec9on [cont] •  Intensity = (Point light intensity) * (coefficient of diffuse reflec9on) * cosine (angle of light incidence) 16 Lamber9an reflec9on [cont] •  Intensity = (ambient light intensity) * (coefficient of ambient reflec9on) + (point light intensity) * (coefficient of diffuse reflec9on) * cosine (angle of light incidence) 17 Light source aVenua9on •  Intensity = (ambient light intensity) * (coefficient of ambient reflec9on) + [light source aVenua9on factor * (point light intensity) * (coefficient of diffuse reflec9on) * cosine (angle of light incidence)] •  faV = 1 / dL2 •  faV = min(1 / [a + bdL +cdL2] , 1) for prac9cal purposes 18 Light source aVenua9on 19 Colored Lights, Surfaces •  Separate equa9ons for each component of the color model Atmoshperic aVenua9on – Depth cueing 21 Depth cueing 22 Specular reflec9on •  Shiny surfaces exhibit o  Specular reflec9on o  Highlight is of the color of incident light rather than object color o  Reflect light unequally in different direc9ons 23 Specular reflec9on •  Shiny surfaces exhibit o  Specular reflec9on o  Highlight is of the color of incident light rather than object color o  Reflect light unequally in different direc9ons 24 The Phong Illumina9on Model A popular illumina9on model for non-­‐perfect reflectors with maximum specular reflectance at a=0 and falls off as a increases 26 The Phong Illumina9on Model Sphere illuminated with different values of Ks and n 27 Calcula9ng the reflec9on vector R = 2N (N . L) -­‐ L 28 The halfway vector •  Using (N.H)n instead of (R.V)n in the specular reflec9on term •  H is constant when light source and viewer both at infinity 29 Improving the point light source model Warn’s model •  Model direc9onality of the light •  Hypothe9cal specular reflec9ng surface with specular coefficient = 1 30 Warn light source 31 Flaps and cones •  Flaps restrict light’s effect to a limited area of the scene in x, y and z •  Cones restrict light source’s effect by evalua9ng illumina9on model only when g < d 32 Cube and plane illuminated using Warn ligh9ng controls 33 Mul9ple light sources 34 Shading models for polygons • 
• 
• 
• 
• 
Constant shading Interpolated shading Polygon mesh shading Gouraud shading Phong shading 35 Shading models for polygons •  Constant shading –  Apply illumina9on model once for a polygon –  Only if both light source and viewer at infinity (so that N.L and N.V remain constant) •  Interpolated shading –  Shading informa9on linearly interpolated across triangle from vertex values 36 Interpolated shading •  Bilinear interpola9on –  Easy for scan line algorithm –  interpolate vertex colors along each edge of the polygon to get colors for start and end of scan-­‐
line –  Interpolated shading only approximates the evalua9on of illumina9on model at each point 37 Shading models for polygons •  Polygon mesh shading –  Shade each of the facet of a mesh that approximates a curved surface –  Mach band effect 38 Mach Band Human visual system exaggerates the intensity change at any edge where there is a discon9nuity in magnitude or slope of intensity 39 Gouraud shading •  Intensity interpola9on shading / Color interpola9on shading •  Extends interpolated shading applied to each polygon •  Assumes normal known for each vertex of the mesh or averages the adjacent facets normal for each vertex •  Compute ligh9ng equa9on at every vertex •  Interpolate colors across polygon 40 Gouraud shading 41 Gouraud shading Can be easily integrated with scan line visible surface algorithm 42 Phong shading •  Normal-­‐vector interpola9on shading •  Interpolate normal, normalize, apply illumina9on model to that pixel •  Eliminates ar9facts •  BeVer shading and highlights 44 Phong shading model Gouraud Shading Phong Shading Gouraud Shading Phong Shading 46 Problems with interpolated shading • 
• 
• 
• 
• 
Polygonal silhoueVe Perspec9ve distor9on Orienta9on dependence Problems at shared ver9ces Unrepresenta9ve vertex normals 47 Orienta9on dependence 48 Problems at shared ver9ces 49 Unrepresenta9ve vertex normals 50 Surface Detail •  Surface Detail Polygon •  Texture •  Bump Mapping 51 Shadows 52 Shadows •  Visible surface algorithms •  Mul9ple light source –  Surface must be classified rela9ve to each of them
•  Point light source and Extended light source •  Visibility from point light source – visibility from a view point 53 Shadows •  We need to change illumina9on model –  Need to add one more parameter Si 54 Shadows •  What happens to the areas in the shadow of all point light sources ? •  Early shadow algorithms [Blinn] –  Throwing shadows onto a flat plane –  Only works when objects don’t cast shadows on each other 55 Compu9ng shadows • 
• 
• 
• 
Scan-­‐line genera9on of shadows Two-­‐pass object precision shadow algorithm Shadow volume Two-­‐pass Z-­‐buffer shadow algorithm 56 Scan line genera9on of shadows •  Brute Force –  Projec9on of every polygon on every other polygon –  How to improve? –  Bouknight and Kelly approach 57 Two-­‐pass object-­‐precision shadow algorithm •  Shadow determina9on before visible surface determina9on •  Sectoring •  Transform lit polygons into modeling coordinates and store as surface detail polygons •  Perform hidden surface removal with arbitrary view point 58 Two-­‐pass object-­‐precision shadow algorithm 59 Shadow Volumes • 
• 
• 
• 
Defined by light source and object Only for polygons facing the light Sphere of influence Mul9ple light sources 60 Two-­‐pass Z-­‐buffer shadow algorithm •  Two-­‐pass –  For light source –  For observer’s view posi9on •  Image precision algorithm •  Calculate and store Z-­‐buffer for the image •  Transforma9on from observer’s view to light source’s view to check if the pixel is in shadow •  Shadow Maps 61