Illumination Models & Shading
Lighting vs. Shading Lighting Interaction between materials and light sources Physics Shading Determining the color of a pixel Computer Graphics ZBuffer(Scene) PutColor(x,y,Col(P)); end Shading usually determined by lighting Could use other methods (e.g. visualizing a function, NPR) 2
The Physics 3
Local vs. Global Illumination Models Local model direct and local interaction of each object with the light. Global model: interactions and exchange of light energy between all objects. 4
Light Sources Point source (A): All light originates at a point Rays hit planar surface at different incidence angles Parallel source (B): All light rays are parallel Rays hit a planar surface at identical incidence angles May be modeled as point source at infinity Also called directional source Area source (C): Light originates at finite area in space. In between the point and parallel sources B Also called distributed source A C 5
Material Reflection Type Specular reflection Smooth surface Reflects light at defined angle Diffuse reflection Rough surface Reflects light in all directions Demo Ambient light Light reflected many times, comes equally from all directions 6
Light/Reflection Types 7
Illumination Equation Looking for a value I(p) per point on the surface Represents the total contribution of all lights in the scene Takes into consideration Position of the viewer Position of the lights Color of the lights 8
Assume non-directional light in the environment Object illuminated with same light everywhere Looks like silhouette Ambient Light The Illumination equation: I = I a k a I a - ambient light intensity k a - fraction of ambient light reflected from surface. Also defines object color 9
Diffuse Light Dull surfaces such as solid matte plastic reflects incoming light uniformly in all directions Called diffuse or Lambertian reflection For light source normalized direction L and a surface with normal N, the amount of reflected light per unit surface area is proportional to N L = cos (independent of viewing direction) 1 L N 1/cos 10
Illumination equation is now: Diffuse Reflection I I k I k ( N L) I k I k cos a a p d a a p d I p k d - point light source s intensity - surface diffuse reflection coefficient 11
Specular Reflection Shiny objects (e.g. metallic) reflect light in preferred direction R determined by surface normal N. L N R V Most objects are not ideal mirrors also reflect in the immediate vicinity of R Phong Model approximate attenuation by the form of cos n (no real physical basis) 12
Specular Reflection (Phong Model) Illumination equation: k s n I I k I k ( N L) k ( R V) n a a p d s N - Specular reflection coefficient - Specularity exponent 13
Exponent n of cosine controls decay factor of attenuation function No physical basis but looks good Specular Reflection 14
For multiple light sources: I p of all light sources are added together Precautions should be taken from overflows More on Illumination Equation n p s p d p p a a V R k L N k I k I I ) ( ) ( 15
Given the lights in the scene Shading Algorithms How to compute the color at a given point on a triangle Three main types Flat shading. Gouraud shading. Phong shading. These roughly correspond to: Per-polygon shading. Per-vertex shading. Per-pixel shading. 16
Flat Shading Applied to piecewise linear polygonal models Simple surface lighting approximated over polygons Illumination value depends only on polygon normal each polygon is colored with a uniform intensity Looks non-smooth (worsened by Mach band effect) 17
Normal per Vertex If a polyhedron is an approximation of smooth surface: Assign to each vertex the normal of original surface at that point If surface is not available use estimated normal (e.g. average of neighboring faces). 18
Gouraud Shading Compute illumination intensity at vertices using normals Linearly interpolate intensity over polygon interior 19
Gouraud Shading Linearly interpolate lighting intensities at the vertices over interior pixels of the polygon, in the image plane Question: Can Gouraud shading support specular lighting? 20
Phong Shading Interpolate (at the vertices in image space) normal vectors instead of illumination intensities Apply the illumination equation for each interior pixel with its own (interpolated) normal 21
Comparison 22
Comparison phong flat gourard flat gourard phong 23