For a 3D game to run on a mobile device like an iPhone, some serious optimisation need to be implemented.
Crash 3D will target iPhone 4 and up and for this to be possible there are a few factors that need to be looked at when designing a level.
I will just cover the most important ones here for a game to run smoothly.
Firstly you need to look at draw calls. You should have no more than 100 draw calls for older devices.
What are draw calls?
To draw an object on the screen, the engine has to issue a draw call to the graphics API (e.g. OpenGL or Direct3D). The graphics API does significant work for every draw call, causing performance overhead on the CPU side.
How to get less draw calls?
Unity Engine has a built in feature called static batching. This reduces draw calls for all your static objects in your scene. To use it you simply need to tick static in the inspector. Other ways to reduce draw calls are to combine textures of objects into atlases. This will significantly reduce draw calls.
Another thing to look at are your total triangle count. You should try and stay under 50k triangles for older devices like the iPhone 4.
There are many other factors that come to play when optimising a scene for a mobile device, but these two are very important.
What is Frustum Culling?
“Frustum culling is the process of removing objects that lie completely outside the viewing frustum from the rendering process. Rendering these objects would be a waste of time since they are not directly visible. To make culling fast, it is usually done using bounding volumes surrounding the objects rather than the objects themselves.” – Wikipedia
What is Occlusion Culling?
Occlusion Culling disables rendering of objects when they are not currently seen by the camera because they are obscured by other objects. This does not happen automatically in 3D computer graphics since most of the time objects farthest away from the camera are drawn first and closer objects are drawn over the top of them (this is called “overdraw”). Occlusion Culling is different from Frustum Culling. Frustum Culling only disables the renderers for objects that are outside the camera’s viewing area but does not disable anything hidden from view by overdraw. Note that when you use Occlusion Culling you will still benefit from Frustum Culling.
This is our Crash 3D Egypt Level being optimised. After implementing Occlusion Culling and a few other optimisations the end results are great. The optimisation had no impact on how the game looks 🙂
Before Optimisation: 179 Draw Calls, 67 600 Triangles
After Optimisation: 71 Draw Calls, 24 200 Triangles