Computer Graphicsgraphics Shading
Total Page:16
File Type:pdf, Size:1020Kb
ComputerComputer GraphicsGraphics Shading The Physics Illumination Models & Shading 2 Local vs. Global Illumination Models Light Sources Point source (A): All light originates at a point Local model – direct Rays hit planar surface at different incidence angles and local interaction of Parallel source (B): All light rays are parallel each object with the Rays hit a planar surface at identical incidence angles light. May be modeled as point source at infinity Also called directional source Area source (C): Light originates at finite area in Global model : space. interactions and Inbetween the point and parallel sources exchange of light B C energy between Also called distributed source A different objects. 3 4 Diffuse Light Ambient Light Dull surfaces such as solid matte plastic reflects incoming light Assume non-directional light in the environment uniformly in all directions. Called diffuse or Lambertian reflection Object illuminated with same light everywhere Understand intensity as the number of photons per inch 2. If a flow Looks like silhouette of photos passing an inch 2 window is hitting a the red surface, how many photons hit an inch 2 of the surface ? The Illumination equation I = I k θ a a Let is the angle between the direction of incoming light and Ia - ambient light normal to surface, and let L, N be corresponding unit vectors. intensity x1 The length of the segment ka - fraction of 1 x θ ambient light reflected x is 1/cos . 1 2 from surface. L θ The amount of incident x3 Also defines object 1 N light per unit surface area (thus reflected light) is color proportional to cos θ =N•L 5 Copyright Gotsman, Elber, Barequet, Karni, Sheffer Page Computer Science, Technion ComputerComputer GraphicsGraphics Shading Diffused Ball Moon Paradox Diffuse Reflection Specular Reflection Illumination equation is now: Shiny objects (e.g. metallic) reflect light in preferred = + ⋅= + θ direction R determined by surface normal N. I Ikaa IkNL pd( ) Ik aa Ik pd cos N Ip - point light source’s intensity L R θ θ α kd - surface diffuse reflection coefficient 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) Question : Can we locate the light source from a shaded image ? 9 10 Specular Reflection (Phong Model) Specular Reflection (cont’d) Illumination equation: Exponent n of cosine controls = + ( ⋅ + ⋅ n ) I Iaka I p kd (N L) ks (R V) decay factor of attenuation ks - Specular reflection coefficient function: n - Specularity exponent No physical basis but looks good: 11 12 Copyright Gotsman, Elber, Barequet, Karni, Sheffer Page Computer Science, Technion ComputerComputer GraphicsGraphics Shading More on Illumination Equation Even More on Illumination Equation For multiple light sources: shadingmodel For distance/atmospheric attenuation sources: n I = I k + I (k (N ⋅ L ) + k (R ⋅V ) ) I p a a ∑ p d p s p I = I k + ()k (N ⋅ L ) + k (R ⋅V )n p a a ∑ d p s p p d p Ip of all light sources are added together Precautions should be taken from overflows dp - distance between surface and light source and/or distance between surface and viewer (heuristic atmospheric attenuation) 13 14 Flat Shading Normal per Vertex 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 If a polyhedron is an approximation of smooth by Mach band effect) 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). 15 16 Gouraud Shading Gouraud Shading Linearly interpolate lighting intensities at the vertices over interior pixels of the polygon, in the image plane Compute illumination intensity at vertices using those normals Interpolate intensity over polygon interior Question : Can Gouraud shading support specular lighting? 17 18 Copyright Gotsman, Elber, Barequet, Karni, Sheffer Page Computer Science, Technion ComputerComputer GraphicsGraphics Shading Phong Shading Comments on Shading Interpolate (at the vertices in image space) normal Phong shading is more expensive (why?) but well vectors instead of illumination intensities worth the effort Apply the illumination equation for each interior pixel Can achieve good looking specular highlight effects with its own (interpolated) normal Both the Gouraud and Phong shading schemes are performed in the image plane and fit well into a polygonal scan-conversion fill scheme Both the Gouraud and Phong are view dependent Can cause artifacts during animation as they are transformation dependent 19 20 Comparison 21 Copyright Gotsman, Elber, Barequet, Karni, Sheffer Page Computer Science, Technion.