Version: 6000.3
语言: 中文
在着色器中设置深度测试模式
检查或写入着色器中的模具缓冲区

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

ZWrite设置深度缓冲区 保存图像中每个像素的 z 值深度的内存存储,其中 z 值是投影平面中每个呈现像素的深度。更多信息
请参阅术语表
内容在渲染期间更新。通常,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.
        }
    }
}

其他资源

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