Computer Graphics Shading
Total Page:16
File Type:pdf, Size:1020Kb
Computer Graphics Shading The Physics 2 Local vs. Global Illumination Models Example Local model – direct and local interaction of Ambient each object with the Diffuse light. Global model: interactions and exchange of light energy between Final different objects. Specular Image 3 Light Sources Ambient Light Point source (A): All light originates at a point !Assume non-directional light in the environment " ! Rays hit planar surface at different incidence angles !Object illuminated with same light everywhere !Parallel source (B): All light rays are parallel " ! Looks like silhouette " ! Rays hit a planar surface at identical incidence angles " ! May be modeled as point source at infinity !The Illumination equation I = Iaka " ! Also called directional source " ! Ia - ambient light !Area source (C): Light originates at finite area in intensity space. " ! k - fraction of " ! Inbetween the point and parallel sources a B C ambient light reflected " ! Also called distributed source A from surface. Also defines object color 5 6 Copyright Gotsman, Elber, Barequet, Karni, Sheffer Page 1 Computer Science, Technion Computer Graphics Shading Diffuse Light Diffused Ball ! Dull surfaces such as solid matte plastic reflects incoming light uniformly in all directions. Called diffuse or Lambertian reflection ! Understand intensity as the number of photons per inch2. If a flow of m photos passing each second through an inch2 window orthogonal to the flow, is hitting the red surface, how many photons hit an inch2 of the surface ? ! Let θ is the angle between the direction of incoming light and normal to surface, and let L, N be corresponding unit vectors. L N Moon Paradox Diffuse Reflection 10 Reflection from a perfect mirror Specular Reflection !Assume object is a perfect mirror. L N R !Shiny objects (e.g. metallic) reflect light in preferred θ θ α V 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 !Lights emits the object in direction V only if V=R α=0 !Phong Model – approximate attenuation by the form of cosnα (no real physical basis) 11 12 Copyright Gotsman, Elber, Barequet, Karni, Sheffer Page 2 Computer Science, Technion Computer Graphics Shading Specular Reflection (Phong Model) Specular Reflection (cont’d) !Illumination equation: ! Exponent n of cosine controls decay factor of attenuation !ks - Specular reflection coefficient function: !n - Specularity exponent ! No physical basis but looks good: 13 14 !Retroreflector " ! sends light back where it came from regardless of the angle of insidence More on Illumination Equation ! For multiple light sources: shadingmodel " ! Ip of all light sources are added together " ! Precautions should be taken from overflows 18 Copyright Gotsman, Elber, Barequet, Karni, Sheffer Page 3 Computer Science, Technion Computer Graphics Shading Even More on Illumination Equation Flat Shading ! For distance/atmospheric attenuation sources: ! 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 dp - distance between surface and light source and/or uniform intensity distance between surface and viewer (heuristic ! Looks non-smooth (worsened by Mach band effect) atmospheric attenuation) 19 20 Normal per Vertex Gouraud Shading !Compute illumination intensity at vertices using those normals !Interpolate intensity over polygon interior 21 22 Gouraud Shading 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 23 24 Copyright Gotsman, Elber, Barequet, Karni, Sheffer Page 4 Computer Science, Technion Computer Graphics Shading Comments on Shading Comparison !Phong shading is more expensive (why?) but well worth the effort !Can achieve good looking specular highlight effects !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 25 26 Copyright Gotsman, Elber, Barequet, Karni, Sheffer Page 5 Computer Science, Technion .