Notes on Oct 17 class

You'll be happy to know that the assignment due Oct 24 consists of a fun excursion into learning how to use a frame buffer. Once you have that under your belt, next week we will dive into implementing the rendering pipeline. Meanwhile, a complete outline of the rendering pipeline is below. I encourage you to study it.

## THE RENDERING PIPELINE

As we discussed in class, the complete rendering pipeline will look something like the following outline. There are a number of variations possible. For example, the shading step can take place over various points - from vertex shading that we have below, to pixel shading, more expensive but more powerful, in which shading is done later in the pipeline.

Note that you are now doing a complete implementation of the window transform, which consists of the combination of your camera transform and your perspective transform.

• Describe each object as a collection of triangles
• For each animation frame:
• Clear the zbuffer by filling it with zeroes.
• Transform the camera matrix C
• For each object:
• Transform the object by matrix M
• Multiply inverse camera matrix and object matrix T = (C-1M)
• For each triangle of the object:
• Transform each vertex of triangle by T
• Clip the triangle to get a (possibly null) collection of triangles
• For each of these triangles:
• Do shading on each vertex, to define [r,g,b] for that vertex
• Apply perspective transform to each vertex [x,y,z] → [-xf/z,-yf/z,-f/z]
• Apply viewport transform to each vertex to get [px,py,pz]
• Vertically split the triangle into two trapezoids
• For each of these two trapezoids:
• Loop through all scan lines from top to bottom
• At each scan line:
• Interpolate to get [px,r,g,b,pz] at left edge and at right edge
• Loop through pixels from pxL to pxR
• At each pixel, where we now have [r,g,b,pz]:
• if pz > zbuffer[px][py]:
• set zbuffer[px][py] to pz
• set framebuffer[px][py] to r,g,b