Z-depth is a term used in animation to describe how far away things are from the viewer.
Z-depth, also known as depth sorting, is an essential aspect of modern animation.
In 2d animation Z-Depth refers to the order things are displayed on the screen. The things at the back will be drawn first, and then we move closer to the viewer. So we would draw the background, then the midground (trees, houses), and then the foreground (characters, objects).
By changing the depth of the objects in a scene you can create a sense of perspective. By amimating depth and scale you can give the impression of objects moving towards or away from the camera.
In 3d Z-depth refers to the depth of each pixel in the rendered image. The Z-depth value is calculated based on the distance between the camera and the object. Objects closer to the camera will have a higher Z-depth value compared to those further away.
The Z-Depth can be used after rendering to apply special effects such as fog or depth-of-field. In fact the blur effects seen in modern phone cameras uses a form of Z-Depth to determine which parts of the image to blur.