If we want to get the most out of Unity and optimize our performance, we’re going to need an efficient way to display lighting and shadows. The best way to do this is through the Universal Render Pipeline (URP).
The URP was developed to provide optimized performance for developers who are targeting a wide range of platforms. With VR, it will give us the capabilities of optimizing our projects for both the Quest 2 and PC VR users. It provides this functionality by making some trades with both lighting and shading techniques. The URP is also a Scriptable Render Pipeline. Without getting into too much detail, this just means that we control rendering through C# scripts, which can be useful for detecting hardware for our users and automating what rendering processes we wish to use for them.
URP Roadmap
Some great benefits that are highlighted in the URP are its light drawing processes, its ability to build once and deploy to everywhere, being able to use Shader Graph and having the ability to perform Deferred Rending. There is a ton of functionality with the URP. I won’t be able to cover all of it here, but if you wish to dive into it more, you can find more information at the URP Roadmap.
adding the URP to Our Projects
Let’s kick things off by integrating the URP to our projects.
There are two ways in which we can add the URP to our project. The first way is by simply starting a project with the URP in it.
- In Unity Hub select New Project
- Select the template labeled 3D (URP)
- Select Create Project
- Window -> Package Manager
- Find and install the Universal RP
- Right Click Assets -> Create -> Rendering -> URP Asset (With Universal Renderer)
- Edit -> Project Settings -> Graphics
- Drag the newly created URP into the empty slot for Scriptable Render Pipeline Settings found in Project Settings.
We may notice that all our objects in the scene have turned pink. That is because the material shaders that these objects are currently using are not compatible with the current rendering pipeline that we just put into place. To fix this, we have a few options available to us.
Changing Materials 1-by-1
- Select an object that is pink
- Navigate to the Material component
- Click the Shader dropdown and go to Universal Render Pipeline -> Lit
The only problem with this is it would take forever to change all our Materials and we might miss some. The other option is to do the following.
- Select all the Materials that we wish to convert to URP
- Edit -> Rendering -> Materials -> Convert Built-in Materials to URP
The last option is to do a bulk conversion of all Materials in the project. To do that, we’ll need the help of the Render Pipeline Converter.
- Window -> Rendering -> Render Pipeline Converter
- Click the dropdown and select “Built-in to URP”
- Select all empty boxes to target for conversions (rendering settings, material upgrade, ect)
- Click Initialize Converters
- Click Convert Assets (This may take a minute or two)
Settings for URP
When it comes to optimizing with the URP, we have a ton of options. Each one will give a trade-off between performance and quality. I will list of some of the settings that I’ve found useful, but don’t think of this as a coverall solution. Every project is unique and we should consider always make sure our setting align with the needs of our current projects.
- Select the Asset called URP_Renderer (This may have a different name if you renamed when creating it)
- Under Rendering
- Rendering Path = Forward
- Post Processing = Disabled
- Under Rendering
Post Processing disabled is also recommended by Meta. Most post processing effects cause a heavy load on CPU and GPU. We may want to consider using post processing to add things like vignette to reduce motion sickness, but other post processing effect like bloom should be avoid if possible.
Now lets mess with the URP Asset.
- Select the URP Asset (Name may differ if you changed it during its creation)
- HDR = Disabled
- Anti-Aliasing = 4x
We first turn off HDR (High Dynamic Range) because it interferes with MSAA. We also set Anti-Aliasing to 4x to help reduce the edges of objects in our game without being too costly to the CPU/GPU.
Conclusion
That’s it for this one! Although there is more to cover, it will start getting into lighting and that will have to wait for another tutorial!