Virtual Reality (VR) is one of the most exciting areas currently in the gaming industry. Thanks to Unity’s development platform, it has never been easier for developers and hobbyists to turn ideas into fully fledged games that reach thousands of gamers. In this blog, we present a series of extremely useful optimization tips and tricks from a very special guest, Andrew Connell. He is better known for his YouTube channel ”VR with Andrew”. Unity and Arm sponsored Andrew to create this video on VR Optimization and Performance Tips for Unity.
When implementing these optimizations, Andrew recommends referring to Oculus’ performance guidelines. This make sure you are in the recommended metrics range while developing your application.
LoD stands for Level of Detail, which refers to the complexity of a 3D model representation in a game. LoD can be decreased as the model moves away from the viewer or according to other metrics such as object importance, viewpoint-relative speed or position. Let us start by showing you how to use LoD models.
We can switch between these models depending on how far the viewer is from the object. We then order the models so that the detail of the object decreases as the distance from the object increases. When creating the LoDs, they should be similar in silhouette and appearance, but also sufficiently differ enough in their geometry to increase performance. Additional LoD models do not have to be created by hand - there are plenty of software solutions for automating the creation process. To implement LoDs on an object, check out the video here.
Anti-aliasing means removing signal components that have a higher frequency than is able to be properly resolved by the recording (or sampling) device. To curb this, we can use Multi Sampling Anti Aliasing (MSAA). First select your render pipeline, then navigate to quality, then to anti aliasing, and select 4x. This is the sweet spot for cost and performance.
Also you may come across specular aliasing too. This happens when you have high specularity levels or highlights on a thin bezel or edge. There is no direct fix for this, but there are some techniques to minimize this as much as possible. This includes avoiding the use of sharp edges, making use of smooth round shapes, and using matte materials. To use these techniques effectively, it is best to communicate early on with your artists. Check out the video to see an example of these practices.
For texture compression, it is best to use ASTC since it provides the best quality to size ratio. The menu is shown here. You can handle it on a project basis, but it is much better to apply it on a per asset basis instead. This avoids having unnecessary texture data and provides much better quality. Check out the video to see how to set up your textures individually.
You can also refer to the table provided in the documentation on ASTC on Arm Developer:
Another technique is called Mipmapping. This creates a bunch of smaller textures based on the initial imported texture. This minimizes texture aliasing and improves performance since we are not using additional texture data.
This can be enabled by going to the texture in your asset window, then going to advanced settings to enable mipmapping. Mipmapping is very important for texture filtering. See the tutorial here.
For texture filtering, you get three options: Point, bi-linear and tri-linear. Point means there is no filtering. Bi-linear will sample the nearest Mipmap. Tri-linear will sample the closest two mipmaps and blend them together to give the smoothest transition. The option for enabling texture filtering is in the same settings window as the mipmaps. Watch how to do it here.
For VR, we recommend tri-linear. With additional anisotropic filtering, we recommend a fairly low value since it can be an expensive addition, which should be reserved for environmental assets.
For rougher, more complex textures, there are a few mapping methods that can be utilized. The most common form of bump mapping is Normal mapping, which works well for most use cases. However, for VR, normal maps are not as useful because of the constant change in the viewing angle of players. Furthermore, in VR we must render two different images for each eye, this process is known as stereoscopic vision. The illusion of a normal map is not as reliable in VR as we are using one texture to render two different viewpoints. There is a more suitable type of mapping, called parallax occlusion mapping, which we implement using a height map. This type of mapping factors in the viewer’s angle with the surface. However, this is quite an expensive process and should be used sparingly for example, for objects that the viewer will interact with up close. Check out the video to see how to implement this.
Shadows are crucial in adding depth to your scene. However, they are also compute intensive, especially on mobile devices. Lighting is an equally complex topic, so we will focus on lighting static objects. One thing to remember is that is better to work with fewer and larger textures than several smaller ones regarding light maps. Check out the video to see how to do this.
Arm has published a resource on the Unity Asset Store for creating dynamic soft shadows using local cube maps. This is a very low-cost solution at runtime, so if you need a simple solution then it is definitely one to consider.
Banding occurs when we cannot correctly show the required color within the number of bits we have for each pixel. This results in the color change occurring in steps as opposed to a smooth gradient. The way to overcome this issue is by enabling tone mapping or dithering. Dithering adds noise to the image to break up the visible steps that we see.
Tone mapping attempts to re-map the pixel values from a high dynamic range (HDR) to a low dynamic range. This works well for screens that do not support HDR.
Head over to the video to see how to implement these.
Alpha Compositing is a technique which combines an image with its background to produce a single image. It produces an appearance of transparency and is mainly used on foliage to reduce aliasing. This is a particularly handy method since the previous anti-aliasing tools may not work in this scenario. In this blog, we will specifically focus on a method called Alpha to Coverage (AOTC). Check out video here to learn how it works and how you can implement it in your game.
Finally, make sure to use a linear color space since it works well with Physically Based Rendering (PBR). Check out the video here to find out how to do this.
Get the best out of your VR applications for mobile.
This blog provides an overview of the best tips for optimizing VR applications for mobile. However, there is still so much more to explore. We recommend checking out the VR section on developer.arm.com for more useful tips and resources. Also it is worth subscribing to “VR with Andrew” to watch his latest videos on how to get the best out of your VR applications for mobile.