This command controls the writing of the surface pixels of an object to the Z-Buffer, that is, it allows us to ignore or respect the depth distance between the camera and an object. ZWrite has two values which are: On and Off, where “On” corresponds to its default value. We generally use this command when working with transparencies, e.g., when we activate the Blending options.
- ZWrite Off, for transparency.
- ZWrite On, default value.
Why should we disable the Z-Buffer when working with transparencies? Mainly because of the translucent pixel overlay (Z-fighting). When we work with semi-transparent objects, it is common that the GPU does not know which object lies in front of another, producing an overlapping effect between pixels when we move the camera in the scene. To fix this problem, we must simply deactivate the Z-Buffer by turning the ZWrite command to “Off” as the following example shows:
Shader “InspectorPath / shaderName”
{
Properties {} …
SubShader
{
Tags { "Queue" = "Transparent" “RenderType”=”Transparent”}
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
}
}
The Z-fighting occurs when we have two or more objects at the same distance from the camera, causing identical values in the Z-Buffer.

This effect occurs when trying to render a pixel at the end of the rendering pipeline. Since the Z-Buffer cannot determine which element is behind the other, it produces flickering lines that change shape depending on the camera’s position.
To correct this issue, we simply need to disable the Z-Buffer using the “ZWrite off” command.