shown in other instead.
Setting Up Object LODs
Level of detail optimization will help you greatly enhance the framerate of your project. For that, you need to take your detailed model and create several versions of it, each with lower polygon count. Do not worry, after being exported, they still remain one object, but with a number surfaces. Then the engine will simply switch them one by one as the camera moves away from your object. You just have to control when and how they will be switched.
Here, we would demonstrate how to switch LODs smoothly using alpha fading.
Step 1. Export LODs
LODs are exported from a 3D editor into Unigine as separate surfaces of the same mesh. That is, each surface in our exported mesh represents a separate LOD of the model and can be enabled or disabled. In our case, they will be exported from 3ds Max. Maya is done exactly in the same way.
- Create a high-poly mesh of the object, which will be seen from close-by:
- Group all the objects that will be exported as separate surfaces.
In our case, it will be two LODs of the airplane body, two LODs of the gun and lights (because they need to be assigned a separate emissive material).Keep the number of surfaces in the exported art assets as low as reasonably possible. A separate surface is exported if it either needs a different material or represents a LOD.
- On the Exporter panel at the side check the Groups as surfaces box.
- Set up other options and click Export.
Step 2. Add a Mesh and Assign Materials
- Add an exported mesh into the world as described here. By default, all surfaces (with a low-poly and a high-poly airplane) are visible at the same time:
- Create a material for airplane body as described here. (If you do not yet have a material library associated with the world, you'll need to create one).
- Press N hot key to go to the Nodes settings -> Surfaces tab. Hold SHIFT or CTRL to select surfaces with both low-poly and high-poly airplane body:
- Assign the same material for two LOD surfaces:
Choose the material from the list:
Create materials for the rest of surfaces (guns and lights, in our case) and assign them as well:
Step 3. Set Up LODs
In this tutorial we would want a high-poly LOD of the airplane to smoothly change into a low-poly one at about 5 units away from the camera. Normally, of course, it should have been much further: let's say, at 100 units.
- To start with, hold CTRL, select surfaces with low-poly LODs and disable them, so we can see what's happening.
Only the first LODs are now displayed. That is the airplane we'll see from close-by:
- Choose the 1st LOD surface:
- Set its Maximum Visible distance to 5.
- Leave the Minimum Visible distance at -inf. It means that no matter how close the camera comes to the airplane, the surface will still be visible.
As soon as we leave the 5-units range, the surface is no longer rendered:
- For the 1st surface LOD to smoothly fade out rather then disappear abruptly, set the Maximum Fade distance to 3 units.
It will prolong the distance over which the surface is still visible.
- Enable the 2nd LOD surface.
- Set the Minimum Visible distance of the 2nd LOD surface to start exactly where the Maximum Visible distance of the 1st surface ends: at 5 units.
- Leave the Maximum Visible distance at inf, because it is the last LOD.
- For the 2nd LOD to fade in smoothly (just like the 1st LOD fades out), set the Minimum Fade distance to the same 3 units.
Now the 2nd LOD fades in, while the first one fades out, making the switching less noticeable.
- Now we can enable and set up guns LODs with the same values:
- We have left Min and Max Parents of all surfaces at default of 1. This means, both airplane body and guns will be switched simultaneously, because their distances will be measured not to surfaces themselves, but to the bounding box of the whole airplane.