VR performance is the foundation for a great VR experience (for example 3D configurators) in space. Headsets like HTC Vive and Oculus Rift both run at an update rate of 90Hz, which means your Unity project’s frame rate must stay at 90fps or higher. Anything else causes the images to “jerk”, resulting in an immersion-breaking experience or worse, simulator disease.
It can be difficult to combine a performance target of 90fps with the desire to use high fidelity 3D models, textures and special effects. While graphics make up most of the performance in VR, other areas such as physics, audio and scripts can also affect performance. Many VR performance problems manifest themselves as a project nearing completion, but a few simple guidelines at the beginning form a good basis.
Using forward rendering and MSAA.
Do not change the default rendering path in Unity. It’s already set to forward rendering and that’s what you want, of course. Set Anti-Aliasing in Quality Settings to about 4x.
For longtime VR developers this may seem like an obvious advice. Unfortunately, we didn’t know this when we started building a very large project based on delayed rendering just to switch to the process at a later date. This has cost a lot of resources.
A rendering path is a technique for drawing images onto a digital display. Unity supports some rendering paths, but the most common are the forward path and the deferred path. The delayed path is rendered in multiple passes that decouple geometry and lighting information. Lighting and shading are “shifted” to the end. This means that delayed rendering supports a large number of lights, since the cost of a light usually depends only on the number of pixels on the screen it affects.
This sounds like a pretty big advantage, but the big drawback of delayed rendering is that it can only perform anti-aliasing through a screenspace shader. This approach is associated with significant performance costs and the results are not always perfect. Anti-aliasing smoothes the jagged pixel edges (aliasing) of objects in 3D and with the relatively low resolutions of VR headsets this is very helpful.
The good news is that forward rendering enables MSAA (Multi-Sampling Anti-Aliasing), a great “AA” technique, at a very low cost. The even better news is that forward rendering is enabled by default in Unity’s graphics settings. All you have to do is make sure that anti-aliasing runs in the quality settings.
In general, we all like to destroy down to one of the quality levels to make sure we’re targeting the experience we want to achieve. We’ve set MSAA to about 4x because we feel there’s a noticeable difference between 2x and 4x, but not much use beyond that. While MSAA is almost “free”, there are still performance costs, as if we rarely go to 8x. Remember that this might change if headsets reach a higher resolution. 8X and more can become the norm over time.
Set the stereo rendering method to Single Pass.
Images in a VR headset are displayed from two different perspectives, one for each eye. In recent years of VR development, this has meant integrating two virtual cameras into a Unity project and rendering the scene twice. In addition, the power costs of image effects would be multiplied by a factor of 2 because they have to be applied to the image of each eye.
Unity has implemented a brilliant solution to this problem called single-pass stereo rendering. It combines the two images into a single rendering pass instead of rendering each one separately and then splits the image accordingly for each lens in the VR headset. Rendering in one pass can be enabled in the player settings.
The only drawback is that not all image effects and shaders support single-pass stereo rendering. Unity supports this immediately, but if you buy assets from the Unity Asset Store, it’s worth contacting the developer in the forums or via email to see if a single pass is supported or not.
Art Direct for performance.
Develop games with performance in mind, rather than end up trying to optimize them.
So create a forward rendered game with MSAA 4x and Single Pass Stereo. These are, in our opinion, solid prerequisites for modern VR development.
We would like to play a VR game in which we drive in a jeep through a lush rain forest in pouring rain and are followed by a T-Rex. We want to see every leaf on every tree, every raindrop and every size on the dinosaur, all simulated in real time. The problem is that this idea would be impossible with today’s technology. Even the “offline rendering” used for Hollywood movies is struggling to achieve this.
Instead, it’s much better to think about all their ideas and try to find those that are feasible and can be rendered and simulated in real time at 90fps. Some ideas must therefore be abandoned if they are unrealistic or do not support the performance goals. Another way to formulate the problem, however, is to view it as a creative art form.
There are no simple answers here, but only hard decisions and a lot of thinking. But thinking is cheap and performance optimization is not really difficult. It is better to develop an idea at the beginning that works well than to try to force a complicated idea into a performance box during the crisis.
Share your performance tips.
Performance is a deep topic with many nuances and there is no way to create a definitive performance checklist to help in any situation. As you develop your project further, we recommend that you perform continuous profiling at each step (using tools such as the Unity’s Profiler). If you have any questions that you would like to share with us, please feel free to do so via our forum.
Thank you for visiting.