Skip to content

Commit

Permalink
Hd/ui best practice (Unity-Technologies#2489)
Browse files Browse the repository at this point in the history
* [HDRP] UI best practice guide

* Merge branch 'master' into hd/ui-best-practice

* Update TableOfContents.md

* Reviewed best practice document

* Added suggestion from Fabien

Co-authored-by: Sebastien Lagarde <sebastien@unity3d.com>
Co-authored-by: Lewis Jordan <lewis.jordan@hotmail.co.uk>
  • Loading branch information
3 people authored Nov 2, 2020
1 parent c854895 commit 98ed47c
Showing 1 changed file with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
# Best Practices on UI with High Definition Render Pipeline
# Working with UI in the High Definition Render Pipeline

Almost any project makes use of UI: for your in-game menu, to indicate a point of interest in your game, or simply display valuable information to your users. In this guide, we will guide you on how to use [Unity UI](https://docs.unity3d.com/Packages/com.unity.ugui@latest) with your HDRP project.
Almost every Project uses some form of user interface (UI). This could be: in a menu system, to indicate a point of interest in your application, or to display valuable information to users. This guide explains how to use [Unity UI](https://docs.unity3d.com/Packages/com.unity.ugui@latest) in your High Definition Render Pipeline (HDRP) Project as well as provide best practice information to keep in mind when working with it.

All the CanvasRender modes are supported from Screen Space to World Space. However, only Unlit UI shaders are currently supported.
HDRP supports all the Canvas **Render Modes**, however, it only supports Unlit UI shaders for Canvas UI.

## Working in a Linear Color Space
HDRP projects require working in a Linear color space. When creating your UI, in order to have the proper color - especially on transparent sprites- you need to ensure your textures are in the right color space too. For more information, see [Linear or gamma workflow guide](https://docs.unity3d.com/Manual/LinearRendering-LinearOrGammaWorkflow.html).
## Working in a linear color space
HDRP Projects require you to work in linear [color space](https://docs.unity3d.com/Manual/LinearLighting.html). When you create UI in the Editor, ensure the sprite textures are in linear color space to make sure the UI renders correctly. This is especially important for transparent sprites. For more information, see [Linear or gamma workflow](https://docs.unity3d.com/Manual/LinearRendering-LinearOrGammaWorkflow.html) and [Working with linear Textures](https://docs.unity3d.com/Manual/LinearRendering-LinearTextures.html).

## Multiple Camera Setup
In HDRP, we only support a single Camera setup by default. If you have needs for multi-camera setups, we encourage you to look into those alternatives:
## Multiple camera setup
HDRP only supports a single camera setup by default. If you need to use more than one camera at the same time, it is best practice to use one the following alternatives:


* [Custom Passes](Custom-Pass.md) allow you to inject shader and C# at certain points inside the render loop, giving you the ability to draw objects, do full screen passes,
* [Custom Passes](Custom-Pass.md): Allows you to inject shader code and C# at certain points inside the render loop. This gives you the ability to draw GameObjects and process full-screen passes.


* [Graphics Compositor](Compositor-Main.md) allows you to render multiple HDRP Cameras to the same Render Target.
* [Graphics Compositor](Compositor-Main.md): Allows you to render multiple cameras to the same render target.

## Post-processing effects on UI
UI is rendered before post-processes during the Transparent pass. This setup implies the need of Custom Passes and custom Post Processes to achieve typical visual effects for UI.
HDRP renders UI during the transparent pass, before post-processing. This means that you need to create Custom Passes and custom Post Processes to achieve typical visual effects for UI.

For example, it is typical to want a blurred scene background when opening a UI menu, if that is the case, then you should:
Render your menu in a Canvas with its RenderMode set to Screen-Space - Overlay ; so post-processes are not applied on the menu)
Add a Custom Pass injected After Post Process that will blur your scene - see [HDRP Custom Passes](https://github.com/alelievr/HDRP-Custom-Passes) for further examples.
For example, if you want to blur the scene background when a UI menu is active, you should:

## Known Limitations
1. Render your menu in a Canvas with its **Render Mode** set to **Screen Space - Overlay**. Using this render mode means HDRP does not apply post-processing to the canvas.
2. Add a [Custom Pass](Custom-Pass.md), injected **After Post Process**, to blur your scene. For examples on how to create custom passes, see [HDRP Custom Passes](https://github.com/alelievr/HDRP-Custom-Passes).

## Known limitations
Here is a list of known issues between Unity UI and HDRP:
* Only Unlit UI is supported,
* On XR platforms, only World-Space CanvasRender Mode is supported.
* HDRP only supports Unlit UI.
* On VR platforms, HDRP only supports the **World Space** Canvas **Render Mode**.

0 comments on commit 98ed47c

Please sign in to comment.