Mobile Unity Optimisations
Optimisation tips for various platforms taken from various Unity/Unite talks:
Mobile VR:
Youtube: Unity LA 2018: Going for Speed Maximizing Performance on Oculus Go
CPU
- Enable Single-Pass Stereo
- Static Batching - One material per Mesh and mark meshes as static.
- Bake Lighting - Per-pixel lights break batches.
- Occlusion Culling - Don't draw stuff you can't see.
- If Umbra fails build custom occlusion engine - Interiors work better with a custom portal engine.
- Oculus Go can handle large textures - 4096x4096
- Oculus Go can do small head translations in addition to head rotation.
GPU
- Faster Fragment Shader - Start with Mobile/Diffuse and go from there.
- No Post Effects - No bloom, tone mapping, ImageEffects, etc...
- Avoid Multipass Effects - Realtime shadows are expensive, many Unity shaders are multipass (for specular), Per-pixel lighting is one pass per light.
- No Fragment Discard - Never use discard or clip() in shaders, never use alpha test.
- Use Anti-Aliasing 4xMSAA - Is basically free.
Other
- Oculus Go has Fixed Foviated Rendering - Will render peripheral parts of the view at lower resolution than the centre
- Oculus Go has Dynamic Throttleing - Occulus Go will adjust CPU/GPU speed according to utilization.
- Create AssetBundles with Chunk Based Compression - Scene loading with Unity on Android is extremely slow
- Use ASTC Texture Compression.
- Don't Decompress Audio On-Load - Will make loading very slow
Mobile AR:
Youtube: Unite LA 2018: Optimizing AR: how to extend battery life and avoid overheating
- Reduce Framerate to 30 fps - Save a lot of power by reducing image frame rate. Phone camera will probably also not be updating at 60 fps anyway.
- Reduce Physics Timestep to 0.033333 - Since we reduced the image frame rate, we can also reduce the physics refresh rate.
- Reduce Resolution to 1/2 - Retina resolution mobile phone displays have way more pixels than you would actually need and the camera quality will not be high enough to match this resolution anyway.