What’s Z-order?

Print anything with Printful



Z-Order is a process for determining the visual order of objects in computer applications, often used in GUIs. It is based on traditional 3D naming conventions and can be used to optimize display speed and determine tab order. It is also used in graphics editing and 3D applications for layering and hidden surface removal.

Z-Order is the name given to the process involved in ordering which elements in a computer application should appear visually in front of other objects. A common use of z-order is when there are multiple windows open in a graphical user interface (GUI) and the z-order determines which windows will be drawn completely and which will be obscured by the windows above them. The name z-order comes from the traditional naming conventions used when describing three-dimensional (3D) spaces, where X refers to the right-left direction, Y to the up-down direction, and Z to the front-back direction. Almost all 3D applications use some form of z-order to quickly determine which objects should or should not be rendered to increase the display speed of a scene.

The actual axis described by a z-order can be thought of as extending into the field of view, moving towards or away from a viewer looking at the monitor. The farther away an object is, the higher its number in the sort order, while closer objects have lower numbers. Using simple sorting algorithms, objects further away from the observer can be excluded from view or drawn only partially, because they are obscured by closer objects.

A common use for z-order is to maintain the state of a set of open windows or other GUI elements in an application. When a window or other element is spawned, it is given an order number to indicate that it is in full view. If another window or element is opened, the z-order is shifted so that the new active window is considered closer. In addition to helping provide guidance that makes drawing GUI elements more efficient, some operating systems or applications also use it to determine the tab order so that when a user uses the keyboard to scroll through a GUI, the elements focus are selected based on their z-order.

Graphics editing programs use z-ordering methods to draw multi-layered images, ensuring that the layers are displayed in the correct sequence. This same principle is applied to programs used for publishing or layout, where different elements can be stacked to create a composite. In some situations, such as in vector graphics, the order is also used to compute geometric operations on objects, such as creating a union or difference between layered geometries.

In 3D applications, z-order is also sometimes called z-buffer or depth buffer. In addition to providing an optimized way to sort objects within a scene, it also allows for effective hidden surface removal. Objects that are sufficiently distant in the z-order number may be ignored and not rendered at all, while objects covered by shapes closer together may have entire segments of their geometry left unrendered because they cannot be seen.




Protect your devices with Threat Protection by NordVPN


Skip to content