Z-fighting
Jump to navigation
Jump to search
Z-fighting occurs when the GPU renders
coplanar triangles at the same time. It generally manifests as flickering between the polygons with a striped pattern changing with the camera angle. It can also appear due to imprecision in the Z buffer. For example, non-coplanar faces that are close together might look normal up close, but might flicker at a long distance.
Mitigation
VBSP and
HLCSG will automatically chop brush coplanar brush faces within the same bmodel. In
, this does not seem to occur for detail brushes[confirm].
- Move polygons away from eachother. The bigger the gap, the longer the distance at which they will Z-fight.
- (only in
) Use $decal for one of the overlapping materials. It offsets any faces by a minuscule amount along the surface normal, thus increasing the gap and reducing Z-fighting. Note that it will also disable writing to the Z buffer, causing the triangle's depth to be inherited from geometry rendered behind it. - Increase the precision of the Z buffer by bumping up the near Z and reducing the far Z (in
, this is controlled via env_fog_controller; in
, this is controlled via worldspawn). This can also be done in
Hammer's settings (titled Back clipping plane), but it will not change anything in-game. In
Hammer++, the near Z can also be changed. - If Z-fighting occurs on a studio model, the geometry can be split into multiple $body meshes; later-defined meshes will be rendered on top of earlier-defined meshes.
- Due to the mathematics of how additive blending works, Additive-blended surfaces will never Z-fight with other additive-blended surfaces.
External links
Z-fighting on Wikipedia