ComputerComputer GraphicsGraphics

The Physics Illumination Models & Shading

2

Local vs. 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 Computer Science, Technion ComputerComputer GraphicsGraphics 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 inch 2. If a flow of photos passing an inch 2 window is hitting a the red surface, how many photons hit an inch 2 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.

x

1 1 The length of the segment x θ x is 1/cos . 1 2 L θ The amount of incident x3 1 N light per unit surface area (thus reflected light) is

proportional to cos θ =N•L

Moon Paradox Diffuse Reflection  Illumination equation is now: = + ⋅= + θ I Ikaa IkNL pd( ) Ik aa Ik pd cos

 Ip - point light source’s intensity  kd - surface diffuse reflection coefficient

Question : Can we locate the light source from a shaded image ? 10

Specular Reflection Specular Reflection (Phong Model)  Shiny objects (e.g. metallic) reflect light in preferred Illumination equation: direction R determined by surface normal N. I = I k + I (k (N ⋅ L) + k (R⋅V)n ) N a a p d s L R θ θ α V ks - Specular reflection coefficient n - Specularity exponent

 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)

11 12

Copyright Gotsman, Elber, Barequet, Karni, Sheffer Page Computer Science, Technion ComputerComputer GraphicsGraphics Shading

Specular Reflection (cont’d)

 Exponent n of cosine controls decay factor of attenuation function:

 No physical basis but looks good:

13

 Retroreflector sends light back where it came from regardless of the angle of insidence

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)

17 18

Copyright Gotsman, Elber, Barequet, Karni, Sheffer Page Computer Science, Technion ComputerComputer GraphicsGraphics Shading

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).

19 20

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? 21 22

Phong Shading Comments on Shading

 Interpolate (at the vertices in image space) normal  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 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 as they are transformation dependent

23 24

Copyright Gotsman, Elber, Barequet, Karni, Sheffer Page Computer Science, Technion ComputerComputer GraphicsGraphics Shading

Comparison

25

Copyright Gotsman, Elber, Barequet, Karni, Sheffer Page Computer Science, Technion