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

World-Space UI with HDRP

Discussion in 'High Definition Render Pipeline' started by whogas, Feb 25, 2020.

  1. whogas

    whogas

    Joined:
    Oct 18, 2013
    Posts:
    46
  2. sergiusz308

    sergiusz308

    Joined:
    Aug 23, 2016
    Posts:
    234
    @whogas thanks man, your post helped me a lot!
     
    whogas likes this.
  3. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    One small point - you might want to rephrase references to "UI elements" in your blog post to make it clear you're talking about the existing UI system and not the new "UIElements" system.
     
    whogas likes this.
  4. whogas

    whogas

    Joined:
    Oct 18, 2013
    Posts:
    46
    That is a good point! I will try to update or make a general warning somewhere.
     
  5. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
    Hey, thanks for this!

    But we dont have those extra settings in shader graph that you do, just updated to the latest HDRP and I see nothing like "After postprocessing" and all those other settings

    Shader graph 7.2.1
    HDRP 7.2.1
     
    Last edited: Mar 6, 2020
  6. whogas

    whogas

    Joined:
    Oct 18, 2013
    Posts:
    46
    That seems odd.

    1. What options are available when you open the settings icon (little gear) on the Unlit Master node?
    2. When you created the shader, did you use Create -> Shader -> HDRP -> Unlit Graph or Create -> Shader -> Unlit Graph (skipping the HDRP subsection)?

    I'll try to think of other issues you might be having, but let me know about those two.
     
  7. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
    Ah, I did skip the HDRP subsection actually - thanks!

    So if you don't do that, are those URP shaders then that also work in HDRP?
     
  8. whogas

    whogas

    Joined:
    Oct 18, 2013
    Posts:
    46
    I have been struggling to keep up with URP developments lately. It certainly seems like you are able to use some URP shaders in HDRP projects, but I don't know all of the pros and cons for doing this yet. Sorry I can't help you more on that front.
     
  9. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
    No worries, big thanks already! The text works great.

    Do you maybe know if its possible to make images/raw images work as well?

    Edit: if you add drop shadow you get some Z fighting


    I'll also try some things
     
  10. whogas

    whogas

    Joined:
    Oct 18, 2013
    Posts:
    46
    The shader graph you can use for Image components is the first part of the blog post. It's a little simpler than the text shader and pulls the sprite info that will be referenced in the Image component. Hopefully that will get rid of your z-fighting issue when you apply it to your background image.

    If you are using a Raw Image, I suspect the same set up should work with the 2D texture input still being called "_MainTex". I just labeled it as "Sprite Texture" since that was specifically what I was using on the Image component, but that label shouldn't really have an impact on functionality.
     
  11. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
    Hey, the icons work

    The Depth issue is fixed when I set the depth test in the surface shader options to "Less" or "Always"
     
    whogas likes this.
  12. whogas

    whogas

    Joined:
    Oct 18, 2013
    Posts:
    46
    Oh, yes. Forgot to mention that setting. Glad it's working!
     
  13. razo84

    razo84

    Joined:
    Jan 15, 2017
    Posts:
    21
    @whogas Just wanna say thank you for this ;)
     
    whogas likes this.
  14. spso

    spso

    Joined:
    Oct 11, 2017
    Posts:
    17
    Hi @ All
    thanks, very helpful.

    I also found that you can use the TextMeshPro Texts (SDF textures) with this little hack in Shader Graph.
    The text is nice and crisp again.

    ShaderGraph_SDF.JPG

    With thanks to https://github.com/gilescoope/shader-graph-nodes for the hint.
     
  15. TonkRogerio

    TonkRogerio

    Joined:
    Apr 12, 2013
    Posts:
    15
    What can URP users do for now?
     
    laurentlavigne likes this.
  16. Ultroman

    Ultroman

    Joined:
    Mar 10, 2014
    Posts:
    110
    Hey. I copied your shader graph there and it seems to work :D
    Except the text disappears really quickly the smaller it gets, whether by increasing distance to the camera or scaling it down or changing the font size. It just...renders it wrongly. See my thread here for screenshots, the shader graph, etc.

    Any help would be greatly appreciated!
     
  17. foonix

    foonix

    Joined:
    Dec 15, 2019
    Posts:
    20
    Thank you for this, it solves a lot of problems that migrating to HDRP caused. In addition to the problems above, it also fixes Canvas objects not rendering in right eye in XR single pass mode.

    However I can't figure out what to do about UI masking. The stencil buffer seems to be used by masking does not seem to be accessible from ShaderGraph, and it uses different mask variables than `Canvas` supplies to `UI/Default`. The result is that things like scrollable UI windows tend to bleed off the canvas.

    https://docs.unity3d.com/2018.4/Documentation/Manual/script-Mask.html
     
  18. whogas

    whogas

    Joined:
    Oct 18, 2013
    Posts:
    46

    This is an interesting question and I don't have a great answer for you at the moment. When I was using HDRP and world-space UI, I only had need of one scroller, and it was for a purely text item. For my case, I just placed the text into a texture and moved the Y-offset value with a scroller. This is kind of a hack, but I figured I'd throw it in here in case it is enough for someone else's situation.
     
  19. arturmandas

    arturmandas

    Joined:
    Sep 29, 2012
    Posts:
    240
    Thank you, most helpful.
     
    whogas likes this.
  20. dpersson16

    dpersson16

    Joined:
    Aug 22, 2019
    Posts:
    1
    I tried this, but whenever i set the rendering pass to "after post-processing", the entire material disappears and becomes invisible