Actually, that was a lie. It is, in fact, not remotely done. Which is good, since you can read about the steps being taken to correct the fact that it is not done.
In this entry Michael explains the z-buffer. Let me take a crack at the same thing, because I enjoy doing it…
So you’re there, rendering polygons, and you want to make sure that stuff in the background is properly obscured by the things in front of it. In the old days, it was a lot like painting with oil-based paints. You had to paint the far away details first, and gradually layer on things closer and closer to the viewer, covering up the stuff you painted before.
Of course, we’re talking about computer rendering here, so we’re trying to make a new painting 30 times a second. (Eat your heart out, Bob Ross.) The problem with drawing the world back-to-front, is that players insist on always moving around all the time. This means that you have to keep re-calculating the distances to all of the stuff to be rendered and then re-sorting them. That’s expensive even today, and back in the (very) early 90’s, computers had even less CPU time to waste on this sort of business.
Enter the z-buffer. (Sometimes called the depth buffer, because programmers are never happy until they have eleven different names for everything.) Imagine that we have two canvases. One is the rendering buffer, where we will paint our picture.
The other is the z-buffer, where we will record how far away things are. Now, the z-buffer is never shown to the user, but you can think of it as a grayscale image.
Every time we draw a pixel in the render buffer, we draw a pixel in the z-buffer as well, recording how far away that pixel is. In our example, farther = brighter. If we ever run into a situation where we would be drawing a brighter pixel over a darker one in the z-buffer, then we skip drawing it and neither the z-buffer or the render buffer are changed.
Once the painting is done, you wipe the z-buffer clean and start over.
But that only solves half of your problems. If you want to draw transparent stuff (like windows) then you need both a z-buffer and sorting to make it look right. Check out the Let’s Code entry to read the rest of that puzzle.
Dead or Alive 5 Last Round
I'm not surprised a fighting game has an absurd story. I just can't figure out why they bothered with the story at all.
A Lack of Vision and Leadership
People fault EA for being greedy, but their real sin is just how terrible they are at it.
DM of the Rings
Both a celebration and an evisceration of tabletop roleplaying games, by twisting the Lord of the Rings films into a D&D game.
What is Vulkan?
There's a new graphics API in town. What does that mean, and why do we need it?
Artless in Alderaan
People were so worried about the boring gameplay of The Old Republic they overlooked just how boring and amateur the art is.