BlendOp command in ShaderLab reference
Reference for the BlendOp command in ShaderLab.
Read time 3 minutesLast updated a month ago
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.
Render pipeline compatibility
Feature name | Universal Render Pipeline (URP) | High Definition Render Pipeline (HDRP) | Custom SRP | Built-in Render Pipeline |
|---|---|---|---|---|
| BlendOp | Yes | Yes | Yes | Yes |
Syntax
This command makes a change to the render state. Use it in a block to set the render state for that Pass, or use it in a block to set the render state for all Passes in that SubShader.
PassSubShaderSignature | Example syntax | Function |
|---|---|---|
| | Sets the blending operation used by the Blend command. |
Parameters
Parameter | Value | Function |
|---|---|---|
| operation | | Add source and destination together. |
| Subtract destination from source. | |
| Subtract source from destination. | |
| Use the smaller of source and destination. | |
| Use the larger of source and destination. | |
| Logical operation: | |
| Logical operation: | |
| Logical operation: | |
| Logical operation: | |
| Logical operation: | |
| Logical operation: | |
| Logical operation: | |
| Logical operation: | |
| Logical operation: `Or (s | |
| Logical operation: `Nor !(s | |
| Logical operation: | |
| Logical operation: | |
| Logical operation: | |
| Logical operation: | |
| Logical operation: `Reverse Or (s | |
| Logical operation: `Inverted Or (!s | |
| Advanced OpenGL blending operation: | |
| Advanced OpenGL blending operation: | |
| Advanced OpenGL blending operation: | |
| Advanced OpenGL blending operation: | |
| Advanced OpenGL blending operation: | |
| Advanced OpenGL blending operation: | |
| Advanced OpenGL blending operation: | |
| Advanced OpenGL blending operation: | |
| Advanced OpenGL blending operation: | |
| Advanced OpenGL blending operation: | |
| Advanced OpenGL blending operation: | |
| Advanced OpenGL blending operation: | |
| Advanced OpenGL blending operation: | |
| Advanced OpenGL blending operation: | |
| Advanced OpenGL blending operation: |
Notes:
- Logical operations require DX 11.1+ or Vulkan.
- Advanced OpenGL blending operations require ,
GLES3.1 AEP+, orGL_KHR_blend_equation_advanced. They can only be used with standard RGBA blending; they are not compatible with separate RGB and alpha blending.GL_NV_blend_equation_advanced
Examples
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. } }}