Search Unity

How is UI supposed to work in HDRP with one camera?

Discussion in 'High Definition Render Pipeline' started by Flow-Fire-Games, Dec 16, 2019.

  1. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
    Hey
    We need some guidance with how to handle the ingame HUD with just one camera as demanded by HDRP.

    HDRP demands only one camera as of now, but this means post processing and everything also affects our UI
    And if you want to enable TAA, the UI gets extremely blurry when moving the camera, which is making it unusable

    Tonemapping makes the UI very poorly readable.

    We tried following that one FPS demo tutorial but that is for LWRP with the render passes and the options do not exist in HDRP.

    What is the intended workflow?
     
    Last edited: Jan 2, 2020
    Rich_A, GileanVoid and Gametyme like this.
  2. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    You can exclude layers from your volume.
    Are you talking about a screen overlay UI or a 3D one?
     
  3. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
    We have a classical overlay Hud but its also using some 3D elements / Planes with materials

    Are you sure? When I tried layers that did not change anything in the volume. Also post processing should technically not be able to seperate between layers no? Changing layers does nothing to the volume, both in local and global setting, just tested
     
  4. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    With a second camera you could exclude post processing by turing them off in the custom frame settings of the HD camera.
    But with only one camera I think you only could make a difference with Light layer.

    So if you have a dark tonemapping, you could add a light source that affects only your 3D UI through light layers in order to make them brighter.
     
    Last edited: Dec 16, 2019
    Sab_Rango likes this.
  5. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
    There must be one official way to handle UI when support for more than 1 camera was removed, traditionally a separate camera is used and every game has UI, surely the HDRP Team has one particular way of doing this in mind
     
    polyphonic13 likes this.
  6. Leniaal

    Leniaal

    Joined:
    Nov 7, 2012
    Posts:
    119
    I'm also having difficulties with using one camera
    • UI Camera
    • Dual render scope
    • First person hands / weapons clipping through objects
    • Top down radar view
    It would be nice to know how to deal with these scenarios, or what plans the team has in mind for the future.
     
    giraffe1 and FerdowsurAsif like this.
  7. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
  8. Elliott-Mitchell

    Elliott-Mitchell

    Joined:
    Oct 8, 2015
    Posts:
    88
    Similar issue - I NEED to exclude assets from post processing in HDRP - IT'S ESSENTIAL!
     
  9. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
    Yes exactly
     
  10. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Hi. We have several 3D planes with Video Players and other streamed texture content in our scenario.
    How i can exclude them from TAA.
    TAA is smearing this content in all settings but it is needed for all other 3D geometries.

    In BuiltIn RP we render these content with a second camera without TAA.
     
    konsic likes this.
  11. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    Repoert this as bug. Only way it could be addressed with final 7.20.
     
  12. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Mhmmm? It s not realIy a bug.
    You could solve it with camera stackin in BuiltIn RP.
    In HDRP it did not find a way to create an comparable "workaround".

    Hope someone has some idea.
     
  13. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    HDRP is terrible with more than one camera right now. All sorts of performance issues and bugs when using more than one camera in a scene. I'm guessing you'll have to wait for it be fixed internally by Unity.
     
  14. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    I played it a bit but I don't know how to do it.

    Is it possible to create a custom pass and exclude UI from PP ?
     
  15. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
    Maybe scriptable but that surely requires an experienced graphics programmer which our team does not have
    In LWRP there is a tutorial for it but comparable things do not exist in HDRP it seems

    I assume there is just no solution in place yet, but this definitely should have a high priority on the radar, there needs to be a equivalent solution to the classic 2 camera workflow basically all studios do in one way or another, it cant just be taken away and not given anything in return.
    Every game needs UI and many games use first person as well.
     
  16. Onat-H

    Onat-H

    Joined:
    Mar 11, 2015
    Posts:
    195
    You can still render a camera to a render texture. Espicially regarding UI, this should solve your problem. In the camera settings you can also define which the volume layer is the camera uses.
     
  17. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    Currently, for me at least, using a render texture in HDRP causes massive amounts of garbage collection for some reason (by default). I've tried adjusting several settings on the render texture (size, depth use, aliasing, etc...) but the performance is still horrendous.

    In my opinion this is simply not a viable, real option. This is another thing I hope Unity fixes in 2019.3.
     
  18. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    Did you try the new incremental garbage collector? There is a boolean for it in the build: "Player Settings" under "Other Settings".
     
  19. foonix

    foonix

    Joined:
    Dec 15, 2019
    Posts:
    20
    Doing some experimenting on how to do this - what it seems to boil down to is the intended workflow seems to be to use the Render Pass setting on the material. For canvas UI this means creating a Canvas UI material + Shader with that renders in `After Post-process` with no z-test.

    Here is a minimal shader graph example based on HDRP/Unlit that will render a canvas with alpha. Note it is important that the texture input is referenced as `_MainTex`. The render pass must be set on the material.

    upload_2020-1-17_9-46-24.png

    For this screen shot I've jacked up the bloom to prove that the canvas is rendered after post-porcess and placed the canvas half way into the floor to prove that it's rendered on top of geometry. The canvas its self is in world space mode.

    I tried this with the new XR packages + Windows MR headset and it appears to be working. I have not tested TAA.

    For more general information about creating a Canvas shader, I found this thread helpful: https://forum.unity.com/threads/shader-graph-ui-image-shader.628111/

    However I still have a problem that TextMesh Pro shaders (or third party shaders) don't seem to be possible be set up this way. The ultimate solution may be to move the entire UI to a custom render pass. But that's a little beyond my skill level..
     
    mbussidk likes this.
  20. lilacsky824

    lilacsky824

    Joined:
    May 19, 2018
    Posts:
    171
    After trying use Unlit shader to render UI with Mask without success.
    I found I can use Custom Pass to render UI with Mask without Post Processing.

    1.Enable Custom Pass
    2.Create a Custom Pass volume and add a DrawRenderersCustomPass.
    3.Set Injection Point to After Post Process.
    4.Set Queue to Transparent
    5.Set Layer Mask to which your UI is.
    6.Set Sorting to Common Transparent.

    There are bugs if you build without Development Build.
    Screen will turn black.
    https://github.com/Unity-Technologies/ScriptableRenderPipeline/pull/5429
     

    Attached Files:

    • ui.png
      ui.png
      File size:
      622.4 KB
      Views:
      1,236
    Last edited: Jan 21, 2020
    Schululu, Ruchir, WimB and 4 others like this.
  21. xDavidLeon

    xDavidLeon

    Joined:
    Jun 9, 2014
    Posts:
    123
    The HDRP Custom Passes github ( https://github.com/alelievr/HDRP-Custom-Passes ) uses the same workflow to render its "blur" effect after all post process.

    I'm still trying to blur a single "transparent" UI rectangle to use as background for modern UI, but had no luck with it.

    This is the effect I'm looking for:



    Did any of you manage to recreate blurred UIs?
     
    DavidBorland likes this.
  22. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
    I wish could have my UI not blurred,
    (TAA'd and Tonemapped) ; P

    Lilacsky did you have any success?
     
  23. lilacsky824

    lilacsky824

    Joined:
    May 19, 2018
    Posts:
    171
    If you want PP(especially TAA) on your UI then you can use Unlit shader in shader graph.
    Because built-in UI shader seems didn`t generate motion vectors which cause blur when moving(when use TAA).
    However you can`t use Mask anymore since shader graph don`t handle stencil buffer properly.

    If you don`t want PP affect UI then you can use the solution that I post above(Use Custom Pass).
    TAA and Tonemapping won`t affect UI anymore.:)
     
    Last edited: Jan 25, 2020
  24. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi,

    sorry haven't read all the thread but I guess nobody mention that in HDRP there is a RenderPass: "After Postprocess" dedicated for this usage.

    See: https://docs.unity3d.com/Packages/c....high-definition@7.1/manual/Surface-Type.html

    On an unlit Material, select RenderPass => AfterPostprocess and the object with this material will be draw after postprocess. Perfect for UI. Note that if you have TAA enabled, you shouldn't enable depth test otherwise this will jitter with AfterPostprocess mode.

    Hope that help.
     
    MrBuBBLs and keeponshading like this.
  25. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
    Hey, this seems to work with our 3D UI with materials and meshes,
    but all the unity GUI (text, icons, sprites) all turn pink material now - what are we doing wrong there?



    Here my settings:



    Also I need shader graph on our UI and the UI needs to be lit, basically the same case as a first person weapon. Can this be done with shader graph as well? A unlit shader is very limiting.

    A - Also this does then mean I can not otherwise post process my UI`?

    B - If custom passes are always unlit, then first person weapons, 3d lit UI etc, are all impossible?


    Custom passes sound very useful but this dosnt seem like a acceptable replacement for dual camera at all so far.
    I just need 2 cameras and 2 different settings of AA / post processing / camera effects.
     
    Last edited: Jan 30, 2020
    Feuerputz likes this.
  26. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi,

    >UI needs to be lit
    In HDRP anything after postprocess can't have any lighting, lighting information aren't available.

    >Also this does then mean I can not otherwise post process my UI`?
    You can do a custom pass to blur your UI.
    so draw your UI frist with after postprocess then add another custom pass to blur. you can use alpha as a mask

    >I just need 2 cameras and 2 different settings of AA
    This is currently a very costly setup.
    "Legacy" Camera stacking support have been drop in SRP as it was causing too much issues (a large number of combination of feature aren't working like MSAA, dynamic resolution etc...). URP have made the choice of redesign a whole new feature with various constraint to allow it (IIRC there is no postprocess on each camera, only at the end) which will be available in 7.2.0.

    HDRP will come with a solution later (but costly: as rendering a second camera in unity is costly on CPU).

    There is still one way to do this. It is to do your own camera stacking. HDRP 7.2.0 have all the element allowing to do this (control on rendertarget clear etc...) and this can be done as an external plugin. This is what we are working on, but our prototype is not ready to be deliver.
     
    pointcache and keeponshading like this.
  27. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
    Hmm, this is very limiting

    We will try with a rendertarget right now.
     
    Last edited: Jan 31, 2020
  28. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
    Ok different question, I think I can go around the issue mostly by just putting the text and icons into a different pass.

    How can I fix the issue with the Unity GUI elements turning pink with the custom render pass?
    (My settings are posted above)

     
  29. lilacsky824

    lilacsky824

    Joined:
    May 19, 2018
    Posts:
    171
    Do you use built-in UI shader?
     
  30. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
    Yes, just classic default UI Sprites, Raw Images and Unity Text
     
  31. RealArt1994

    RealArt1994

    Joined:
    Jul 7, 2019
    Posts:
    5
    I think Unity team need work faster for solve HDRP problem if you guys have this problem like me we can make topic on unity HDRP and report this as bug

    Problem 1: Post processing Effect in simple UI can solve with Custom HD UI in shader graph but i don't know how make shader for work with text mesh pro and text that is problem

    Problem 2: in Canvas Camera i have big problem All UI Element flowing with camera and player and when camera rotate and ui going back of some object UI disappear (UI pass not render after All render layer)

    Problem 3: in out game we have Map, 3D HP system and Customization Character all of this need multi camera setup so i can't Implement all of this with HDRP now(i done Map, 3D HP system with custom shader with shader graph and Render texture but its not look good and lack in performance)

    and if anyone have solution good to know how solve it
     
  32. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
    Any solution for the pink shaders when trying to render UI elements with the extra pass?
     
  33. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
  34. lilacsky824

    lilacsky824

    Joined:
    May 19, 2018
    Posts:
    171
    I found there is something missing in your screenshot,there should have shader pass option in overrides.
    Maybe you can try assigning material with UI shader?
    option.jpg
     
  35. jjejj87

    jjejj87

    Joined:
    Feb 2, 2013
    Posts:
    1,117
    Why can't there be a bool check on the canvas to enable/disable PP...
    why are we still spending time on stuff like this for months...
     
    lacas8282, MaxGeorg, naby7u and 2 others like this.
  36. Kagyu

    Kagyu

    Joined:
    Mar 5, 2016
    Posts:
    96
    This allowed me to have masked UI without affected by PP. There is one more problem remaining for me though.
    How do I make Unity to draw to my right eye on single pass instanced set up?

    Unity 2019.4.1f HDRP7.3.1
     
  37. foonix

    foonix

    Joined:
    Dec 15, 2019
    Posts:
    20
    I've been unable to get this to work without using an HDRP/Lit or HDRP/Unlit material or ShaderGraph based shader.

    What I wound up doing is reading the source code for `UI/Default`, making a ShaderGraph based work-alike, dropping it on a material, and applying that material to any canvas image or text object. I can post it if there is interest, but I haven't been able to line up the stencil semantics, so it doesn't work with masking. Also I've not been able to solve TextMesh Pro text in right eye with this technique (the shader is pretty complicated).

    However, from a design standpoint, I would recommend to minimize use of `Canvas` as much as possible in HDRP VR. The performance is terrible because it does not participate in SRP batching. Consider "real" 3d objects as much as possible instead, even if it's just a quad.
     
    Kagyu likes this.
  38. Kagyu

    Kagyu

    Joined:
    Mar 5, 2016
    Posts:
    96
    With this method, UI Mask is now working without affected by PP but I still have the last issue with the HDRP setup for my VR project.

    UI is not rendered on the right eye.

    I can make unity draw on both eyes by the method here(https://forum.unity.com/threads/uni...left-eye-with-single-pass-hdrp-oculus.912626/) but with that method, as far as I tested, UI mask stops working again...

    What could be the solution? How I can make single pass instanced and UI mask without affected by PP at the same time?

    @foonix Yeah, thank you for you adivice. My VR project is a kind of 3d model viewer and I need file managing system in it. I have a tablet in the VR environment and I would like to display that file manager on that. In this kind of use case, I think general ui system still be very suitable if it works properly...
     
    Last edited: Jul 30, 2020
  39. Onat-H

    Onat-H

    Joined:
    Mar 11, 2015
    Posts:
    195
    What’s the best way currently to render UI to a render texture in HDRP (for use as computer screens for example)?
    Simply adding a second camera and setting the render target to render texture kills the performance... (most likely due to all the passes of the hdrp camera)
    Using Fullscreen passthrough helps with performance, but doesn’t render the UI at all...:D
     
  40. Kagyu

    Kagyu

    Joined:
    Mar 5, 2016
    Posts:
    96
    I have played around with the second camera method this morning. It works kinda ok. The performance was a issue of course but the biggest disappointment for me was the lack of transparency of UI.

    If the "solution" @SebLagarde mentioned as "HDRP will come with a solution later (but costly: as rendering a second camera in unity is costly on CPU)." above in this thread solve the all issues we discuss here, the second camera method maybe the best option for us just for now because it will not be to hard to adapt to the future solution when it comes out.

    The point is when it will be, though. It has been 6 months for now since he posted it.
     
  41. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    802
    After reading through this thread and experimenting a bit more I got UI to render in AfterPostprocess using a "Custom Pass Volume" with carefully selecting the right settings:
    (this is on HDRP 7.5)
    The Canvas needs to use "Screen Space - Camera" for this to work, regular Overlay doesn't.

    upload_2020-9-14_12-32-50.png
     
    cp- and EmilGame0523 like this.
  42. itsnottme

    itsnottme

    Joined:
    Mar 8, 2017
    Posts:
    129
    This does improve the UI for me, but the UI still looks bad with anti-aliasing enabled. Any ideas?
     
  43. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    What do you mean? the UI shouldn't affected by antialiasing method once it is render after postprocessing, could you provide more information and maybe a screenshots? thanks
     
  44. itsnottme

    itsnottme

    Joined:
    Mar 8, 2017
    Posts:
    129
    Thank you for your response.
    Here it is before adding the custom pass
    Without Custom Pass.png
    Here it is after
    With AA.png
    This is how it looks without anti-aliasing
    Without AA.png
    Here are my custom pass settings
    1.PNG
    I am taking these screenshots while moving the camera and canvas.
    Using TAA.
     
    Last edited: Sep 24, 2020
    Glurth likes this.
  45. valarnur

    valarnur

    Joined:
    Apr 7, 2019
    Posts:
    440
    TXXAA doesn't work well with particles (vfx graph) and some postprocessing effects like bloom. With TXAA is visible downgrade on particles.
    Tested on 7.5.1 and 8.2.
    As the matter of fact, does TXAA disables bloom ?

    8.2 crashes a lot without bug report prompt (https://forum.unity.com/threads/crash-hdrp-8-2.971007/). Could you update to new 8.3+?
     
    Last edited: Sep 24, 2020
  46. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,269
    Is it possible to set that render pass in a basic shader or only via the material like that?
     
  47. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
  48. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    I leave this here.
    My problem got finally solved here

    https://github.com/alelievr/HDRP-Custom-Passes

    Video Textures and other streamed in moving content without TAA smearing when camera or content moves.

    There a also other UI examples.

    1.JPG
     
    PutridEx likes this.
  49. bruceweir1

    bruceweir1

    Joined:
    Nov 29, 2017
    Posts:
    15

    In 2020.3.1f1 there is an additional step required after the above is complete. On the Camera, select General -> Custom Frame Settings -> Rendering -> After Post-Process.
    Then it works.
     
  50. meadjix

    meadjix

    Joined:
    Dec 31, 2014
    Posts:
    11
    Korindian likes this.