- Home /
In Shader, "Blend Off" means there is no alpha blending operation while rendering?
In shader, does "Blend Off" means there is no alpha blending operation while rendering? I know alpha blending is very slow because alpha blend object have to do some other things like alpha sorting, color operation by each pixel, and so on. I wonder How can unity decide if this object need to be render with alpha blending operation. In unity standard shader, there is strange code:
...
[HideInInspector] _SrcBlend ("__src", Float) = 1.0
[HideInInspector] _DstBlend ("__dst", Float) = 0.0
...
Blend [_SrcBlend] [_DstBlend]
...
According that code, all object that used for standard shader is rendered with alpha blending operation because there is no Blend Off tag. What I want to ask is how can I notify to unity that I want to render object without alpha blending operation? If I tag "Blend One Zero", does unity render without alpha blending operation automatically?
Answer by Owen-Reynolds · Aug 21, 2015 at 03:11 PM
Take a look at the info page for the Unity Standard Shader.
I think this line in the 2nd paragraph answers your Q: "[...] its features are enabled or disabled by simply using or not using the various texture slots and parameters in the material editor." But it seems like you may as well read the entire thing.
The older version of Unity shaders (the ones mentions in the Standard Shader man page) has places to explicitly turn blending on/off and hand-set whether it was sorted. I assume there is still a way to get to the "old" custom frag/vert shaders, where you still do that.
Answer by narcissuspark · Aug 24, 2015 at 02:26 PM
Thank you for a reply, and I take a look at the Unity Standard Shader page but still don't understand. In "Standard.shader" and "StandardShaderGUI.cs", there are codes like below.
"StandardShaderGUI.cs"
public static void SetupMaterialWithBlendMode(Material material, BlendMode blendMode)
{
switch (blendMode)
{
case BlendMode.Opaque:
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
...
break;
...
So if I select BlendMode.Opaque, I think shader code will be complie below.
"Standard.shader"
Blend One Zero
In my opinion, this will be looked opaque but alpha blending calculation(pixel adding: SrcFactor*1 + DstFactor*0) wil be calculated when it's rendering because there is no "Blend Off" option. So, since Standard Shader has no "Blend Off" option in its code, does it calculate alpha blend calculation per pixel whend it's rendering? How can I know this will be rendered with or without alpha blend calculation?
Your answer
Follow this Question
Related Questions
Blended Edges on Tree Creator Leaves 0 Answers
Transparent shader with alpha 1. Still a performance hit? 2 Answers
Fixed Shader with multiple AlphaBlended Layers ? 0 Answers
Textured object appears transparent in a textured sphere with front culling 1 Answer
How to force the compilation of a shader in Unity? 5 Answers