Documentation/Articles/How to improve performance and reduce loading time

From NeoAxis 3D Engine Wiki

Jump to: navigation, search
Go to higher level

Contents

Introduction

From this article you will learn how to reduce load time for engine and maps, as well as increase overall performance.

The engine includes a Profiler, where you can find a large number of useful statistics to help you optimize your application. You can access the Profiler from Game.exe, through the Escape menu or from the main menu of your application.

Profiler01.jpg

Reducing load time

Shader cache

Shader compilation is a factor that has a major impact on engine and map load time. Almost any project includes a variety of materials, each of which uses multiple shaders for their work. When there is a large number of materials in your project, shader compiling may take a considerable amount of time. Shaders are compiled in the process of map load, as well as when you change global settings of the engine, such as fog type or shadow type. In NeoAxis you can compile shaders in advance and store them in cache. Shader caching can significantly reduce engine load time. You can learn more about shader compilation from this article. We recommend that you regularly recalculate shader cache.

Texture Format

Different types of textures have different load times. If you use JPG, PNG or TGA texture formats, this may substantially increase load time. We recommend that you use the DDS texture format, because it is the most hardware-friendly format which has the shortest load time. DDS texture format is a container format which may contain data in various formats. You can convert textures to DDS format in Resource Editor or use third-party utilities.

We recommend that you use the following formats of DDS textures:

  • DXT1 - recommended for textures without alpha channel.
  • DXT5 - recommended for textures, which have an alpha channel.
  • 3Dc - recommended for Normal Map textures.
  • (A)RGB - Use this format when the quality provided by DXT1 and DXT5 formats does not suit you requirements. The DXT1 and DXT5 formats are lossy formats, and in some cases, may be unacceptable.

Texture size

We also recommend that you use textures of minimal acceptable size. Any reduction of texture size which does not result in an unacceptable loss of quality, will have a positive effect on application load time and overall performance.

Performance improvement

Most people, new to 3D technologies, and to NeoAxis engine in particular, are often facing the problem of low frames per second (FPS) rate. Below, we will provide you with general recommendations on this issue.

The number of triangles and batches in the scene

A factor that has most impact on the FPS rate is the number of triangles and batches in the scene. A batch (or a DIP call) is a command to the graphics card to render a group of triangles. It is quite similar to how a scene and its meshes correspond. A map contains a large number of meshes, with each mesh consisting of sub meshes. The more sub meshes a scene consists of, the more batches the system has to render. We recommend that you carefully inspect your mesh after import in Mesh Editor.

Profiler02.jpg

Setting up Shadows

Shadows usually have a major impact on performance, especially if enabled Parallel Split Shadow Maps (PSSM). There are two general parameters of shadows: the shadow type and the size of shadow texture. For maximum performance, we recommend you to use the simplest shadow type acceptable or even turn off shadows at all.

You can also turn off shadows for those objects, rendering shadows for which is not so important. Turning shadows on for some smaller objects can significantly reduce performance, although these shadows will be almost imperceptible. In order to adjust shadows for objects of StaticMesh type, use the CastDynamicShadows property. There is also a similar property for attached object types.

Setting up visibility range

Setting up map visibility range prevents the engine from rendering objects that are at a considerable distance from the camera. To set up visibility range, use the NearFarClipDistance property of the "Map" object in Map Editor. You can also customize other parameters of the "Map" object, which can also contribute to performance improvement.

Hardware Geometry Instancing

The engine supports Hardware Geometry Instancing technology, which significantly reduces the number of batches. The technology combines identical groups of triangles and renders them as a single batch, thus reducing the load on the graphics card driver. You can enable or disable the instancing mode in engine Profiler. To do this, open the engine console and type "allowHardwareInstancing false" to disable or "allowHardwareInstancing true" to enable Hardware Geometry Instancing. The Hardware Instancing Technology is now only available for Direct3D.

Level of detail models (LOD)

3D models can have multiple sets of triangles with different levels of detail. Read about how to configure LODs in this article.

Portal system for invisible geometry culling

The engine includes a Portal System for invisible geometry culling, which can significantly increase performance of graphics cards in enclosed spaces.

Setting up lights

Light sources have a major impact on overall performance. We recommend that you use minimum number of dynamic light sources, as well as configure lighting ranges for Point and Spot light sources.

Use of static lighting

The engine includes a component for calculation of static lighting. You can learn more in the Static Lighting Manager article.

Special algorithms for invisible geometry culling

Programmers can change the algorithm to determine visible objects, thus greatly increasing performance. For more information see the RenderingLowLevelMethodsImpl.cs file in the GameCommon project.

Optimization final product by means Ngen.exe (Native Image Generator)

The Native Image Generator (Ngen.exe) is a tool that improves the performance of managed applications. Ngen.exe creates native images, which are files containing compiled processor-specific machine code, and installs them into the native image cache on the local computer. The runtime can use native images from the cache instead of using the just-in-time (JIT) compiler to compile the original assembly.