Mesh Level of Detail (Legacy)
- Last UpdatedJul 04, 2023
- 2 minute read
The LOD of the mesh is a sequence of independent meshes from which the engine will choose from time to time which one to draw. They can be with shaders, or different materials.
Enabling the LOD of the Mesh
The mesh must be called in a particular way. Add @LODxxx after the name of the mesh that forms the sequence of LOD.
The initial part of the name of the mesh (that is, the one that comes before @LODxxx) must be identical for all the meshes that will form that LOD.
Naming example
-
The first LOD has index 0, so the tag is nameMesh @ LOD0.
-
The following LODs will have the distance from which they will be visible so the tag is nameMesh @ LODn_distance, where n is the LOD number and distance is the distance.
For example: nameMesh@LOD1_50.7 indicates the LOD 1 that becomes visible from a distance of 50.7.
Distance
-
When choosing the distance, remember that the distance at which the LOD is chosen is calculated from the center of the object BoundingSphere.
Number of meshes
-
The maximum number of LODs supported is 8, so from @ LOD0 to @ LOD7, it is important that there are no gaps between the various LODs, such as activating only the @ LOD0 and the @ LOD2, forgetting the @ LOD1.
Other notes
-
The mesh will always be identified by the engine as the only mesh with the name nameMesh.
-
It is important that between the various meshes there is a bounding correspondence, that is, that the space occupied in the scene is identical (or at least the maximum for LODs above 0). This is because actions such as the visibility calculations are done on the bounding (box, sphere) of the mesh at @ LOD0.
-
The same goes for the pivots of the objects. They must all be in the same position. Otherwise, the meshes risk being drawn at different points according to the LODs.
-
The hierarchy must also be the same.
-
You can animate a sequence of LOD by animating the LOD0, and the others will follow.
-
Only the meshes with unified material can be used for the LOD. This almost all the meshes available, except for the particular ones such as tubes, billboards, or those containing movies.
Scenario example
A mesh called Home requires three LODs.
-
Create the three meshes of the LODs.
-
Arrange the pivots to be identical.
-
Rename them to make it clear to the engine that they are a sequence of LODs. Otherwise, the engine draws them as if they were three normal meshes.
-
Rename the first LOD: Home @ LOD0
-
Rename the second LOD: Home @ LOD1_5000
-
Rename the third LOD: Home @ LOD2_7000
-
Results of scenario
-
The House at @ LOD0 is drawn when the distance is 0..4999.
-
The House at @ LOD1 is drawn when the distance is 5000..6999.
-
And the House at @ LOD2 is drawn when the distance is 7000..infinite.