Search Unity

Avoid multiply alpha

Discussion in 'Shaders' started by Razouille, Jan 20, 2016.

  1. Razouille

    Razouille

    Joined:
    Jan 25, 2013
    Posts:
    44
    Hi there,

    In my game i manage shadows for my characters and weapons (with Sprites-Default shader), but when they are overlapping, the color is darker : shadow problem.png . I don't know if it is possible, but i would like to avoid alpha multiply on my sprites, in order to get only 1 "black" color for my shadows, that is to say get this : shadow expected.png .

    I'm quite noob about shaders, i tried to modify blending mode but nothing get me what i need =(

    If someone can help me that would be great =)
     
  2. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    This issue has shown up in hundreds of threads and its mainly because this is natural hardware behavior and is not obviously overcome. You can do it by e.g. rendering shadows to the alpha channel of the screen and then later using a different shader to cover the screen using a color that combines with the alpha channel. But there are other ways.
     
  3. Razouille

    Razouille

    Joined:
    Jan 25, 2013
    Posts:
    44
    Thank you for the answer, i'll look for this "alpha channel of the screen", never heard about it.

    Btw i found half of a solution there : https://mispy.me/unity-alpha-blending-overlap/
    But it doesn't work if i check "Flip X" or "Flip Y" on the sprite renderer (it works if i check both)