Unity VR optimisation hints and tips
Hi everyone, we are two developers working on 'Crystal Rift' - Jon Hibbins, who created the game originally and Nick Pittom, who joined the project two months ago.
The game is a dungeon crawler designed for VR, and currently that's the Oculus Rift, although we're looking at GearVR and other platforms. This presents challenges, as all VR games do, but we feel we've been able to make some great progress with the medium and are creating a game that really plays to it's strengths. The game will however also be available to play in 2D, so there are some challenges there to ensure we cater for that as well. However, with VR being our target, there are some unique challenges to the medium, which if you are considering going into VR you may have to overcome.
In future posts we'll delve into the many challenges of developing the specific aspects of the game, but for now we thought it would be great to share some simple hints and tips I have discovered regarding Unity Optimisation for VR, I know it’s a list and a bit bossy but I feel strongly that the combination of these tips will help any game run well in VR on Unity.
First up; develop for the lowest spec machine you want to target and optimise for that, developing on the state of the art scenario that you have custom built is not a machine people have, they have a couple of years old 670 or something, or maybe even and iMac or Gaming Laptop. VR is still very early and it makes good sense to allow as many people as possible to jump on board. It also makes sense to prepare for Mobile VR, such as GearVR, as you can provide faster better computers an upgrade via the Quality system.
- Use the Profiler to find your CPU and GPU ms response, make sure both are under 10ms for the average machine
- Avoid full screen shaders unless you absolutely need to use them, they don’t work well with 2 eyes and add a render pass
- Use static Batching (readup and learn it)
- Use the ABSOLUTE minimum verts you can in every model (less than 300)
- Remove any and all faces you will not see in VR
- Use Unity Pro, it has too many features you need for VR development (Profiler, Occlusion etc)
- Use Height Maps to give depth and avoid the verts – we use these throughout
- Remove ALL Update methods that do nothing, and have a switch off state when they are not needed.
- Replace Update with LateUpdate for Key/Joystiq processing, it seems to perform better
- Remove all Physics and overheads
- Don’t use realtime shadows unless you absolutely require them, even then turn them off on any object it’s not needed or use a quicker method
- Learn the quality settings and what they do, start with the Oculus suggested then adjust them for your game, specifically understand Pixel Light Count, anti aliasing and soft particles
- We create our textures in 2048 and have the default setting as 1024 (roughly the height of the camera) this speeds up the renderer
- Use a single texture for multiple objects
- Understand your shaders and their overheads, only use the ones that don’t require 2nd passes etc
- Optimise every mesh you have, combine them, reduce vets, remove doubles, avoid complex meshes (circles and tubes etc)
- Use Unitys fog start and end on the Camera’s , if you limit the draw distance this may effect your game, but design for it with LOD or something
- Do your own occlusion too, we also remove lights and particles because it all causes overhead
For our own game, the culling system we have in place has been very effective at keeping performance high.
Heres a screen shot of what our map looks like without our aggressive occlusion method:
Here is what it looks like with it on:
As you can see we scrap the bits we can’t see before Unity's profiler even, this made a 10% improvement in render time alone. I’m sure we’ve missed some others, but that’s quite a list for now, if anyone has any other tips or comments on any of these please comment.
I hope you found at least 1 tip here that helps your game, and of course most of these tips are also good for non-VR games.