Polygon Shading13
Polygon Shading13
I = I E + K A I AL + ∑i ( K D ( N • Li ) I i + K S (V • Ri ) I i )
n
Polygon Rendering Methods
• Given a freeform surface, one usually
approximates the surface as a polyhedra.
• How do we calculate in practice the
illumination at each point on the surface?
• Applying the illumination model at each
surface point is computationally
expensive.
Polygon Shading
• Can take advantage of spatial coherence
– Illumination calculations for pixels covered by same primitive are
related to each other
I = I E + K A I AL + ∑i ( K D ( N • Li ) I i + K S (V • Ri ) I i )
n
Piecewise linear approximation
Polygonal Approximation
Smooth Shading
Polygon Shading Algorithms
Wireframe Flat
Gouraud Phong
Watt Plate 7
Flat Shading
What if a faceted object is illuminated only by directional light sources and is
either diffuse or viewed from infinitely far away
Watt Plate 7
I = I E + K A I AL + ∑i ( K D ( N • Li ) I i + K S (V • Ri ) I i )
n
Gouraud Shading
• Smooth shading over adjacent polygons
– Curved surfaces
• Renders the polygon surface by linearly interpolating
intensity values across the surface.
Nv =
∑ k
Nk
|∑ k
Nk |
N v = ∑k N k
Bilinear
y
by three linear interpolations
I3
I1 IP
scan line
I2
x
Ib
w2
w1
I
Ia
Ib
I = w2 I a + w1 I b Ia
I = w2 I a + (1 − w2 ) I b
I = w2 ( I a − I b ) + I b w1 w2
Bilinear Interpolation
• Bilinearly interpolate colors at vertices
down and across scan lines
Bilinear Interpolation
• Ia = (Ys - Y2) / (Y1 - Y2) * I1 + (Y1 - Ys) / (Y1 - Y2) * I2
Ib = (Ys - Y3) / (Y1 - Y3) * I1 + (Y1 - Ys) / (Y1 - Y3) * I3
Ip = (Xb - Xp) / (Xb - Xa) * Ia + (Xp - Xa) / (Xb - Xa) * Ib
Gouraud Shading of a sphere
Phong Shading
A more accurate method for rendering a polygon
surface is to interpolate normal vectors, and then apply
the illumination model to each surface point.
Flat
Gouraud
Phong
Phong Shading
1. Determine the average unit normal at
each polygon vertex.
2. Linearly interpolate the vertex normals
over the surface polygon.
3. Apply the illumination model along each
scan line to calculate pixel intensities for
each surface point.
Phong Shading
• What if polygonal mesh is too coarse to capture illumination effects
in polygon interiors?
I = I E + K A I AL + ∑i ( K D ( N • Li ) I i + K S (V • Ri ) I i )
n
Phong Shading
One lighting calculation per pixel;
Approximate surface normals for points inside polygons
by bilinear interpolation of normals from vertices
Phong Shading
• Bilinearly interpolate surface normals at vertices down
and across scan lines
Flat Shading Gouraud Shading
Phong Shading
Diffuse
surface
With additional
specular
component
Polygon Shading Algorithms
Wireframe Flat
Gouraud Phong
Watt Plate 7
Shading Issues
• Problems with interpolated
shading:
– Polygonal silhouettes
– Perspective distortion
– Orientation dependence (due to
bilinear interpolation)
– Problems at T-vertices
– Problems computing shared
vertex normals
One shade or color for the
entire object, e.g., there really
is no shading being done
– Phong
More accurate
Global Illumination
In the real world light is everywhere.
• Reflects in every direction from
every
surface onto every surface.
• Anywhere in the world, light
comes
from infinite directions around.