Z-buffer fighting

From ActiveWiki
Jump to navigation Jump to search
Commonly found z-buffer fighting within Active Worlds.

Z-Buffer fighting, commonly but technically incorrectly referred to as 'Z-buffering' or 'Zbuffer', is a common graphics glitch. The glitch occurs when two or more surfaces overlap each other on a parallel plane, resulting in the flickering of textures or colors of the surfaces as they "fight" for z-order, or order of visibility.

Terminology

A diagram showing a 3D scene and its z-buffer representation.

Z-Buffer is the calculation of the depth of an object, or how far an object is. The term 'fighting' comes from the fact the depths of the merging surfaces are the same and are 'fighting' for priority as the graphics card tries to decide which is displayed in front first.

Causes

Z-Buffer fighting is dependant on the z-buffer depth of the user's graphics card and, in respect to such, the distance between surfaces in the camera's Z plane. The "order" of the 3D objects in a view can be visualized as a greyscale image, where the pixels of an object are all colored by a shade of grey. The brighter the shade, the further they are, so when two objects have pixels overlapping, the darkest one is always rendered first.

In today's graphics cards, there are three modes of z-buffer depth: 16-bit, 24-bit and 32-bit. The higher the bit, the more shades of grey avaliable so to speak, therefore there is a higher percision when measuring distances between objects. A 32-bit depth will result in much less z-buffer fighting from much further distances than 16-bit as the rendering engine has higher percision. With a 16-bit depth, z-buffer fighting will start to occur on objects a relativley short distance away from the camera. Not only this, but "banding" will occur where the flickering becomes more pronounced, thick lines of overlap. Imagine the z-buffer representation, if you will, as a gradient with banding instead of smooth transistions from white to black.

Remedy

It is important that surfaces are distanced from each other by at least two CTRL-SHIFT clicks in order to avoid close-up overlapping and unpleasant graphical artefacts, which may turn down the visual appeal of a build greatly. However, if there is severe z-buffer fighting visible from distances, where overlap occurs in thick lines, your graphics card may be set to 16-bit depth buffer. This is the default for much older cards, or is turned on for troubleshooting reasons.

Methods for remedying this is different across graphics cards and rendering API's (DirectX or OpenGL):

Intel Graphics

A screenshot of 16-bit z-buffer depth enabled. The flickering is much closer to the user and much more pronounced.

Note: This only applies to OpenGL rendering. DirectX is set to 24-bit by default.

  • Right-click the desktop and click "Graphics Properties..."
  • Click on "3D Settings"
Note: If this button is missing, you may be using an OEM driver. Download the latest driver from Intel.
  • Find the attribute "Depth Buffer Bit Depth" and select "24 Bit Depth Buffer"
Note: Some cards may allow "32 Bit Depth Buffer". However, if memory conservation is a concern, 24-bit depth is sufficent.
  • Press OK for both windows. Restart Active Worlds if open.