Search Unity

Custom shader with Fade not Transparent

Discussion in 'Shaders' started by Kingmoge, Oct 12, 2018.

  1. Kingmoge

    Kingmoge

    Joined:
    Jul 29, 2016
    Posts:
    9
    I have a custom surface shader and I want to reduce alpha to make something completely transparent. I have it pretty much set up, but the object still shows reflections. Using the standard shader, I could set it to Fade instead of Transparent and get the effect I want (completely gone, no reflections). How can I get this effect with a custom shader? I'm using RenderType transparent and Queue transparent, and have not found a "Fade" option for those.

    Thanks!
     
  2. echologin

    echologin

    Joined:
    Apr 11, 2010
    Posts:
    1,078
    you set the blend mode in shader to

    Blend SrcAlpha OneMinusSrcAlpha
     
  3. Kingmoge

    Kingmoge

    Joined:
    Jul 29, 2016
    Posts:
    9
    Thanks for the reply!

    I already have that as the blend mode. Unfortunately, that's what is giving me the "transparent" type rendering mode - you don't see the actual item, but you do still see the reflections on it. I'm looking for "fade" type rendering mode, where at alpha 0, it disappears entirely.

    In case I'm not making sense, see screen grab, both cubes using built-in standard shader with alpha 0. Left cube is set to Fade, right is set to Transparent. Right cube is what I'm getting in my custom shader (reflections still visible), left cube is what I want to get (completely gone).

    cubes.PNG .
     
  4. echologin

    echologin

    Joined:
    Apr 11, 2010
    Posts:
    1,078
    Multiply the RGB * alpha
     
  5. Kingmoge

    Kingmoge

    Joined:
    Jul 29, 2016
    Posts:
    9
    Thanks again (belatedly) -

    Here's what actually got the effect I was trying for...

    #pragma surface surf Standard fullforwardshadows alpha:fade

    I think at some point earlier I had tried alpha:fade and it blew up everything, but it may have been combined with some other tweak that was the actual problem.
     
  6. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    86
    Thanks Kingmoge, lifesaver.
     
  7. lvthn-inc

    lvthn-inc

    Joined:
    Sep 11, 2019
    Posts:
    1
    Thank you, just what I was looking for
     
  8. rcornwall

    rcornwall

    Joined:
    Oct 21, 2016
    Posts:
    7
    Kingmoge - this is the end of a 2 hour google dive. Thanks for posting!
     
  9. Xyth

    Xyth

    Joined:
    Aug 10, 2017
    Posts:
    3
    Thanks, that :Fade is just what I needed