Search Unity

Question Shadergraph / LWRP equivalent of transparent depth shader (Ghost Shader).

Discussion in 'Shader Graph' started by AlfieBooth, Aug 15, 2019.

  1. AlfieBooth

    AlfieBooth

    Joined:
    Dec 2, 2013
    Posts:
    31
    Hi all,

    I am looking to try and replicate this shader :
    https://forum.unity.com/threads/transparent-depth-shader-good-for-ghosts.149511/
    for the LWRP - hopefully using shadergraph.

    ...hopefully using shadergraph, as I'm one of the many for whom shader writing is a baffling learning curve and shadergraph makes much more sense to me.

    Basically, all i need is a simple, unlit, single coloured shader that only renders itself once. i.e: Any overlapping geometry on that mesh is only drawn for the topmost pixels, so you don't get that increasing density of color and alpha.
    I hope that makes sense, sometimes the right words elude me.

    Any help is greatly appreciated, thank you in advance.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,336
    Yep, totally makes sense what you want.

    Also totally not possible with Shader Graph at this time.

    You can get something kind of close by using the Scene Color node. The short version is have a shader set to Transparent and Alpha with a fixed Alpha value of 1.0.

    Then instead of outputting the color and alpha of your shader through the color and alpha of the master node, use a Lerp or Add node to Lerp or add to the output of the Scene Color node and put that into the master node's color (or emissive if using HDRP). This will have the behaviour you're going for if you have a full resolution opaque texture enabled for your render pipeline asset, but it comes at the cost of no other transparent objects will show up behind your objects.
     
  3. AlfieBooth

    AlfieBooth

    Joined:
    Dec 2, 2013
    Posts:
    31
    Thank you so much for your prompt and thorough response.
    I was hoping actually that it would be yourself that helped me out, so im chuffed.

    I will try that out right now...
     
  4. AlfieBooth

    AlfieBooth

    Joined:
    Dec 2, 2013
    Posts:
    31
    Worked like a charm...
    NEVER would have figured that one out.
    Thank you very much