Lecture_001_Course_Overview

Perspective Projection

Perspective Projection

Perspective Projection

Notice v/1 = y/z. Therefore we can compute v = y/z by assuming the box size is 1.

Assume camera has unit size, then:

Practice Rendering Algorithm

Practice Rendering Algorithm

Draw an image: assume camera at C = (a, b, c):

  1. for each vertex V = (x, y, z) calculate V' = V - C
  2. let V' = (x', y', z'), then (u, v) = (\frac{x}{z}, \frac{y}{z})

Practice Rendering Algorithm Result

Practice Rendering Algorithm Result

The steps to draw is: 1. assuming the camera is at c = (2, 3, 5) 2. then subtract camera c from vertex (X, Y, Z) to get (x, y, z). This is simulating view direction 3. divide (x, y) by z to get (u, v), This is using the similar triangle to compute perspective projection.

Rasterization

Rasterization Accuracy

Naive Rasterization Rule: turn on a pixel if the line pass through the pixel

Naive Rasterization Rule: turn on a pixel if the line pass through the pixel

Diamond Rule: turn on a pixel if it is in the center of the pixel

Diamond Rule: turn on a pixel if it is in the center of the pixel

Thickness Rule: turn on a pixel if the line (with a specified width) occupies some percentage of a pixel

Rasterization Performance

Naive Rasterization: to cover n pixel, if we check the condition for every pixel we probably need n^2 times.

Incremental Line Rasterization

Incremental Line Rasterization

Incremental Line Rasterization: given endpoints (u_1, v_1), (u_2, v_2)

''' v = v1; for (u = u1; u <= u2; u++) { v += s; draw(u, round(v)) } '''

The Bresenham Line-Drawing Algorithm (https://www.cs.helsinki.fi/group/goa/mallinnus/lines/bresenh.html)

The Bresenham Line-Drawing Algorithm (https://www.cs.helsinki.fi/group/goa/mallinnus/lines/bresenh.html)

This algorithm requires floating point, which is bad. Also, if the line does not start in the diamond area, there are some fixes to the method. Modern implementation uses Branson Ham's line Algorithm.

Table of Content