Search Unity

Help on blending alpha and color channels independently

Discussion in 'Shaders' started by fgielow, Mar 7, 2012.

  1. fgielow

    fgielow

    Joined:
    Jan 3, 2012
    Posts:
    122
    Hello!

    I read that I can specify different Source and Destination Factors for the colors and the alpha channel, as explained here: http://unity3d.com/support/documentation/Components/SL-Blend.html. I basically need to follow this:

    Code (csharp):
    1. Blend SrcFactor DstFactor, SrcFactorA DstFactorA
    , specifying them differently.

    But in my shader it does mot matter what I specify as SrcFactorA and DstFactorA, nothing ever changes at all. I may even set both alpha factors to be multiplied by zero and they still appear on screen!

    Here is my shader, I am basically trying to modify mobile/particles/additive:

    Code (csharp):
    1. Shader "ex2D/BlueHaloAdditive" {
    2. Properties {
    3.     _MainTex ("Particle Texture", 2D) = "white" {}
    4. }
    5.  
    6. Category {
    7.     Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
    8.     Blend SrcAlpha One, One oneMinusSrcAlpha
    9.     Cull Off
    10.     ZWrite Off
    11.    
    12.     BindChannels {
    13.         Bind "Color", color
    14.         Bind "Vertex", vertex
    15.         Bind "TexCoord", texcoord
    16.     }
    17.    
    18.     SubShader {
    19.         Pass {
    20.             SetTexture [_MainTex] {
    21.                 combine texture * primary
    22.             }
    23.         }
    24.     }
    25. }
    26. }
    The thing is, while I want to blend their colors, I also need to blend the alpha channel but in a different way.
    Whatever I put after the comma to specify alpha blending options does not influence anything at all.

    Am I doing something wrong? How should I proceed?


    Thanks in advance,
    Fernando.
     
  2. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    Yes, if it doesn't work. Because it should work.
     
  3. nullvar

    nullvar

    Joined:
    Apr 18, 2014
    Posts:
    1
    Same question, i'm trying to apply different operation to alpha channel but is not working, even multiplying alpha by zero.

    Code (csharp):
    1.  
    2. Blend OneMinusSrcColor Zero, Zero Zero
    3.  
     
  4. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    304