ELI5: Explain Like I'm 5

Z-buffer

Okay kiddo, let's imagine we are drawing a picture of a really cool car on a piece of paper. We want to draw the car so that it looks like it is 3D, with some parts of it appearing closer to us than others.

But if we just drew all the parts of the car on top of each other, it would not look right. We need a way to tell the paper which parts are in the front and which parts are in the back.

That's where the z-buffer comes in. It's like a list that keeps track of how far away each part of the car is from us. If one part is closer, it goes on the top of the list. If another part is farther away, it goes further down the list.

So when we draw the car, we can refer to the z-buffer to know which parts to draw on top of each other. The parts that are closer to us get drawn on top, and the parts that are further away get drawn below.

This helps us create a 3D-looking picture that appears more realistic. And that's the basic idea of what a z-buffer does!
Related topics others have asked about: