Working with Content
So, the above are the basic optimization techniques available in UNIGINE.
However, the optimization process is not limited to these tools. In most cases, it starts at the stage of importing your content into the project. In addition, most objects have a set of parameters that allow you to control their impact on performance.
We'd like to share some recommendations on working with content that will help you keep your application's performance at a high level.
Geometry#
We have already mentioned that geometry is the main part of a virtual scene that significantly affects performance, and UNIGINE has enough tools to optimize it. But to achieve maximum efficiency when using these tools, you should also follow these rules:
- Try to create LODs as separate surfaces of one mesh. This way you will reduce the number of nodes in the hierarchy and simplify configuring the LODs visibility.
- The number of polygons in neighboring LODs should differ by 2-3 times at least.
- The optimal number of LODs is 2 or 3. Using more levels of detail in most cases will only create an additional CPU load.
- Avoid using occluders with large objects that have multiple surfaces, as well as in scenes with flat objects, as this can lead to a performance drop instead.
- Export models from a 3D editor in local coordinates, so that the size of the mesh bounding box is as close as possible to the size of the mesh itself. This will provide a more accurate occlusion culling.
Terrain, Grass, Water and Cloud Layer#
As you know, besides being imported from other 3D editors, geometry can be created directly in UnigineEditor using the built-in tools. The most performance-consuming objects created in this way are Terrain, Grass, Water and Cloud Layer. They have a set of parameters (both global and local for each object) that are designed to optimize the rendering.
Textures#
As a rule, in any project a 3D model has several textures assigned for various purposes, consuming quite a lot of memory. The following techniques can help you reduce their impact on performance:
- Try to use smaller textures wherever possible, but always check that the visual performance hasn't degraded.
- Configure the global texture settings: set the optimal Quality and Maximum Resolution values for all textures in the project to reduce the amount of GPU memory consumption.
- Use asynchronous streaming of graphics resources to load textures smoothly. Try not to set a low Textures Memory Limit to avoid re-uploading them from disk.
- When importing textures, enable the Unchanged flag only for *.dds or *.texture textures, and for your custom textures (e.g. HDR) that should not be compressed.
- Choose the appropriate Texture Preset when importing the texture, or customize your own. This will allow you to apply the correct compression to the texture and avoid creating unused texture channels.
- Use texture channels to store multiple textures in a single texture.
Decals#
Decals are usually used to add extra detail to objects in a scene. Each decal has settings that may contribute to performance optimization:
- Configure the decal visibility distances (Min/Max Visibility, Min/Max Fade).
- Use the Viewport bit mask to control the decals visibility.
Particle System#
If you use particle systems in your scene, you can reduce the frame refresh rate for their simulation to improve performance. This can be done using the Periodic Update section parameters in the Particle System settings.
Here you can also specify the distance at which the particles stop updating and freeze (the Update Distance Limit parameter), as well as the frequency of their updating when only the shadow of the particle system is visible in the frame or nothing is visible at all.
Lighting#
Lighting in a scene also requires quite a bit of resources. Each light source, depending on its type, may require up to 6 rendering passes to calculate the shadows cast by the objects it illuminates. The individual settings of each source can also affect performance.
You can apply any of these methods to optimize the rendering of light sources:
- Disable shadow rendering for some illuminated surfaces and materials. For example, you can do this for the farthest LOD surface (where shadows are not important).
- Use static lighting and shadows for immovable objects instead of dynamic lighting.
- Use Shadow Mask to control the rendering of shadows from lit objects.
- Use Screen Space Shadows instead of Shadow maps at long distances, since screen-space effects depend on screen resolution rather than geometry: the higher the resolution, the more accurate the shadows.
- Reduce the size of the light source.
- Enable Interlaced rendering of light sources.
- Configure the distance at which light sources and shadows are rendered.
- Use as few light sources that affect transparent objects as possible.
- Disable rendering of light sources on water.
- Use as few World Lights as possible.
- Reduce the number of cascades for World Lights.
- Use Point-shaped Omni Light sources and disable shadow rendering for surfaces illuminated by such sources. Since the UNIGINE engine uses tile-based rendering, these light sources will be grouped and rendered in the batched mode. Batch rendering settings are available in the Settings window (Lights -> Batching).
- Create fake lighting: use Billboards and Volumetric objects instead of real light sources.
Physics#
To optimize the modeling of physical phenomena and interactions, we recommend the following:
- Configure the global physics settings: adjust the distance from the camera within which the physical interaction of objects takes place, specify the optimal number of computational iterations per one frame (for example, for simple scenes, one computational iteration is enough), and select a suitable time budget within which the physical calculations take place in the current frame (if the physical interactions look like slow motion, the time budget should be increased).
- Use bit masks to fine-tune physical interactions between objects. For example, you can limit object collisions by using the Collision Mask.
- Use a simplified geometry for Collision Shapes used in collision detection. For example, you can use the least detailed LOD or just a primitive.
- Try to use as few Collision Shapes for a single object as possible.
- Use discrete collision detection wherever possible.
- Enable the Freezing option for Rigid, Ragdoll, and Fracture bodies to stop physics calculations when no external force is affecting the body.
Adjust the amount of pieces for Fracture bodies, as too many pieces can reduce performance.