Version: 2023.1
言語: 日本語
ShaderLab コマンド: Blend
ShaderLab コマンド: ColorMask

ShaderLab コマンド: BlendOp

Blend コマンドで使用されるブレンディング操作を指定します。このコマンドが効果を発揮するためには、同じ Pass ブロック (このコマンドが Pass ブロック内にある場合) または SubShader ブロック (このコマンドが SubShader ブロック内にある場合) に Blend コマンドが存在する必要があります。

すべてのデバイスですべてのブレンド操作がサポートされているわけではなく、サポートはグラフィックス API とハードウェアの両方に依存します。グラフィックス API によって、サポートされていないブレンディング操作の扱いは異なります。GL はサポートされていない操作をスキップし、Vulkan と Metal は Add 操作にフォールバックします。

レンダーパイプラインの互換性

機能名 ビルトインレンダーパイプライン ユニバーサルレンダーパイプライン (URP) HD レンダーパイプライン (HDRP) カスタム SRP
BlendOp

使用法

このコマンドは、レンダー状態の変更を行います。Pass ブロックで使用すると、そのパスのレンダー状態を設定することができます。また、SubShader ブロックで使用すると、そのサブシェーダー内のすべてのパスのレンダー状態を設定することができます。

シグネチャ 構文例 機能
BlendOp <operation> BlendOp Sub Blend コマンドで使用するブレンド操作を設定します。

有効なパラメーター値

パラメーター 機能
operation Add 同時にソースとデスティネーションを追加します。
Sub ソースからデスティネーションを減算します
RevSub デスティネーションからソースを減算します
Min Use the smaller of source and destination. (1)
Max Use the larger of source and destination. (1)
LogicalClear Logical operation: Clear (0) (1)
LogicalSet Logical operation: Set (1) (1)
LogicalCopy Logical operation: Copy (s) (1)
LogicalCopyInverted 論理演算: Copy inverted (!s) (注 2 参照)
LogicalNoop Logical operation: Noop (d) (1)
LogicalInvert Logical operation: Invert (!d) (1)
LogicalAnd Logical operation: And (s & d) (1)
LogicalNand Logical operation: Nand !(s & d) (1)
LogicalOr Logical operation: Or (s | d) (1)
LogicalNor Logical operation: Nor !(s | d) (1)
LogicalXor Logical operation: Xor (s ^ d) (1)
LogicalEquiv Logical operation: Equivalence !(s ^ d) (1)
LogicalAndReverse Logical operation: Reverse And (s & !d) (1)
LogicalAndInverted Logical operation: Inverted And (!s & d) (1)
LogicalOrReverse Logical operation: Reverse Or (s | !d) (1)
LogicalOrInverted Logical operation: Inverted Or (!s | d) (1)
Multiply Advanced OpenGL blending operation: Multiply (2)
Screen Advanced OpenGL blending operation: Screen (2)
Overlay Advanced OpenGL blending operation: Overlay (2)
Darken Advanced OpenGL blending operation: Darken (2)
Lighten Advanced OpenGL blending operation: Lighten (2)
ColorDodge Advanced OpenGL blending operation: ColorDodge (2)
ColorBurn Advanced OpenGL blending operation: ColorBurn (2)
HardLight Advanced OpenGL blending operation: HardLight (2)
SoftLight Advanced OpenGL blending operation: SoftLight (2)
Difference Advanced OpenGL blending operation: Difference (2)
Exclusion Advanced OpenGL blending operation: Exclusion (2)
HSLHue Advanced OpenGL blending operation: HSLHue (2)
HSLSaturation Advanced OpenGL blending operation: HSLSaturation (2)
HSLColor Advanced OpenGL blending operation: HSLColor (2)
HSLLuminosity Advanced OpenGL blending operation: HSLLuminosity (2)

注:

  1. Logical operations require DX 11.1+ or Vulkan.
  2. Advanced OpenGL blending operations require GLES3.1 AEP+, GL_KHR_blend_equation_advanced, or GL_NV_blend_equation_advanced. They can only be used with standard RGBA blending; they are not compatible with separate RGB and alpha blending.

Shader "Examples/CommandExample"
{
    SubShader
    {
         // SubShader を定義する残りのコードをここに記述

        Pass
        {    
             // Enable subtractive blending for this Pass
             Blend SrcAlpha One
             BlendOp RevSub
            
              // Pass を定義する残りのコードをここに記述
        }
    }
}

このサンプルコードでは、SubShader ブロックでこのコマンドを使用するための構文を示しています。

Shader "Examples/CommandExample"
{
    SubShader
    {
         //この SubShader の減法ブレンディングを有効にします
         Blend SrcAlpha One
         BlendOp RevSub

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

        Pass
        {    
              // Pass を定義する残りのコードをここに記述
        }
    }
}
ShaderLab コマンド: Blend
ShaderLab コマンド: ColorMask