-------------------------------------------- student : treacle graded by : Damian Isla problem set: ivscan -------------------------------------------- Renders 1st test (triangle) (0-3): 1.5 Renders 2nd test (rgb) (0-2): 1.5 Renders 3rd test (cube) (0-2): 2 Renders 4th test (interpen) (0-2): 0.5 Renders 5th test (ellipse) (0-2): 1 Renders 6th test (geekball) (0-2): 1 Exactitude (0-2): 1 total (0-15): 8.5 -------------------------------------------- notes: 1) The pixel-lighting rule that was described in class (only light a pixel when the center of that pixel is within the polygon) was not obeyed. 2) Color interpolation had some small problem: a bright outline was seen at times on the edges of polygons. 3) The most serious problem is that the system does not at all handle multiple polygons in a model any more complex than the cube. The unfortunate thing is that this could easily have been fixed, since looking at your code, I saw that you had done no visibility calculations. You were rendering the polygons in the order in which you got them, which is clearly wrong, since they are not handed to you in any particular order (and even if they were, there would be no garantee that they didn't intersect etc). You could have addded a simple XRES-wide z buffer, and that would have completely solved the problem. Some more subtle stuff: 4) You were not correctly intializing the EdgeRec, in that you were not correctly adjusting the starting value of X to account for the start of the edge being off-pixel-center. i.e. the initial value of xcurr does NOT equal xstart, but rather xstart + epsilon (finding epsilon is the trick). Because what you REALLY want is the value of X at the intersection of the edge with the next scan line. Note that it is not JUST X that should be adjusted in this way, but also color and depth (and inverse depth). 5) The above also counts for when you're interpolating along a scan-line (in RenderScanLine()). For each pixel that you light up, you want to take the values of color and depth at the CENTER of the pixel you're considering. So, if the starting X of an edge does not happen to be at the center of a pixel, you need to adjust the starting values of h and color to find their correctly interpolated values at the center of the first pixel. The formula for this 1-D case is: hstart = e1->hstart + (pixelCenter_X - e1->xcurr) * (e1->hcurr - e2->hcurr) / (e1->xcurr - e2->xcurr) and likewise for color. Where pixelCenter_X is the X-coordinate of the center of the first pixel you're lighting up, e1 is the first edge and e2 is the second edge. 6) Linearly interpolating Z in screen space is wrong. You needed to instead use linearly interpolated values of h in order to correcly gauge depth. --------------------------------------------