Image
Previous | Next --- Slide 16 of 53
Back to Lecture Thumbnails
Image
kayvonf

Question: When the depth test is passed, why is the depth buffer updated to contain the depth of the current triangle at this sample point?

Image
lucida

because we might come across another triangle that's even closer (has smaller depth) than the current triangle, in which case we want to change the color buffer at the point x,y to that of this new triangle.

Image
kayvonf

@lucida. You're statement is correct, but that doesn't directly answer the question of why update the depth buffer. Care to clarify your thinking?

Image
lucida

@kayvonf if you never update the zbuffer then you'll always be comparing the depth of the current triangle to the depth of being infinitely far away (or whatever max depth value we use to initialize the zbuffer) in which case as long as the triangle covers the sample point, the color buffer will always be updated to take that triangle's color.

This would be an incorrect algorithm where the last triangle that happens to cover the sample in whatever order we choose to go through the triangles will be the one that gets to color the sample regardless of whether or not it is actually the closest triangle to the viewer.

We want to update the depth buffer to contain the depth of the current closest triangle so far so that only triangles that we come across later that are closer than this triangle can replace this triangle's color in the color buffer.

Image
kayvonf

@lucida. Excellent. I like that answer a lot better!