7 Ways to Optimize your Unity Project with URP

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
There are plenty of ways you can optimize for better performance, and better visual fidelity but each is going to be highly dependent on the nature of your project, so make sure that as you make changes you profile and test to confirm that performance is actually improving. In this video, we’ll be going over some of the ways to optimize the graphics performance of the Universal Render Pipeline (URP). Manage Your Lighting The URP has been built with optimized real-time lighting in-mind, in the URP Forward Renderer you can have up to eight real-time lights per object, and up to 256 real-time lights per-camera on Desktop, and 32 real-time lights per camera on Mobile and Switch. The URP also allows for configurable per-object light settings inside of the pipeline asset for even more control over your lighting. However, one of the best ways to improve the performance of your scene is to bake your lighting wherever possible. Real-time lighting can be expensive, and baking your lights can be a great way to gain back performance. Especially if the lights in your scene aren’t going to be moving. The process of baking, essentially allows lighting data in your scene to be pre-rendered into textures that are then re-projected onto the geometry in your scene. By pre-rendering your lighting data to baked textures, you can save valuable rendering time, and increase the performance of your scene as the lighting textures can be batched into a singular draw call, and don’t need to continuously be calculated; this is especially useful if your scene uses multiple lights. Another great reason to bake your lighting is that it allows you to render bounced or “indirect” lighting in your scene, and improve the visual quality of your scene. This is known as Global Illumination, and is a process that simulates rays of light bouncing around your environment, and illuminating other nearby objects with the bounced light rays. When baked, areas of shadow in your scene will receive the bounced light, and will become illuminated. It can be subtle, but this technique spreads the light around your scene more realistically, and improves its overall appearance. To get started baking your lighting, you first need to mark your lights as Baked. You can do this by selecting the lights in your scene, and choosing Baked from the Mode dropdown. Make sure that any geometry in your scene is marked as Static. This will allow it to be included in the lightmapping calculations, and contribute towards the bounced light from the Global Illumination. It’s worth noting that, you can also change lightmapping settings on individual object meshes, by selecting the GameObject in the Inspector, and adjusting the settings on the Mesh Renderer in the Inspector. This can be a great way to improve baking times, as you can reduce the settings for distant or smaller objects. Once your scene is set up for baking, open the lighting window by choosing Window > Rendering > Lighting, and create a new Lighting Settings Asset. Then set up your Lightmapping settings using the Progressive Lightmapper, and choose Generate Lighting. When you’re setting up your lightmapping settings, you might find that it will take a long time to bake. It’s advisable to start with a low lightmap resolution, and size while you’re iterating your scene during development. It's also possible to visualize lighting data in the Scene view by using the draw mode dropdown Then, when you’ve finished working on your scene, gradually increase the resolution, size, and sample settings for something more suitable for your target appearance. You’ll want to find a resolution that allows these settings to be no higher than they need to be, as lower resolution and lightmap sizes will help lower the texture memory requirement. Use Light Probes Light Probes sample the lighting data in your scene during baking, and allow the bounced light information to be passed onto dynamic objects that may move or change such as characters or vehicles. This helps them to blend into, and feel more natural in, the baked lighting environment. Here you can see the difference between how our character looks with and without light probes active in our scene. To add light probes into your scene, simply choose Create -> Light -> Light Probe Group. Then position your probes into the scene, and choose the edit light probes option. We can then select a light probe, and duplicate it using the button in the Inspector or CTRL + D on our keyboard in windows, or CMD+D on Mac to begin positioning our probes. Generally, it’s worth placing probes wherever there is a shift in lighting. So, place them close to shadowed areas or areas where lighting colors change more frequently. Then, just bake your lighting again to see the effect of your newly placed probes. If you have auto-generate enabled in the Lighting Settings Panel, your scene should automatically update to compensate for the probes. Use Reflection Probes The final way we can use lighting settings to optimize our scene is through the use of reflection probes. Reflection probes are a way of projecting parts of the environment onto nearby geometry to create more realistic looking reflections in our scene. By default, Unity will use the skybox as the reflection texture on your objects. But, reflection probes allow your reflections to more closely match their surroundings. Notice here how more of the lighting in our scene is reflected onto the edges of our objects, and smooth parts of our character. To create reflection probes simply choose Create > Light > Reflection Probe. Next, position and size your reflection probes into areas of your scene where reflections are needed. Then to bake your reflections, simply choose the Bake Reflection Probes setting in the Lighting Window. If auto-generate is enabled, Reflection Probes will be baked automatically. Be sure to experiment with the resolution of your probes using the Resolution dropdown. Higher resolutions will mean higher quality reflections, which are good for objects that may be viewed close up. However, if your camera is further away, lowering the resolution will help keep your scene optimized by storing less information in memory. Manage your Camera Settings The URP includes ways to optimize your camera, by disabling unwanted renderer processes on your cameras. This can be extremely useful if you’re targeting both higher end, and lower end devices in your project. By disabling things like post-processing, shadow-rendering or depth-texture you can remove any potentially expensive behaviorrs on lower-quality settings, and increase performance. Another great way to optimize your camera is through the use of Occlusion Culling. By default, the camera in Unity will always draw everything within the camera’s view frustum including geometry that may be hidden behind walls or other objects. Drawing Geometry is quite expensive, and there’s no point in drawing objects that the player won’t be able to see. This is where Occlusion Culling can be extremely useful. By baking Occlusion Data, Unity can ignore any parts of your scene which are blocked from view of the camera, and therefore increase performance by reducing the amount of scene geometry being drawn per frame. To enable Occlusion Culling in your scene, you’ll need to mark any geometry as either Occluder Static or Occludee Static. Once your geometry is marked, open the Occlusion Window by going to Window > Rendering > Occlusion Culling. Then, click Bake. Now Unity will use the occlusion data when rendering, and not render any geometry that is within the Camera’s view frustum but blocked by another object. This can be previewed in the Scene view during Play mode by selecting a camera, and enabling the Visualisation Tab. Manage your Render Pipeline Settings The URP is designed to support deployment onto multiple target platforms and devices. For that reason, the URP Asset contains multiple settings that we can control to increase and improve performance in our game. You can view the Render Pipeline Asset by selecting it in the project window. Or by choosing Edit > Project Settings > Quality and selecting the Render Pipeline Asset. Each Quality Tier in the project can hold a different Render Pipeline Asset. So, you can create different Render Pipeline Assets to customize the renderer settings, and control how your game performs at each Quality Tier. Many of these settings will impact the overall performance, and visual quality of your scene. It is worth experimenting with them, in order to get the best results for your project, but generally, if you’re looking to gain performance it is worth reducing shadow resolution, and Distance as much as possible, as well as, disabling any features your project isn't using such as the Depth Texture or Opaque Texture. Similarly, enabling the SRP batcher, will enable the new method of batching in the URP The SRP Batcher will automatically batch together meshes that use a compatible shader. So, if you have lots of dynamic objects in your scene, this can be a useful way to gain some performance. The SRP Batcher has been designed specifically for improved batching in the URP. If you’d like to read more on optimizing your settings using Shader Stripping, and the SRP Batcher, we’ve posted a link in the description down below. Use The Frame Debugger Finally, for a better understanding of what’s happening during rendering of your scene you can make use of both the Frame Debugger, and the Profiler. For additional information in the Frame Debugger, You can adjust the Debug level on your URP Asset Note that adjusting this, may reduce performance. So it is recommended to turn it off when not profiling The Frame Debugger gives you a breakdown of all of the draw calls your game makes before rendering the final image, and can be a great way to figure out why certain frames are taking longer to draw than others, or help to identify why your scene’s draw call count is so high in the first place. The Frame Debugger can be found by going to Window > Analysis > Frame Debugger. When your game is playing, select the Enable button to get a breakdown of the scene at each point in the rendering cycle. This is also where you can see any Renderer Features you may have active in your Pipeline Asset, and identify the impact your custom features may be having on the rendering loop. For more information on Renderer Features and how to use them, follow the link below. Use the Profiler Similarly, The Profiler is a great way to figure out how long your project takes to complete a frame cycle. It gives an overview of rendering, memory, and scripting. The Profiler can help identify scripts that are taking a long time to complete, and give you an indication of potential bottlenecks in your code. The Profiler can be found by going to Window > Analysis > Profiler. When Play-mode is active, the window will give you an overview of the overall performance of your game. You can also pause the live view, and use the Hierarchy mode to get a breakdown of the Time taken to complete a single frame, and each call Unity has made during that frame. These are just a few of the ways you can optimize your scene to increase both performance and fidelity. For more information on ways you can optimize your project and for more information on the URP, follow the link below. Thanks for watching.
Info
Channel: Unity
Views: 138,209
Rating: undefined out of 5
Keywords: Unity3d, Unity, Unity Technologies, Games, Game Development, Game Dev, Game Engine, unity 2020, urp, universal render pipeline, performance optimization unity, better performance unity, unity tutorial, better game performance, unity 2020.1, urp in 2020.1, performance optimisation unity 2020
Id: NFBr21V0zvU
Channel Id: undefined
Length: 11min 17sec (677 seconds)
Published: Mon Aug 24 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.