Search Unity

Blending alpha values

Discussion in 'Shaders' started by DannyHerbert, Sep 3, 2015.

  1. DannyHerbert

    DannyHerbert

    Joined:
    Aug 22, 2014
    Posts:
    2
    Is there a way to get the alpha values of two different sprites to not add up? For an example here is a photo of my problem. when the two shadows (they are separate sprites) pass over each other I'm trying to get the alpha value to be the same as the individual sprites. Pretty sure this should be possible with shaders, no? I'm relatively new to writing shaders but have been searching for a while now with no luck!
    two.png
     
  2. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    472
    It looks like you want to blend your shadow sprites with everything except other shadows. If that is the case, you could render them all together as opaque to a RenderTexture, and then blend the RenderTexture with the screen with an ImageEffect. It looks like your game is pretty low resolution, so the rendertexture resolution shouldn't have to be huge.
     
  3. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    DannyHerbert likes this.
  4. DannyHerbert

    DannyHerbert

    Joined:
    Aug 22, 2014
    Posts:
    2
    Stencil buffer worked perfectly!! I ran into a problem with them clipping/culling strangely but managed to get it fixed after reading this! Thank you both for the help!