版本:Unity 6 (6000.0)
语言:English
在着色器中设置深度裁剪模式
在着色器中禁用写入深度缓冲区

在着色器中设置深度测试模式

深度测试允许具有“Early-Z”功能的 GPU 在管道的早期拒绝几何体,并确保几何体的正确排序。您可以更改深度测试的条件以实现诸如对象遮挡之类的视觉效果。

示例

此示例代码演示了在 Pass 块中使用此命令的语法。

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.
        }
    }
}

此示例代码演示了在 SubShader 块中使用此命令的语法。

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.
        }
    }
}

其他资源

在着色器中设置深度裁剪模式
在着色器中禁用写入深度缓冲区