Scan-Line Algorithms & Linear Interpolation
Depth Interpolation, Z-Buffering
Planar polygon with plane equation: Ax + By +
Cz + D = 0 ==> is LINEAR in all directions !
Solve for z: z = (-A/C)x + (-B/C)y -D --> dz/dx = const;
dz/dy = const.
Keep this information with the polygon, or with the edges
on the scan-line.
Allows quick updating by addition:
-- calculate initial z-value for edges
-- add dz*/dy along the edges, and
-- add dz/dx along coherent spans.
Updated depth values get used in z-buffer for depth comparison.
Brightness/Color Interpolation, Gouraud Shading
Same general approach is used again !
Assume we know brightness of a polyhedral object face at its vertices.
Now we can also linearly interpolate the brightness across the face.
However, if there are more than 3 vertices,
the brightness values may not form a global linear function
of x and y coordinates!
Thus do the interpolation in a bi-linear form
in trapezoidal (triangular) areas.
Compute di*/dy along each edge directly from brightness
at vertices.
Again, do quick updates by addition:
-- calculate initial i-value for edges
-- add the (di*/dy)'s along the edges.
Need to calculate a new di/dx along each span
for each scan-line.
The updated brightness values get used in the i-buffer, if the z-comparison
is successful.
NOTE: There may be tangent discontinuities in the generated
"brightness surface" !