Version: Unity 6.0 (6000.0)
语言 : 中文
设置着色器的深度测试模式
在着色器中检查或写入模板缓冲区

在着色器中禁用写入深度缓冲区

ZWrite 可设置在渲染过程中是否更新深度缓冲区内容。ZWrite 通常对不透明对象启用,对半透明对象禁用。

禁用 ZWrite 可能会导致不正确的深度排序。这时您需要在 CPU 上对几何体进行排序。

示例

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

Shader "Examples/CommandExample"
{
    SubShader
    {
         // The rest of the code that defines the SubShader goes here.

        Pass
        {    
              // Disables writing to the depth buffer for this Pass
              ZWrite Off
            
              // The rest of the code that defines the Pass goes here.
        }
    }
}

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

Shader "Examples/CommandExample"
{
    SubShader
    {
         // Disables writing to the depth buffer for this SubShader
         ZWrite Off

         // The rest of the code that defines the SubShader goes here.        

        Pass
        {    
              // The rest of the code that defines the Pass goes here.
        }
    }
}

其他资源

设置着色器的深度测试模式
在着色器中检查或写入模板缓冲区