Version: 6000.3
语言: 中文
检查或写入着色器中的模具缓冲区
设置GPU渲染到的颜色通道

在着色器中设置混合模式

Blend命令确定 GPU 如何组合片段的输出着色器在 GPU 上运行的程序。更多信息
请参阅术语表
替换为渲染目标。

此命令的功能取决于混合作,您可以使用 BlendOp 命令进行设置。请注意,虽然所有图形 API 和硬件都支持混合本身,但某些混合作的支持更为有限。

启用混合会禁用GPU上的某些优化(主要是隐藏表面移除/Early-Z),这可能导致GPU帧时间增加。

常见混合类型

以下是最常见的混合类型的语法:

Blend SrcAlpha OneMinusSrcAlpha // Traditional transparency
Blend One OneMinusSrcAlpha // Premultiplied transparency
Blend One One // Additive
Blend OneMinusDstColor One // Soft additive
Blend DstColor Zero // Multiplicative
Blend DstColor SrcColor // 2x multiplicative

例子

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

        Pass
        {    
              // Enable regular alpha blending for this Pass
      Blend SrcAlpha OneMinusSrcAlpha
            
              // The rest of the code that defines the Pass goes here.
        }
    }
}

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

Shader "Examples/CommandExample"
{
    SubShader
    {
         // Enable regular alpha blending for this SubShader
         Blend SrcAlpha OneMinusSrcAlpha

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

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

其他资源

检查或写入着色器中的模具缓冲区
设置GPU渲染到的颜色通道