Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question URP Transparent material

Discussion in 'Universal Render Pipeline' started by AnahidE5, Oct 5, 2022.

  1. AnahidE5

    AnahidE5

    Joined:
    Jan 10, 2022
    Posts:
    40
    I have some issues using the URP Lit shader for transparent materials. Due some animations (where these parts either fade or appear by changing the alpha value), I need to have the materials for this brain as transparent. However, even when I set the render face to be the front and alpha channel at 255, the brain does not look right. I basically want it to look more or less similar to the opaque version at this point before the animation starts but it doesn't.
    Opaque.PNG
    transparent.PNG

    The other problem (can be seen in the video) is the "somewhat overlapping" parts keep jumping over each other as I move the view. I've selected the materials so you can see the properties on the inspector. The problem is similar to the brain. I need these materials to be transparent for my animations.


    In general, what is the best way to use transparency? I read forum post of mostly problems similar to mine but no solutions.
     
  2. DarkDungeonStudio

    DarkDungeonStudio

    Joined:
    Oct 31, 2013
    Posts:
    37
    Having the same problem.
    Been looking into this issue the whole day, and I can't find a solution to this.
    I know it's because transparent materials are rendering last and the ZWrite is set to OFF.

    So I know what is the cause of the issue.
    But I have no idea how to solve the issue.

    It could be resolved by making a shader that renders the Depth data first with ZWrite ON, and then the color with ZWrite OFF.

    But I have no idea of to make shaders like that.
     
  3. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    761
    Hi, I think the first pass (renders depth only) is not needed, the color with "ZWrite On" should solve this issue.

    If you can use shader graph (at least 2021.2), it will be very easy to do that by changing the Depth Write to "ForceEnabled".
    DepthWriteForceEnabled.jpg
     
    Marnelle and chendingbo404 like this.
  4. vincewa

    vincewa

    Joined:
    Jan 19, 2021
    Posts:
    9
    I know this is old but I've also been having the same issue. I'm not that fluent with shader graph to set one up for my materials but to help with a few of the issues described about.

    1. Turn off preserve specular. This will help with the texture looking washed out and dull in some cases.
    2. The flipping back and forth and renderings appearing over one another is due to rendering priority. At the bottom of the material under "Advanced Options" you will see sorting priority. Obviously the higher the priority it will stop allowing objects to flash over it.
    Hope this helps someone who has been experiencing this same issue and doesn't feel ready to dive into learning shader graphs.
     
  5. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    313
    One of my biggest issues with URP... anything todo with transparency and shadows from transparency is a dead area, nothing just works as you'd expect.. ie the common shaders it comes with where you want alpha transparency on the material... they haven't bothered fixing and improving these problems for years... in BIRP these default shaders just worked if you wanted transparency, and you'd get a smooth alpha shadow that wasn't complete crap... sad really.

    URP is far from a replacement of BIRP, and HDRP which should be better is just as rubbish.
     
  6. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    313
  7. vincewa

    vincewa

    Joined:
    Jan 19, 2021
    Posts:
    9
    So here is the official answer. Full credit to this guy on you tube Daniel Liett.


    Essentially you have to turn on alpha clipping, Set it to the value you want the material to render invisible at and that's it. Once the materials alpha reaches that value it will be fully transparent. Don't forget to also set render priority on the material as I mentioned above if you are getting strange blending of transparent materials.

    Good luck all hope this helps.