---
title: "KB: Flickering models; Understanding Z-Fighting  and how to mitigate It"
canonical: "https://help.twinfinity.com/space/HCFD/154107917/KB%3A%20Flickering%20models%3B%20Understanding%20Z-Fighting%20%20and%20how%20to%20mitigate%20It"
format: markdown
---
In the world of 3D graphics, creating realistic and visually appealing scenes is a top priority. However, there's a common issue that can disrupt the illusion of depth and realism: Z-fighting. In this article, we'll dive into what Z-fighting is, why it occurs, and explore strategies to mitigate this visual artifact.

## What is Z-fighting?

Z-fighting, also known as "depth fighting," is a phenomenon in 3D computer graphics where two or more objects in a scene flicker or appear to fight for dominance in the rendered image. This typically occurs when the objects occupy nearly the same 3D space and have similar or identical Z-buffer (depth) values. As a result, the renderer struggles to determine which object should be displayed in front, leading to visual artifacts like flickering or distorted geometry.

## Why does Z-fighting occur?

Z-fighting is primarily a consequence of limited precision in the depth buffer of the graphics hardware. In a 3D rendering pipeline, the depth buffer stores the Z-coordinate (depth) of each pixel in the scene. This buffer has a finite bit depth, which means it can only represent a limited number of distinct depth values. When objects are very close to each other in 3D space and their depth values fall within the precision limits of the depth buffer, Z-fighting occurs.

## How can I mitigate Z-fighting?

1. Turn off the visualization of objects that may be represented in several disciplines, and ensure they are only shown once. Example: architectural models often contain objects that also appear in the structural model, like columns. Disabling the object in one of the models will reduce the Z-fighting at that object.
2. Make sure the models are exported in project space and not world space. Models that are very far away from the origin can have a more prominent Z-fighting problem.
3. If you are building Twinfinity apps, adjust the near and far planes of the camera to suit your scene. Increasing the near plane reduces Z-fighting significantly. The downside is the near-plane clipping that may occur.

## Conclusion

Z-fighting can be a frustrating issue in 3D graphics, but with the right strategies it can be effectively mitigated. By understanding its causes and employing techniques like managing clipping planes and exporting models in project space, developers and artists can create visually stunning, artifact-free 3D scenes and improve the overall quality of their work.