Documentation

Unity Engine

Download Unity

Unity Engine

ZTest command in ShaderLab reference

Reference for the ZTest command in ShaderLab.
Read time 2 minutesLast updated 19 days ago

Important
The Built-In Render Pipeline is deprecated and will be made obsolete in a future release.
It remains supported, including bug fixes and maintenance, through the full Unity 6.7 LTS lifecycle.
Sets the conditions under which geometry passes or fails depth testing.

Render pipeline compatibility

Feature name

Universal Render Pipeline (URP)

High Definition Render Pipeline (HDRP)

Custom SRP

Built-in Render Pipeline

ZTestYesYesYesYes

Syntax

This command makes a change to the render state. Use it in a
Pass
block to set the render state for that Pass, or use it in a
SubShader
block to set the render state for all Passes in that SubShader.

Signature

Example syntax

Function

ZTest [operation]ZTest LessSet the conditions under which geometry passes or fails depth testing.

Parameters

Parameter

Value

Function

operation
DisabledDisable the depth test.
NeverDraw no geometry, regardless of distance.
LessDraw geometry that is in front of existing geometry. Do not draw geometry that is at the same distance as or behind existing geometry.
EqualDraw geometry that is at the same distance as existing geometry. Do not draw geometry that is in front of or behind existing geometry.
LEqualDraw geometry that is in front of or at the same distance as existing geometry. Do not draw geometry that is behind existing geometry.

This is the default value.
GreaterDraw geometry that is behind existing geometry. Do not draw geometry that is at the same distance as or in front of existing geometry.
NotEqualDraw geometry that is not at the same distance as existing geometry. Do not draw geometry that is at the same distance as existing geometry.
GEqualDraw geometry that is behind or at the same distance as existing geometry. Do not draw geometry that is in front of existing geometry.
AlwaysNo depth testing occurs. Draw all geometry, regardless of distance.

Additional resources