Documentation/Articles/Overview of Shader Cache Compiler

From NeoAxis 3D Engine Wiki

Jump to: navigation, search
Go to higher level

Contents

Shader Cache Compiler

UtilitiesIcon.jpg Shader cache compiler (ShaderCacheCompiler.exe) is a tool to optimize engine loading speed. The tool precompiles shader programs of the video card. When you feel your app loads too long, consider using this instrument.

Shader Cache Compiler

Modern 3D applications use large amounts of shaders for their work. Compilation of significant number of shaders takes a lot of time, because absent a cache, compilation is performed upon loading the map. The engine allows preliminarily calculating shaders and therefore significantly increasing loading speed of the application.

Each matrial has its own shader generation settings. Aside form settings of the material, the code of the shader depends on global settings of the engine. For instance, on the selected type of shadows. When the engine generates material, it queries the cache and checks for the given shader taking into account parameters of the material and global settings. If the shader is found in the cache, the engine uses it, otherwise the shader needs to be compiled in run-time of the application.

To avoid compiling shaders in run-time, a cache is created. It contains generated shaders for all possible combinations of global settings of the engine. Given the huge amount of variants of settings, shader cache compilation takes significant time (about an hour). There's no need to compile shaders for all possible combination of settings, though. Only specific ones can be selected.

In addition to basic materials, there are materials generated dynamically depending on map settings. For example, landscape creates shaders upon loading of the map. Pre-compilation of such shaders is supported too and is configured on the Maps Tab.

Menu

File

ShaderCacheCompiler 03.jpg


The File menu consists of Save and Exit commands.

Save — saves shader cache compiler settings. This action is also available from the toolbar.

Exit — exits the compiler.


Build

ShaderCacheCompiler 04.jpg


The Build menu consists of one item — Compile. This command starts cache compiling. This action is also available from the toolbar.

After you click the Compile button, a confirmation window opens warning you compilation may take significant time. This window also has the Purge cache option that allows to clear a previously compiled cache. We recommend using this option when for the final build of the project.

ShaderCacheCompiler 05.jpg

After confirmation, the Compile window opens and the compilation process starts.

ShaderCacheCompiler 06.jpg

Upon completion of compilation click the Close button to close the window.

Help

ShaderCacheCompiler 07.jpg


The Help menu consists of 3 items:

  • Overview of Shader Cache Compiler — opens shader cache compiler documentation, that is the present text.
  • Documentation — opens engine documentation.
  • About — opens the About window of the program.

General Tab

This tab contains the general shader cache compiler settings. Each particular parameter indicates whether or not the compiler should take this parameter into account when generating shaders. The more parameters are selected, the lower is the probability the app will have to compile the shader upon loading of the map. At the same time, the more options are selected, the longer it takes to compile shaders.

ShaderCacheCompiler 08.jpg

Render Systems

Title Description
Direct3D9 Compile Direct3D9 rendering system shaders.
OpenGL Compile OpenGL rendering system shaders.

Shadow Optimizations for Direct3D9

Title Description
General Compile shaders that are common to all types of video cards.
ATI Hardware Shadows Compile ATI-specific shaders.
nVidia Hardware Shadows Compile NVIDIA-specific shaders.

Fog Models

Title Description
None Compile shaders for disabled fog. This option is always on.
Exp Compile shaders for the Exp (exponential) fog type.
Exp2 Compile shaders for the Exp2 (squared exponential) fog type.
Linear Compile sahders for the Linear fog type.

Shadow Techniques

Title Description
None Compile shaders for disabled shadows. This option is always on.
Shadowmap Low Compile shaders for low quality common shadows.
Shadowmap Medium Compile shaders for medium quality common shadows.
Shadowmap High Compile shaders for high quality common shadows.
Shadowmap Low PSSM Compile shaders for low quality PSSM shadows.
Shadowmap Medium PSSM Compile shaders for medium quality PSSM shadows.
Shadowmap High PSSM Compile shaders for high quality PSSM shadows.

Others

Title Description
Static Lighting Compile static lighting shaders (lighting maps).

Maps Tab

Some objects on the map such as landscape create shaders unique for each particular map. To precompute such shaders, a whole map should be loaded during the compilation process.

On this tab you can enable map preloading during shader compilation (the Load maps at compilation time option).

This mode is beneficial to maps that feature landscape or dynamically created materials.

ShaderCacheCompiler 09.jpg

Aside from map preloading you should specify a map list in the below box. The list supports both map paths and wildcards. The path is specified relative to the Data folder of the project.

You can compile cache for a specific map by specifying the path to it. For example, "Maps\TankDemo\Map.map".

Another example is using all maps in the given folder: "Maps\*.map". The cache will be created based on information of maps in the Maps folder.

Finally, you can select all maps using the *.map mask. This is the default setting.