Optimization in Unity3D for XR apps & Game Development

Akshay Arora
XRPractices
Published in
3 min readNov 18, 2022

Optimization is a very important area to look into while building real time XR(AR/VR/MR) applications and game development.

What is Optimization?

For games and XR applications, the user experience is the prime goal. the performance of your XR app or game might make or break the complete experience of the user. Running an application or game that is properly optimized feels very smooth and responsive, and it will have a larger audience since it can run on lower-end platforms and multiple devices.

Why is it very important to take care of it from project’s initial stage?

In colleges and online courses, we’ll be most likely have been taught how to optimise graphics and code. But in practice or in actual project, these techniques might not always be practical to implement due to various reasons like:

  • Project deadlines & budget
  • Difference in skill set of team members
  • 3rd party dependencies like SDKs, assets, libraries, etc.
  • Feeling lazy.. 😴

Optimization should be as important as a process as your app’s version control. It's a good idea to write efficient code, import not very over-bloated assets and 3D models, from the very start of the project.

Now, we know when to start the optimization but when to stop?

Benchmarking

A benchmark is a point of reference that you can use to determine if your optimisation efforts improving the game performance or making it worse. How to determine this benchmark?

  • App or game should run/boot fast
  • Performance should be consistent
  • Should make the target FPS(Frames per second)- 30 FPS or 60 FPS
  • Other parameters like device temperature, storage, etc.

Frame and Frame rate

When we say that the app or game should target one specific FPS number, how exactly is higher frames/second making the difference in performance?

But first, let's understand, what exactly a frame is?

The CPU processes the game engine components and code and calls the renderer, which then passes control to the GPU that produces the image or a FRAME we finally see on the screen.

The CPU must finish the things before the GPU will start drawing the frame. If the CPU and GPU can finish their tasks in the allocated time, then we will achieve the desired frame rate. However, if they can’t be completed in time, the frame time will get longer. As a frame takes up more milliseconds, the frame rate decreases.

Getting started with Optimization

First, know about the right tools.

Unity Editor Profiler is a tool which can be used to measure performance of our application. We can connect the devices to test how the application or game is intended to work on the release devices. Profiler will also run in Editor to quickly check the bottleneck but it is recommended to do the final benchmarking in the target device. To access the profiler window, go to Window->Analysis->Profiler to access the profiler window

Sample profiler window

There is Memory Profiler as well which can be added by importing a package and is used to get additional information to analyze memory usage.

Stats window shows real-time rendering information. Stats can be enabled by clicking on upper right corner of the Game view in the Unity Editor.

Stats window

Frame debugger lets us freeze the playback on a particular frame to view the draw calls and details related to rendering that particular frame. Frame debugger can be accessed by going to Window->Analysis->Frame Debugger

Frame Debugger

Now, we know about the tools. Let’s go to the main part, how to optimize the app or game.

We can divide the optimizations into segments:

These topics, we can discuss in different articles otherwise this article will become huge. Will post the links here once they are published.

Thanks! 🙂

--

--