Sets the conditions under which geometry passes or fails depth testing.
Depth testing allows GPUs that have “Early-Z” functionality to reject geometry early in the pipeline, and also ensures correct ordering of the geometry. You can change the conditions of depth testing to achieve visual effects such as object occlusion.
Feature name | 빌트인 렌더 파이프라인 | 유니버설 렌더 파이프라인(URP) | 고해상도 렌더 파이프라인(HDRP) | Custom SRP |
---|---|---|---|---|
ZTest | 지원 | 지원 | 지원 | 지원 |
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 | 기능 |
---|---|---|
ZTest [operation] | ZTest Less | Set the conditions under which geometry passes or fails depth testing. |
파라미터 | 값 | 기능 |
---|---|---|
operation | Less | Draw geometry that is in front of existing geometry. Do not draw geometry that is at the same distance as or behind existing geometry. |
LEqual | Draw 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. |
|
Equal | Draw geometry that is at the same distance as existing geometry. Do not draw geometry that is in front of or behind existing geometry. | |
GEqual | Draw geometry that is behind or at the same distance as existing geometry. Do not draw geometry that is in front of existing geometry. | |
Greater | Draw geometry that is behind existing geometry. Do not draw geometry that is at the same distance as or in front of existing geometry. | |
NotEqual | Draw geometry that is not at the same distance as existing geometry. Do not draw geometry that is at the same distance as existing geometry. | |
Always | No depth testing occurs. Draw all geometry, regardless of distance. |
This example code demonstrates the syntax for using this command in a Pass block.
Shader "Examples/CommandExample"
{
SubShader
{
// The rest of the code that defines the SubShader goes here.
Pass
{
// Sets the depth test operation to Equal for all pixels in this Pass
// You would typically do this if you want to render the geometry exactly where already rendered geometry is
ZTest Equal
// The rest of the code that defines the Pass goes here.
}
}
}
This example code demonstrates the syntax for using this command in a SubShader block.
Shader "Examples/CommandExample"
{
SubShader
{
// Sets the depth test operation to Equal for all pixels in this Pass
// You would typically do this if you want to render the geometry exactly where already rendered geometry is
ZTest Equal
// The rest of the code that defines the SubShader goes here.
Pass
{
// The rest of the code that defines the Pass goes here.
}
}
}