Level of Detail (Pro Only)
As your scenes get larger, performance becomes a bigger consideration. One of the ways to manage this is to have meshes with different levels of detail depending on how far the camera is from the object. This is called Level of Detail (abbreviated as LOD)
Here's one of the ways to set up an object with different LODs.
- Create an empty Game Object in the scene
- Create 2 versions of the mesh, a high-res mesh (for L0D:0, when camera is the closest), and a low-res mesh (for L0D:1, when camera is further away)
- Add a LODGroup component to this object ( -> -> )
- Drag in the object with the high-res mesh onto the first Renderers box for L0D:0. Say yes to the "Reparent game objects?" dialog
- Drag in the object with the low-res mesh onto the first Renderers box for LOD:1. Say yes to the "Reparent game objects?" dialog
- Right Click on LOD:2 and remove it.
At this point the empty object should contain both versions of the mesh, and "know" which mesh to show depending on how far away the camera is.
You can preview the effect of this, by dragging the camera icon left and right in the window for the LODGroup component.
In the Scene View, you should be able to see
- Percentage of the view this object occupies
- What LOD is currently being displayed
- The number of triangles
LOD-based naming conventions in the asset import pipeline
In order to simplify setup of LODs, Unity has a naming convention for models that are being imported.
Simply create your meshes in your modelling tool with names ending with _LOD0, _LOD1, _LOD2, etc., and the LOD group with appropriate settings will be created for you.
Note that the convention assumes that the LOD 0 is the highest resolution model.
Setting up LODs for different platforms
You can tweak your LOD settings for each platform in Quality Settings, in particular the properties of and .
Utilities
Here are some options that help you work with LODs
Recalculate Bounds | If there is new geometry added to the LODGroup, that is not reflected in the bounding volume, press this to update the bounds. One example where this is needed is when one of the geometries is part of a prefab, and new geometry is added to that prefab. Geometry added directly to the LODGroup will automatically updates the bounds |
Update Lightmaps | Updates the Scale in Lightmap property in the lightmaps based on the LOD level boundaries. |
Upload to Importer | Uploads the LOD level boundaries to the importer |