CS 184: COMPUTER GRAPHICS
Lecture #19 -- Mo: 4/5, 1999.
PREVIOUS
< - - - - > CS
184 HOME < - - - - > CURRENT
< - - - - > NEXT
Preparation:
Read: Ch. 16.1 -- 16.3, "Illumination and Shading"
Lecture Topics
Review
Lighting models tell us what brightness and what color to expect
on each surface.
Shading/rendering concerns techniques to produce the apparent brightness
values on the display efficiently!
GLIDE Lighting Model
Various lights: ambient(sky), directed(sun), point(bulb), spot(focused).
Superposition Law: sum effects of individual lights
IDEAL AND REAL SURFACES
Ideal Lambert Surface
Perfect Mirrors
Approximation of Real Surfaces
Real surfaces are a mixture of chalky properties and of a dull, dusty mirror.
==> They have some diffuse as well as some specular reflection.
Reflected beam is spread out in a small angle around the unit vector
R (club shape).
==> Phong model: Models the reflective component on a real surface.
Intensity falls of with a user definable power of the cosine of the
deviation from ideal R dir.
Phong Lighting Model
Show effect of exponent on cos function.
Phong Highlight on glossy surface
Even uniform directional light, with flat surface can produce nonuniform
brightntess, if surface is partially reflective and we use a Phong illumination
model.
Better Approximations of Real Surfaces:
Real material are more complicated: Spreading of light (Phong exponent)
may depend on:
-- incident angles {Torrence Sparrow model },
-- the material in metal, reflected light penetrates deeper into
substrate, picks up color of metal {metalness factor},
-- color of light {spectral behavior}.
Surface Characterization
Relationship
between ka, kd, ks; and the C’s and the K’s
Shading
Examples using spheres.
Brightness Normalization.
Normally one tries to carefully choose lights so that the produced brightnesses
fall into the range 0 to 1.0 which is then mapped onto the, say, 256 discrete
beam intensities of CRT.
In spite of best intentions the sum of all calculated brightnesses
may exceed unity,
this may produce funny effects if left unchecked !
--> at the very least: clip to unity
--> better: detect and scale downwards all brightness values on object
or in scene.
Now that we know what the brightness is that we would like to see,
the question arises how can we efficiently generate all the pixels
of the right brightness ?
Shading and Rendering: Techniques to produce desired display brightness.
Needs to be efficient ! We cannot afford to do full shading calculation
for each pixel.
Lambert lighting model + flat faces + uniform illumination -> easy:
ONE brightness value per polygon.
==> just take a representative value at centroid of face, and apply
brightness values to all pixels of the polygon.
All other cases are harder: cause non-uniform apparent brightness.
Causes of non-uniform brightness
Point light or spotlight close to surface, or a curved surface will
have varying brightness.
Could sample more finely, and subdivide large polygons into many smaller
coplanar ones. But this would still look patchy with sharp, contrasty brightness
boundaries in between.
Need to smoothly blend these patches together: --> Sample at
corners of patches and then interpolate between these sample points.
We cast this procedure into the framework of our scan-line algorithm,
and do an interpolation similar to the interpolation of the z-values in
the z-buffer.
1. Gouraud Shading Technique:
Linear Interpolation of (Scalar) Brightness Values
Good for: handling small nonuniformities in illumination intensity, or
for
Polyhedral approximations to round objects.
Principle: Use barycentric intensity interpolation;
==> Implementation:
GOURAUD
SHADING TECHNIQUE:
1. compute shading at visual vertices, A...D
2. compute shading along edges by linear interpolation.
3. compute shading along spans by linear interpolation.
This also works for round objects:
Take an averaged brightness value at each corner, determined by averaged
vertex normal
== weighted face normals of all the adjacent polygons by angle subtended
at vertex.
But this is fake: edges remain straight! -- but it is efficient.
Smooth shading can be applied whenever the apparent brightness changes
across a surface,
-- either because the illumination is non-uniform,
-- the reflection has highlights,
-- or the surface is curved.
Limitations
of Gouraud Shading:
Some flat spots; extrema may be "short-circuited";
discontinuities at concave corners; missing highlights...
2nd Technique: Phong Shading:
Interpolate normal vector directions
We can fix some of the above problems with a more sophisticated interpolation
scheme.
PHONG
SHADING
Phong can interpolate over flat spots.
1. compute normals at visual vertices, A...D
2. compute normal along edges: (interpol)
3. compute normal along spans: (interpol)
4. for every pixel compute brightness from interpolated normal orientation.
Problems with Phong shading:
Not perfect either ! --> example of "corrugated surface"
Limitations
of Phong Shading
“Corrugated” structures with too few vertices (just zig-zag) may have
all parallel normal directions and cannot represent periodic shading variations.
Geometry that is not seen at vertices cannot be inferred !!
Illumination changes that are not seen at vertices cannot be inferred
!!
Procedural Shading
Texture Mapping, Bump Mapping, ...
Current Homework Assignment:
ASG#8
"Lighting Calculations and Gouraud Shading"
DUE: Saturday 4/10/99, 11:59pm.
CAN BE DONE WITH YOUR PARTNER OF CHOICE !
Midterm Exam will be held in class on April 14, 1999.
--> Next
Lecture
<-- Up to CS
184 HomePage
Page Editor: Carlo H. Séquin