This page has been translated automatically.
Unigine Basics
1. Introduction
2. Managing Virtual Worlds
3. Preparing 3D Models
4. Materials
5. Cameras and Lighting
6. Implementing Application Logic
7. Making Cutscenes and Recording Videos
8. Preparing Your Project for Release
9. Physics
11. PROJECT2: First-Person Shooter
12. PROJECT3: Third-Person Cross-Country Arcade Racing Game
13. PROJECT4: VR Application With Simple Interaction
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Basic Optimization Techniques

Once you have assessed the scene performance status, you already have some idea of what exactly you need to pay attention to in order to improve and speed up your application.

As a rule, one of the main ways to improve performance is to correctly select and apply optimization tools to the 3D scene geometry.

Let's take a look at the main tools available in UNIGINE:

  • Levels of Detail (LODs) — the main way to optimize your project. The idea is to show a simplified model with less detail instead of a highly detailed model when the object is far away from the camera. To do this, you need to take a detailed model and create several versions of it for different distances, each with a reduced number of polygons.

    A model with LODs can be represented as a single Mesh object with a number of surfaces, each representing a certain LOD. LOD settings allow you to specify the distance for switching between surfaces.

    LODs can be configured automatically when importing the model into UNIGINE or manually via a 3D editor and UnigineEditor.

    10109 polygons
    LOD 0
    5004 polygons
    LOD 1
    2583 polygons
    LOD 2
  • Impostors — flat images used instead of real models at a far distance from the camera. This method allows rendering objects with preserving visual accuracy: each impostor has the same transformation and appearance of the original object, but its geometry has only 2 triangles. Typically, impostors are used in scenes with a large number of objects that need to be visible from a long distance.

    UNIGINE has a handy tool for creating impostors — Impostors Creator. It is accessible via the UnigineEditor main menu (Tools -> Impostors Creator).

    A real object (on the left) and its impostor (on the right) in the scene
  • Switching on and off the nodes at a certain distance from the camera using World Switcher. With this tool, you can disable parts of the virtual scene that are far away from the user, thus improving performance.
  • Occlusion Culling allows you to avoid rendering geometry occluded by other opaque geometry by cutting it off using special occluders (Occluder, Occluder Mesh) or using Hardware Occlusion Queries.
  • Managing a large number of identical objects using Mesh Cluster and Mesh Clutter allows you to simplify the node hierarchy by replacing many identical objects with one. Mesh Cluster allows you to arrange the meshes it stores around the scene as you see fit. Mesh Clutter scatters meshes randomly, and they cannot be edited individually. However, using Mesh Clutter is more efficient in terms of memory consumption.

However, it's not just the geometry of a 3D scene that affects performance. Inefficient use of light sources, dynamic shadows and reflections, and other effects can significantly reduce the application speed. That's why UNIGINE has a bit masking mechanism that allows you to selectively apply certain effects or enable certain properties for individual objects. Bit masks are used in the following systems:

  • Rendering into viewport
  • Shadowing
  • Reflections rendering
  • Collisions
  • Intersections
  • Decals
  • Fields
  • Sound sources
  • Physicals
  • Pathfinding (inside Navigation Areas)

Bit mask operating principle is as follows: an effect or property has a certain set of flags — bit masks — that define the scope of this effect or property. Cameras, Objects, Collision Shapes (used to detect collisions with physical objects) and other entities contain some of these bit masks depending on the type of entity and the possibility of applying a particular effect to it.

Masks are compared bitwise using logical conjunction, that is, the first bit of one mask is compared to the first bit of the other mask and so on. Two bit masks are considered a match if they have at least 1 matching bit, regardless of the value of the other bits.

An effect is only applied to an object if their bit masks match.

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.

Last update: 2024-04-04
Build: ()