62 · Rendering · 3D

Z-fighting

Flickering where two surfaces overlap.

The GPU decides which surface is in front using a depth buffer with limited precision. When two surfaces sit at almost the same depth, like a decal on a wall or two overlapping floors, rounding makes them take turns winning pixel by pixel, and they flicker as the camera moves. It gets worse far from the camera.

←→ move the cameraO offset on/off↑↓ near planeDrag to move

Try this: Move the camera: the overlapping planes flicker. Turn on a small offset (O), or raise the near plane with ↑.

Move the camera.

Prompt bit

Works for 2D or 3D in any engine (Unity, Unreal, Godot, web). Paste the short one for a quick fix, or the detailed one when you want it done properly.

Fix z-fighting: never place two surfaces at the same depth, give decals a small depth bias instead of a big offset, push the near clip plane out to about 0.1 m (not 0.001), and keep the far plane only as far as you can see.

45 words · one sentence to paste as is

Where it's used

Common mistakes

A near plane of 0.01 (ruins precision everywhere), fixing it by moving decals huge distances so they float, ignoring duplicate faces from model exports, and only testing up close where it does not show.

Writing this with an AI assistant? See our best AI coding assistants for game developers.

Missing a concept? Request one.

Related concepts

New concepts, in your inbox.

One short email when we add new concepts, plus our weekly roundup of AI tools for game devs. Unsubscribe any time.