Search Unity

URP Lit Shader transparency issue

Discussion in 'Universal Render Pipeline' started by Lazy_Evaluation, Mar 29, 2021.

  1. Lazy_Evaluation

    Lazy_Evaluation

    Joined:
    Nov 16, 2019
    Posts:
    16
    Hello! I'm trying to turn an object semi transparent with URP shaders. I spent the past day looking for a solution and I found hundreds of people with my problem but none of those solutions worked for me :-(
    I've got a tree with URP/Lit shader. I need to turn it semi-transparent. The alpha value in the color setting doesn't work if the surface is opaque, but if I set the surface to transparent transparency works but I get two drawbacks:
    1) The shadows cease to exist, even with "Shadows ON" on the mesh rendered
    2) The objects are rendered in the wrong order (this is the worst and seemingly common problem!)

    Opaque:

    Transparent:


    As you can see the leaves are behind the tree's trunk, and the leaves are rendered in the wrong order. I found a workaround for the shadows: I followed a tutorial online and created my Lit shader graph, added the texture, and set the shader to transparent, and shadows works fine with my fresh lit shader. I can also set transparency there. But the objects gets still rendered in the different order! I also tried to set the priority to high (value "50" in the urp Lit shader, value 5000 in my shader), but nothing changed...
    What can I do? I'm currently using URP 10.3.2, and Unity 2020.3.0f1.
     

    Attached Files:

    Last edited: Mar 29, 2021
  2. bluebrain

    bluebrain

    Joined:
    Jun 18, 2014
    Posts:
    39
    Any solution? I'm struggling with this issue as well.
     
  3. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,874
    Technically it's not possible and it is not used in any game or engines
    I think all leave shaders are opaque with alpha cutout effect
    Fade mode(transparent in URP) is not suitable for leave shaders. It's for particle effects
    Untitled.jpg
     
  4. bluebrain

    bluebrain

    Joined:
    Jun 18, 2014
    Posts:
    39
    OP, I figured out the solution. The objects with transparency (leaves) must be a different object and material than the opaque object (trunk).
     
  5. OmarVector

    OmarVector

    Joined:
    Apr 18, 2018
    Posts:
    130
    Actually this not a fix to the problem, its just a fix to your model, and the problem still exist

    I do not get it, why Unity havent fixed this issue so far, when there is a model that consist of different objects combined, when apply a transparence map, it start act like a flipped normal model and render what is behind, like not Z test
     
  6. sickb0y247

    sickb0y247

    Joined:
    May 29, 2014
    Posts:
    54
    This is such a pain. I know this is an old post but if someone is still looking for help, this isn't a fix for all cases but so far it's been a decent work around for me.
    In the material under advanced settings there is a priority slider where you can force the draw of that material to supersede other materials, basically putting them on different "layers" of importance. So if your ground materials are drawing over something in front of them, just set those particular materials to a lesser priority.
     
  7. CassClay

    CassClay

    Joined:
    Mar 21, 2020
    Posts:
    70
    Personally I had a problem with a lava shader I made with Shader Graph URP. As Unlit it was showing alright, but couldn't apply Normal Map to the rocky surface around the lava. So I just made 2 planes, one for the rocks and one for the lava and made it Lit. That was because the semi-transparent parts on the texture didn't show alright and had red artifacts after lava passed trough them. I believe any object should have more materials applied on it to show transparency clip properly.