Building performant applications for embedded systems can be quite challenging. In case of the Hololens, we are dealing with a relatively small amount of RAM and GPU power. (Hololens Graphics)

Unity is a great tool to build applications real quick without spending much time on the real basics. Hence, Unity already delivers a pre-defined set of functionality, whether we need it or not.

While I was building my first application for the Hololens with Unity, I quickly noticed huge performance impacts while executing simple tasks. Not only I didn’t configure Unity properly, but also not much effort was made to “code” efficient. This article covers some basic tweaks to increase your Hololens project performance with Unity.

Captain Obvious Tips

It may sound simple and obvious, but as a nine to five Unity developer, not much effort is made to optimize the scene itself, without even starting to tweak the Unity settings itself.

  1. Keep the amount of gameObject at a total minimum.
  2. Destroy or at least Disable unused gameObjects.
  3. Avoid Update and FixedUpate calls. Try to add as much logic into one Update function as possible, instead of reusing the same script over and over again.
  4. Try to use the new ECS System Unity just came up with.
  5. Use shaders carefully. Less is more in terms of performance.
  6. Use low LOD models and improve the overall appearance with the texture.
  7. Avoid canvas elements.
  8. Prefer mobile shaders over desktop shaders
  9. Always ask yourself: “Do we really need this script/shader/gameObject”?
  10. Use the latest Unity and HoloToolKit

Let’s say we already optimized our scene as much as we can afford, we still have some options left.

Lights

  1. I do not recommend to use lights at all, but mark static gameObjects as static and pre-bake as many lights as possible to avoid real-time rendering.
  2. Avoid casting soft- or hard shadows
  3. In the “Lighting” window, use following environment light settings for the best performance

Player Settings

  1. Prebake Collision Meshes and Optimize Mesh Data.
  2. Select the prefabs you are using the most to speed up the initialization process.
  3. Enable Vertex Compression as well.
  4. Set “Stereo Rendering Mode” to “(Fastest)
  5. Not shown in the screenshot, but disable Accelerometer Frequency if not needed.

Physics Manager

  1. Configure the collision matrix in a way you need it. Disable all unnecessary collision checks.
  2. Disable 2D collision. (Only possible if no 2D collider components are in use)
  3. Avoid Mesh-Colliders and try to apply the most simple colliders. Such as BoxCollider or ShpereCollider.
  4. Make use of Layers and only let gameObjects collide which should be collidable.

Quality Settings

The configuration of the quality settings depends on the application. Therefore, try to tweak the settings as much as possible and find the optimal minimum for the application.

  1. Reduce Light Count
  2. Lower the texture quality
  3. Disable
    1. Anisotropic Textures
    2. Antialiasing
    3. Soft Particles
    4. Real-time Reflection Probes
    5. Shadows
  4. V-Sync: Don’t Sync

Example of a compromise configuration between performance and quality

 

 

 

 

 

 

 

HoloToolKit

Be aware that HoloToolKit adds a lot of bloatware which is mostly not required.

 

 

“Apply Mixed Reality Scene Settings” adds some gameObjects we possible don’t need. Thus, iterate over each element and it’s attached scripts to perform some additional optimization steps.

Don’t forget to bake the light before building a release build 🙂