shown in other instead.
Setting Up Object LODs
Using Levels of Details (LODs) is the main way to optimize your project. The point is to switch the high detailed mesh to a mesh with lower number of details when the mesh is far from camera. For that, you need to take your detailed model and create several versions of it, each with lower polygon count.
The mesh with LODs is imported to Unigine as a single object with a number of surfaces representing LODs. LODs settings allows you to specify the distance when a surface should be switched to another.
This article demonstrates how to export a mesh with LODs from a 3D editor, add it to the Unigine engine and specify settings of mesh's LODs surfaces.
Step 1. Export LODs
To optimize your project by using LODs, you should create one or more LODs for a mesh object. They should be exported as separate surfaces of the same mesh, and each separate surface will be a LOD of the mesh.
To export the mesh with LODs, do the following:
- In a 3D editor, create a detailed model and a number of models with a low number of polygons. For example, you can just copy the existing detailed model and reduce the number of polygons.
Within this tutorial, we will use the model of a plane from Unigine SDK Browser. This model already contains 3 LODs for the plane's body, 3 for windows and another 3 LODs for other parts of the plane.
17827 polygons 11054 polygons 2696 polygons 33403 triangles 20649 triangles 4836 trianglesLOD 0LOD 1LOD 2
- Export the models as an *.fbx file.
In the result, you will get a mesh with 9 surfaces named after LODs.
Step 2. Add a Mesh into the World
Add an exported mesh into the world as described here. By default, all surfaces (LODs) are visible at the same time:
The surfaces of the exported model that represent LODs:
Step 3. Set Up LODs
This section explains how to set up LODs of the mesh to smoothly switch a high detailed LOD to a low detailed when the camera begins to move away from the mesh. LOD surfaces have 3 parameters:
Visibility and Fade Distances
For each LOD surface, you should specify a visibility distance and a fade distance. For setting up the LOD surfaces, do the following:
- Open the Nodeswindow, and choose the added node.
- On the Surfaces tab, choosethe first LOD surfaces and:
You can disable other LOD surfaces to see the result of the current LOD surface settings.
- Set its Maximum Visibility distance to 5. It means that when the camera is 5 units away from mesh, the first LOD surfaces won't be visible.
- Leave the Minimum Visibility distance at -inf. It means that no matter how close the camera comes to the mesh, the surfaces will still be visible.
- Set the Maximum Fade distance to 10 units. It will prolong the distance over which the LOD surfaces are still visible and provide a smoothly fading.
- Choose the second LOD surfaces and:
- Set the Minimum Visibility distance of the second LOD surfaces to start exactly where the Maximum Visible distance of the first LOD surfaces ends: at 5 units. It means that when the first LOD surfaces begin to fade out, the second LOD surfaces will be shown.
- Set the Maximum Visibility distance at 30 units. After 30 units, the second LOD surfaces begin to fade out and the third LOD surfaces will be shown.
- Set the Minimum Fade distance to 10 units. After 5 up to 15 units, the second LOD surfaces will smoothly fade in.
- Set the Maximum Fade distance to 20 units. After 30 up to 50 units, the second LOD surfaces will smoothly fade out.
- Choose the third LOD surfaces and:
- Set the Minimum Visibility distance to 30 units. It means that when the second LOD surfaces begin to disappear, the third LOD surfaces will be shown.
- Set the Maximum Visibility distance at 300 units. After 300 units the third LOD surfaces totally disappear.
- Set the Minimum Fade distance to 20 units. The third LOD surfaces will start to smoothly fade in from 30 to 50 units.
- Set the Maximum Fade distance to 50 units. After 300 units, the mesh will begin to smoothly fade out.
If you want to leave the last LOD surface always visible, set the Maximum Visibility distance to inf.
You should specify the same settings for each surface of the same LOD. Different surfaces from the one level of details should have the same settings to appear and disappear simultaneously.
Minimum and Maximum Parents
Another important parameters of the LODs are Min and Max Parents.
These parameters allows you to specify to which surface or node up in the hierarchy the minimum and maximum visibility distances will be measured. Use the default values of 1. In this case, all surfaces of the mesh will be switched simultaneously, because their distances will be measured not to surfaces themselves, but to the bounding box of the whole mesh.
Read here about these parameters.