Warm-up Exercises:
Still to do:
Solution #1: Ray Casting:
-- Cast a ray from the eye through each pixel into
the scene,
-- determine what surface gets hit first (display
that color).
Solution #2: Painter's Algorithm:
This is one of several "List-priority Algorithms"
-- Depth-sort all front-facing polygons;
-- (over-) paint them back-to-front.
-- Complete depth sorting is not be possible when
there are cyclic overlaps;
-- then we need to break polygons into smaller parts.
(There are many other algorithms that break up polygons into smaller
parts --> later).
Solution #3: Horizon-Line Algorithm:
Suited primarily for height functions and for terrains.
-- Paint slices through the function from front-to-back.
-- keep an up-to-date upper (and lower) horizon
= silhoutette edge Max-y(x) and perhaps Min-y(x).
-- The area between these two horizons is shadowed
out;
-- Only draw new elements above and below.
Solution #4: Z-Buffer
The z-buffer is a 2D array of storage elements that stores for each
pixel (R,G,B)color and a z-depth.
-- Paint all triangles (one at a time) into the
z-buffer (using scan-line-based raster filling;
-- the front-most pixel and its depth and color
will be retained -- and finally displayed.
-- The z-depth of each pixel can be efficiently
calculated by linear interpolation,
i.e., by fixed incrementation
in y and in x (since we assume all polyhedron faces to be planar).
Extra
Notes on Scan-Line Algorithms