\[ \mat{R}\of{\vec{n}, \theta} \;=\; \matrix{ x^2(1-c)+c & xy(1-c)-zs & xz(1-c)+ys \\ yx(1-c)+zs & y^2(1-c)+c & yz(1-c)-xs \\ xz(1-c)-ys & yz(1-c)+xs & z^2(1-c)+c } \]
\[ \vector{x\\y\\z} \;\mapsto\; \vector{x \cdot \frac{-d}{z} \\ y \cdot \frac{-d}{z} \\ -d} \quad\longleftrightarrow\quad \matrix{ 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & -1/d & 0 } \cdot \vector{x\\y\\z\\1} \;=\; \vector{x\\y\\z\\-z/d} \;\cong\; \vector{x \frac{-d}{z} \\ y \frac{-d}{z} \\ -d\\ 1} \]
A triangle is an affine combination of three points \[ \vec{X}\of{\alpha, \beta, \gamma} \;=\; \alpha\vec{A} + \beta\vec{B} + \gamma\vec{C}\]
with \(\alpha+\beta+\gamma=1\).Affine transformation preserve affine combinations
Planar projections map triangles to triangles
triangulation (flat shading)
no weighting
angle-weighted
ambient: \(I_a m_a\)
diffuse: \(I_l m_d \left( \vec{n} \cdot \vec{l} \right)\)
specular: \(I_l m_s \left( \vec{r} \cdot \vec{v} \right)^s\)

How would you implement this?
for (x=x0; x<=x1; ++x)
set_pixel(x, round(m*x + t));
for (x=x0, y=y0; x<=x1; ++x, y+=m)
set_pixel(x, round(y));
Δx = x1-x0;
Δy = y1-y0;
d = 2*Δy - Δx;
ΔE = 2*Δy;
ΔNE = 2*(Δy - Δx);
set_pixel(x0, y0);
for (x = x0, y = y0; x < x1;)
{
if (d <= 0) { d += ΔE; ++x; }
else { d += ΔNE; ++x; ++y }
set_pixel(x, y);
}
Good: Only integer arithmetic!
Crucial for systems without FPU



Flat Shading
Gouraud Shading
Phong Shading
Initialize depth buffer to \(\infty\)
Rasterize triangles, interpolate depth value per fragment
(x,y) still has a depth value zDepth buffer test & update
// draw color rgb to pixel (x,y)
void set_pixel(x, y, z, rgb)
{
// is current pixel closer than stored z-value?
if (z < zbuffer[x,y])
{
// write pixel's color to frame buffer
framebuffer[x,y] = rgb;
// update depth buffer
zbuffer[x,y] = z;
}
}
How will the z-buffer resolve visibility when two triangles \(A\) and \(B\) lie in the same plane and overlap? Assume triangle \(A\) is drawn before triangle \(B\).
How does quantization of the z-values affect visibility inside the view volume?
“Rasterization is fast, but needs cleverness to support complex visual effects. Ray tracing supports complex visual effects, but needs cleverness to be fast.”
– David Luebke, Nvidia