11-11-2024

Hello! This past week was fairly eventful, as we just had the 2024 U.S. Presidential Elections. As such, I didn't accomplish that much, but I will briefly summarize what I worked on.

Rasterizer

This past week, I worked on improving my rasterizer's rendering of triangle edges. Recall from last week's after image that I was rendering 3d hills with jagged black pixels around triangle edges. This is not what I wanted, but it was where I started this past week.

After floundering about trying to find a quick fix, I eventually started to drill down into my rasterizer's behaviours. My goal was to delve deeper until I found a conflict between by assumptions and the code's real behaviour.

One of the first contradictions I found was the depth values at triangle intersections. I found the same pixels were producing different depth values on separate triangles that actually intersect near the pixel location. I found out that the pixel locations are often offset by a small amount and this offset has a different slope for each triangle, thereby separating coicident samples on triangles that differ in slant.

Here is a visualization of which edge pixels had similar depth and which pixels did not.

Here is a half baked attempt to fix the edge problems by filling each fragment that is 'close' to a fragement that has rendered before it. The problem is that this doesn't catch all of the triangle edges and is barbarically large, compared to by goal of using a .00000...000001 epsilon tolerance.

Here is another attempt.

And another.

Here is a debugging technique. I don't remember what red and blue stand for, but they were helpful at the time.

Here is a rendering where the depth buffer didn't work. Back sides of the mountains were overpainting the front side near some of the mountain peaks.

I've run out of time to narrate the rest of my progress, but here are some pictures: Here the overpainting is even more extreme, giving the effect that the mountains are see thru. This one almost looks like it has shadows.

Something went wrong... I wanted to understand how my rasterizer was handling depth values. Rendering this depth map helped me to understand that depth was being rendered opposite what I wanted. I was able to flip by projector's depth calculation and rendered a depth map that is now color inverted. Much better!

Notice that there is no black line in the middle when the camera is rotated of axis alignment. Notice that the black line appears at only an axis aligned viewpoint. Again no black line. Its back!

This triangle has a bunch of missing pixels regularly along its edge. I found that there was a mistake in my triangle - box intersection code that didn't account for when the triangle perfectly intersects with a vertex of a box. Wrong pixels along the boundary at regular intervals. Believe it or not, this rectangle is great, except for 1 pixel. Here is a close up of the bottom right corner of the rentangle form the previous image. Notice that 1 pixel doesn't fit in with the others. It turns out that this pixel intersects 2 edges of the triangle and was associated with a different edge in each triangle. Crazy bug. Here is a rendering of two triangles that don't actually share an edge, since they are slanted differently.

This is roughly what I wanted. I'm happy to say that I improved edge rendering.

Next steps

I'd like to fix the 'banding' effects caused by premature integer rounding in the color calculations in my code. I'd also like to figure out how to remove the grid artifacts. I also want to look into the vertical black line bug. Once I'm confidant in rendering these triangles, I'd like to start trying to render something finer, such as a nice data visualization chart.