Search Unity

Standard shader albedo alpha fade & transparent becomes unlit!

Discussion in 'Shaders' started by ekergraphics, Jun 17, 2017.

  1. ekergraphics

    ekergraphics

    Joined:
    Feb 22, 2017
    Posts:
    257
    Hello!

    I just observed behavior where I had a .PSD file with a transparent background and white silhouette applied as the albedo texture, and setting to either fade or transparent rendering modes made the entire texture unlit.

    Cutout works fine, but that then becomes 1-bit alpha instead of 8-bit, which doesn't even get MSAA applied to it so it looks very bad.

    Also, the transparent render mode has another bug in that the background isn't 100% transparent, even though when viewed in Photoshop it clearly is.

    This is not normal, I hope?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Transparent is for transparent mediums, like glass or water, which even when "fully transparent" still reflect a small amount of light so aren't actually fully transparent. Fade is what you want if you want something to be completely transparent, however I've seen some examples that Fade is actually slightly bugged and isn't fully transparent either.

    Cutout really is the only way to guarantee it is 100% transparent, but as you said it makes for an ugly edge. The better technique, especially if you're using MSAA, is to use AlphaToMask, but that isn't an option built into Unity's Standard shader. You can setup a Surface Shader to use it, but be warned it can break shadow casting & receiving for that object due to some unfortunate defaults in the generated shadowcaster passes.

    Search the forum for AlphaToMask or Alpha to Coverage and I think I posted some example code someplace.