
You move the camera and two surfaces start flickering. The texture looks like it is vibrating. Sometimes parts of a wall disappear and reappear rapidly.
This is called Z-fighting. It happens when two surfaces compete for the same depth position in the rendering pipeline. Unity is not broken. The GPU simply cannot decide which surface should be drawn first.
Below is a structured way to understand and fix Z-fighting in Unity.
Unity uses a depth buffer (Z-buffer) to determine which objects are in front of others. Each pixel stores a depth value.
If two surfaces are extremely close together, their depth values become nearly identical. The GPU alternates between them each frame, causing visible flickering.
The most common cause is two meshes occupying the same space.
Examples:
Solution:
The camera’s depth precision is not evenly distributed. A very large distance between near and far clip planes reduces depth accuracy.
Select your Camera and check:
Common mistake:
This setup destroys depth precision.
Better example:
The smaller the range, the better the precision.
If your objects are very far from world origin (for example, position 100000, 0, 100000), floating-point precision decreases.
This can cause visible Z-fighting even when meshes are not perfectly overlapping.
Solution:
If you intentionally place one surface on top of another (like bullet marks or road lines), offset the depth slightly using shader settings.
In custom shaders you can use:
Offset -1, -1
This tells the GPU to bias depth calculation and avoid conflict.
Coplanar means two surfaces share the exact same plane.
Example problem:
Instead, modify the mesh so they are not perfectly overlapping.
Sometimes flickering looks like Z-fighting but is actually shadow acne.
Select your Light and adjust:
If adjusting bias fixes the issue, the problem was shadow precision, not geometry overlap.
If using URP or HDRP, check your rendering settings:
Higher precision buffers can reduce artifacts in complex scenes.
Very thin meshes (like 0.0001 units thick) can produce depth artifacts.
Increase thickness slightly if possible.
Z-fighting is more visible when:
Understanding when it appears helps you design around it.
No. Z-fighting is a fundamental limitation of depth buffers in real-time rendering. Every 3D engine can experience it.
The solution is always structural: improve depth precision or remove overlapping geometry.
Z-fighting happens when two surfaces compete for the same depth value. The GPU cannot consistently decide which one is in front.
Most cases are solved by adjusting clip planes or removing overlapping meshes.
Once you understand how the depth buffer works, flickering geometry becomes easy to diagnose and prevent.