Version: Unity 6.0 (6000.0)
语言 : 中文
在着色器中设置混合模式
使用 AlphaToMask 模式减少锯齿

设置 GPU 渲染到的颜色通道

默认情况下,GPU 写入所有通道 (RGBA)。对于某些效果,您可能希望不修改某些通道;例如,您可以禁用颜色渲染来渲染无色阴影。另一个常见的用例是完全禁用颜色写入,以便您在一个缓冲区中填充数据而无需写入其他缓冲区;例如,您可能需要在不写入渲染目标的情况下填充模板缓冲区。

示例

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 模式减少锯齿