Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question UI Canvas behind 3D plane with material with transparency input enabled

Discussion in 'High Definition Render Pipeline' started by JupiterOne, Feb 10, 2023.

  1. JupiterOne

    JupiterOne

    Joined:
    Jan 7, 2019
    Posts:
    5
    Hi all, I'm using hdrp and in my scene i have a box (or a plane) placed in fron of a UI Canvas (screen space camera) with some text an raw images inside.
    When i apply to the box a material with transparency input enabled, the canvas (and its content) disapear behind the 3D model.
    I dont't understand if i'm doing something wrong or if i'm trying to achieve an impossible setup.
    Any help appreciated
    Thnx

    screen.png
     
  2. meicexl

    meicexl

    Joined:
    Apr 9, 2020
    Posts:
    11
    Transparent UI elements won't render behind transparent materials if they have refraction on. You can make elements always render on top of transparent materials by adjusting their sorting order, but you can't have them render behind and take refraction into account. You can turn refraction off and the UI will render properly, but turning off refraction may not be desirable.

    What you may want to do is use the HDRP TMP shaders, which allow you to set your font material to be Opaque. This will allow text to render behind refracted transparent materials properly. An obvious drawback is that they're, well, opaque. So, you won't be able to change their alpha.
    upload_2023-2-10_13-26-34.png

    This may not be applicable to your case, but in our project we have computers that the player can interact with. We needed various UI animations that would deal with fading out UI elements, so we couldn't use opaques. To go around this problem, we have a plane with a texture that sort of resembles what is displayed on the computers positioned slightly behind the world space canvas. When the player looks at the display through a transparent material, they still see something that resembles the canvas. When they go around the transparent material, the canvas appears, hiding the dummy plane texture behind it. It works quite well as long as your glass is blurry so that the dummy texture can't be seen very well. Of course, this won't really work well if your UI is constantly updating and moving around, but it did the trick in our case.

    gif.gif
     
  3. JupiterOne

    JupiterOne

    Joined:
    Jan 7, 2019
    Posts:
    5
    Thnx, i'll look into it..

    at the moment i've "solved" the problem with a render texture with a custom material rendering a second camera with all the UI content.
    This way it works fine.
    Thnx