4.2.1 Miscellaneous GPU optimizations
The following list describes miscellaneous GPU optimizations:
- Use static batching
- Static batching is a common optimization technique that reduces the number
of draw calls and this, in turn, reduces application processor utilization.
- Dynamic Batching is performed transparently by Unity, but it cannot be
applied to objects made up of a large number of vertices, because the
computational overhead becomes too large.
- Static Batching can work on objects made up of a large number of vertices,
but the batched objects must not move, rotate, or scale during rendering.
- To enable Unity to group objects for static batching, mark them
as static in the Inspector.
- The following figure shows static batching settings:
Figure 4-5 Static batching settings
- Use 4x MSAA
- ARM Mali GPUs can do 4x multi-sample anti-aliasing with very low
- You can enable 4x MSAA in the Unity Quality
- The following figure shows the MSAA settings:
- Use level of detail
- Level of detail (LOD) is a technique where
the Unity engine renders different meshes for the same object depending on the
distance from the camera.
- Geometry is more detailed when the object is close to the camera. The
detail level is reduced as the object moves away from the camera and at the
furthest distance you can use a planar billboard.
- You must set up LOD groups properly to manage the meshes to use and the
associated distance ranges.
- To access the setup of LOD groups, select:
- In Unity 5 you can set a Fade Mode for
each LOD level to blend to contiguous LODs. This smooths the transition between
them. Unity calculates a blending factor according to the screen size of the
object and passes it to your shader for blending. You must implement the
geometry blending in a shader.
- The following figure shows the LOD group settings:
Figure 4-7 LOD group settings
- Avoid mathematical functions in custom shaders
- When you are writing custom shaders, try to avoid using expensive built-in
mathematical functions such as: