Specifies the blending operation used by the Blend command. For this command to have any effect, there must also be a Blend command in the same Pass block (if this command is in a Pass block) or SubShader block (if this command is in a SubShader block).
Not all blending operations are supported on all devices, and support depends on both the graphics API and the hardware. Different graphics APIs handle unsupported blending operations differently: GL skips unsupported operations, and Vulkan and Metal fall back to Add operations.
Feature name | Built-in Render PipelineA series of operations that take the contents of a Scene, and displays them on a screen. Unity lets you choose from pre-built render pipelines, or write your own. More info See in Glossary |
Universal Render Pipeline (URP) | High Definition Render Pipeline (HDRP) | Custom SRP |
---|---|---|---|---|
BlendOp | Yes | Yes | Yes | Yes |
This command makes a change to the render state. Use it in a Pass
block to set the render state for that Pass, or use it in a SubShader
block to set the render state for all Passes in that SubShader.
Signature | Example syntax | Function |
---|---|---|
BlendOp <operation> |
BlendOp Sub |
Sets the blending operation used by the Blend command. |
Parameter | Value | Function |
---|---|---|
operation | Add |
Add source and destination together. |
Sub |
Subtract destination from source. | |
RevSub |
Subtract source from destination. | |
Min |
Use the smaller of source and destination. | |
Max |
Use the larger of source and destination. | |
LogicalClear |
Logical operation: Clear (0) (See note 1) |
|
LogicalSet |
Logical operation: Set (1) (See note 1) |
|
LogicalCopy |
Logical operation: Copy (s) (See note 1) |
|
LogicalCopyInverted |
Logical operation: Copy inverted (!s) (See note 1) |
|
LogicalNoop |
Logical operation: Noop (d) (See note 1) |
|
LogicalInvert |
Logical operation: Invert (!d) (See note 1) |
|
LogicalAnd |
Logical operation: And (s & d) (See note 1) |
|
LogicalNand |
Logical operation: Nand !(s & d) (See note 1) |
|
LogicalOr |
Logical operation: Or (s | d) (See note 1) |
|
LogicalNor |
Logical operation: Nor !(s | d) (See note 1) |
|
LogicalXor |
Logical operation: Xor (s ^ d) (See note 1) |
|
LogicalEquiv |
Logical operation: Equivalence !(s ^ d) (See note 1) |
|
LogicalAndReverse |
Logical operation: Reverse And (s & !d) (See note 1) |
|
LogicalAndInverted |
Logical operation: Inverted And (!s & d) (See note 1) |
|
LogicalOrReverse |
Logical operation: Reverse Or (s | !d) (See note 1) |
|
LogicalOrInverted |
Logical operation: Inverted Or (!s | d) (See note 1) |
|
Multiply |
Advanced OpenGL blending operation: Multiply (See note 2) |
|
Screen |
Advanced OpenGL blending operation: Screen (See note 2) |
|
Overlay |
Advanced OpenGL blending operation: Overlay (See note 2) |
|
Darken |
Advanced OpenGL blending operation: Darken (See note 2) |
|
Lighten |
Advanced OpenGL blending operation: Lighten (See note 2) |
|
ColorDodge |
Advanced OpenGL blending operation: ColorDodge (See note 2) |
|
ColorBurn |
Advanced OpenGL blending operation: ColorBurn (See note 2) |
|
HardLight |
Advanced OpenGL blending operation: HardLight (See note 2) |
|
SoftLight |
Advanced OpenGL blending operation: SoftLight (See note 2) |
|
Difference |
Advanced OpenGL blending operation: Difference (See note 2) |
|
Exclusion |
Advanced OpenGL blending operation: Exclusion (See note 2) |
|
HSLHue |
Advanced OpenGL blending operation: HSLHue (See note 2) |
|
HSLSaturation |
Advanced OpenGL blending operation: HSLSaturation (See note 2) |
|
HSLColor |
Advanced OpenGL blending operation: HSLColor (See note 2) |
|
HSLLuminosity |
Advanced OpenGL blending operation: HSLLuminosity (See note 2) |
Notes:
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
{
// The rest of the code that defines the SubShader goes here.
Pass
{
// Enable subtractive blending for this Pass
Blend SrcAlpha One
BlendOp RevSub
// The rest of the code that defines the Pass goes here.
}
}
}
This example code demonstrates the syntax for using this command in a SubShader block.
Shader "Examples/CommandExample"
{
SubShader
{
// Enable subtractive blending for this SubShader
Blend SrcAlpha One
BlendOp RevSub
// The rest of the code that defines the SubShader goes here.
Pass
{
// The rest of the code that defines the Pass goes here.
}
}
}
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.