Lighting
Lighting
Model
Some of the contents used in this lecture belong
to…
0.75
Iaka + Ip [kd max {(L.N),0} + ks max{(R.V)k ,0}] = I
Mathematical Calculation of Phong Model
We need to incorporate the effect light present in environment. Thus total refelcted
light also includes ambient component.
Ambient Component = Iaka
Total reflected light intensity from Q,
I = Ambient Component + Diffuse Component + Specular Component
= Iaka + Ip kd (L.N) + Ip ks (R.V)k
More specifically,
I = Iaka + Ip [kd max {(L.N),0} + ks max{(R.V)k ,0}]
Additional Issues
When there are n light sources in the scene, their effects are cumulative: Intensity at Q,
I = Iaka + ∑(i=1 to n) Ipi {kd (L.N) + ks (R.V)k }
The intesnsity of red, green and blue component of reflected light,
Ir = Iakar + Ip kdr (L.N) + Ip ks (R.V)k
Ig = Iakag + Ip kdg (L.N) + Ip ks (R.V)k
Ib = Iakab + Ip kdb (L.N) + Ip ks (R.V)k
ks : coefficient for specular component which is same as the color of light source,
not affected by surface color.
Photo: Alex Canclini
Shading
• The process of assigning colors to pixels.
Shading
• Assumptions
– Light source at infinity
– Viewer at infinity
– The polygon represents the actual surface being modeled
Problems of Flat Shading
• Specular highlights tends to get lost
• If chosen point on polygon is at location of the light
source, then color of the polygon will be significantly
distorted.
Flat Shading
Smooth Shading
• Introduce vertex normals at each
vertex
– Used only for shading
– Think of as a better approximation of the real surface that
the polygons approximate
– Finds color value for each point in the polygon individually
• Two types
– Gouraud Shading
– Phong Shading (do not confuse with Phong Lighting Model)
Gouraud Shading
• Most common approach
• Perform Phong lighting at the vertices
• Linearly interpolate the resulting colors over faces
– Along edges
– Along scanline
Gouraud Shading
color3
ytop
y4 color4
color2
ys
ybott color1
xleft xright
Xright- Xleft
Gouraud Shading
color3
ytop
y4 color4
color2
ys
ybott color1
xleft xright
Xright- Xleft
Calculate the surface normals
along the scan line and the edge
using incremental approach
Problem of Gouraud Shading
– Often appears dull
– Lacks accurate specular component
C1
C3
x
x - xleft
mx= mleft + (mright - mleft)
x right - xleft
Calculate the surface normals along the scan line
and the edge using incremental approach
Phong vs Gouraud Shading
• Phong shading is more smooth
• If a highlight does not fall on a vertex, Gouraud shading may
miss it completely, but Phong shading does not.
Reference:
Computer Graphics: Principles and Practice: John F. Hughes, James D. Foley, Andries van Dam,
Steven K. Feiner (2nd Edition)
Chapter: 16.1.1 - 16.1.4, 16.1.6, 16.2.1 - 16.2.5