Definition: Z-fighting is a display error in real-time rendering that occurs when two surfaces are at the same or almost the same position. The depth buffer cannot clearly decide which one is in front. The result is a flickering, striped pattern that changes with each camera movement.

English: Z-Fighting, Depth Fighting
German: Z-Fighting, Tiefenflimmern

How It Works

The z-buffer stores the depth of each pixel with limited precision. If two surfaces are congruent (coplanar) or closer together than this precision can resolve, sometimes one wins and sometimes the other. Because the rounding changes with each viewing angle, the pattern moves across the surface.

Two causes often occur together:

  • Coplanar geometry: Two surfaces lie exactly on top of each other.
  • Depth range too large: The near clipping plane is very close to the camera, and the far one is very far away. The precision at a distance then decreases strongly.

Relevance in Mechanical Engineering

CAD data is a typical source of z-fighting:

  • Duplicate parts: The same screw or the same sheet metal part is in the assembly more than once, for example because of variants or copies.
  • Surfaces on top of each other: Type plates, stickers, seals and coatings are modeled as separate bodies exactly on a surface.
  • Large scenes: A complete production line or hall with fine details reaches the limits of depth precision.

Solutions in data preparation:

  1. Remove duplicate geometry and hidden internal parts
  2. Move parts that lie on a surface by a very small distance, or transfer them as a texture to the base surface
  3. Divide large plants into sections and adjust the near and far clipping planes to the scene size
  4. In the renderer, use polygon offset for stickers if necessary, or activate reversed-Z or logarithmic depth

These steps are part of a clean CAD-to-3D conversion, so that the same model shows without flicker in the web viewer, on the tablet and in the VR headset.

Frequently Asked Questions (FAQ)

Why does my model flicker only at a distance?

Depth precision decreases with distance. A value for the near clipping plane that is too small makes the effect stronger. Often it is enough to move this plane farther away from the camera.

Is a better renderer a solution?

Only in part. Higher depth precision reduces the problem in large scenes. Coplanar surfaces from the CAD model still flicker, and you should clean them up during data preparation.