If you have already gotten to the point where you can scan convert a triangle by interpreting its red,green,blue vertices down to the pixel level (the assignment that was due this week), then you are more than half way there. In these notes, I'm going to assume that you have completed that part of the algorithm.
I am also going to assume that you have added a surface normal vector to each vertex of your primitive untransformed shapes. As we discussed in class on April 19, here are the notes for how to compute the surface normals for a shape.
The complete steps of the zbuffer algorithm in a frame of animation are as follows:
After you have transformed the surface normal vector, you must then renormalize it (scale it back to unit length) before using it in the Phong shading algorithm.
If your camera is at the origin looking into positive z (the convention we adopted for ray tracing), then this computation is (x,y,z) → (fx/z,fy/z,1/z).
If your camera is at some positive z value z=f, looking back toward the origin (the convention we adopted earlier in the semester), this computation is (x,y,z) → (fx/(f-z),fy/(f-z),1/(f-z)).
Scan convert the triangle. As you scan convert (that is, interpolate down to the pixel) the projective z value pz of the triangle at this pixel, do a comparison between this interpolated pz and the value stored in the z-buffer at this pixel. If pz is closer, then replace both the value in the z-buffer and the value in the rgb framebuffer by the triangle's interpolated pz and the triangle's interpolated r,g,b.