Version: 6000.3
语言: 中文
在着色器中设置混合模式
使用 AlphaToMask 模式减少锯齿

设置GPU渲染到的颜色通道

默认情况下,GPU 写入所有通道 (RGBA)。对于某些效果,您可能希望保持某些通道不修改;例如,您可以禁用颜色渲染以渲染未着色的阴影。另一个常见用例是完全禁用颜色写入,以便你可以用数据填充一个缓冲区,而无需写入其他缓冲区;例如,您可能想要填充模板缓冲区保存每像素 8 位值的内存存储。在 Unity 中,可以使用模板缓冲区来标记像素,然后仅渲染到通过模板作的像素。更多信息
请参阅术语表
而不写入呈现目标。

例子

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

        Pass
        {    
              // Enable writing only to the RGB channels for this Pass, which disables writing to the alpha channel
              ColorMask RGB

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

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

Shader "Examples/CommandExample"
{
    SubShader
    {
         // Enable writing only to the RGB channels for this SubShader, which disables writing to the alpha channel
         ColorMask RGB

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

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

其他资源

在着色器中设置混合模式
使用 AlphaToMask 模式减少锯齿