Example
Choose the nearest triangle at each overlapping pixel.
highlighted = computed this step
Step 1 — Set up
Set up the exact input values.
red and blue triangles(((1, 1), (4, 1), (2, 4)), ((1, 2), (4, 2), (3, 4)))
Step 2 — Pixel A
Compute the highlighted value.
row, col, red z, blue z, winner(2, 2, 3, 2, blue)
Step 3 — Pixel B
Compute the highlighted value.
row, col, red z, blue z, winner(2, 3, 1, 4, red)
Step 4 — Result
State the final pixel set.
z-buffer pixels((2, 2, blue), (2, 3, red))
z-buffer-depth
A z-buffer stores the nearest depth seen so far at each pixel, so a later fragment only wins when its z value is smaller.