Documentation/Articles/Overview of Shader Cache Compiler

From NeoAxis Engine Wiki

Jump to: navigation, search
Go to higher level
Shader Cache Compiler

Contents

Shader Cache Compiler

Modern 3D applications are usually using a great number of Shaders. Since shader compiling takes significant amount of time, application load time is increased respectively. The NeoAxis engine enables shader precomputing, thereby significantly increasing application load speed.

Every material has its shader generation settings. Apart from material settings the shader code is also affected by engine global settings (e.g. the selected shadow type and fog type). While generating a material the engine accesses cache and checks shader availability with regard to global settings and material’s parameters. If the required shader is found in cache, the engine uses it. Otherwise, a new shader is compiled “on the fly” just as the application is operating.

To avoid shader compiling while the application is operating a special cache is created to store shaders for all possible variants of engine settings. Due to the large number of such variants compiling a shader cache takes quite a lot of time (about an hour). Of course you may avoid compiling shaders for all possible setting by selecting only those you need.

Apart from ordinary materials there also materials, dynamically generated depending on map settings. For example, terrain creates shaders during the map load. Precomputing is also available for this type of shaders and can be adjusted in the Maps tab.

Shader Cache Compiler Window

The Shader Cache Compiler window consists of two parts: 1 – Main panel and 2 – Tabs panel. Let us examine each element in detail.

Shader cache4.jpg

Main Panel

The main panel consists of the menu and several shortcuts.

Shader cache5.jpg
The File menu includes the Save and Exit buttons.

Use Save to save the settings of the shader cache compiler.

Use Exit to exit the compiler.


Shader cache6.jpg
The Build menu consists of one single Compile button used for starting cache compilation.


Shader cache7.jpg
You may also access the save and compile functions through shortcuts.


Pressing the Compile button calls a confirmation box warning the user that compilation may take a large amount of time.

Shader cache2.jpg

After the choice confirmation the Compile window appears and the compilation process is started.

Shader cache3.jpg

After the compilation is finished press the Close button to close the window.

Tabs Panel (setttings)

The tabs panel is used to adjust shader cache compilation. There are two groups of settings:

  • General
  • Maps

Let us examine each tab in detail.

The General Tab

This tab contains the general settings of the shader cache compiler.

Shader cache8.jpg

While choosing a certain parameter you specify whether shaders will be generated with regard to it. The more parameters you specify, the less possible it is, that the application will have to compile shaders during the map load. However, with a large number of parameters selected shader compilation may take a long time.

Render Systems

Name Description
Direct3D9 To compile shaders for Direct3D9 rendering system.
OpenGL To compile shaders for OpenGL rendering system.

Shader Models

Name Description
Shader Models 2 To compile shaders for video cards with support of pixel shader 2.0 or lower.
Shader Models 3 To compile shaders for video cards with support of pixel shader 3.0.

Shadow Optimizations

Name Description
General To compile shaders those are common for all video card types.
ATI Hardware Shadows To compile shaders, specific for ATI video cards.
nVidia Hardware Shadows To compile shaders specific for NVIDIA video cards.

Fog Modes

Name Description
None To compile shaders for disabled fog.
Exp To compile shaders for the fog of Exp (exponential) type.
Exp2 To compile shaders for the fog of Exp2 (squared exponential) type.
Linear To compile shaders for the fog of Linear type.

Shadow Techniques

Name Description
None To compile shaders for disabled shadows.
Shadowmap Low To compile shaders for low-quality common shadows.
Shadowmap Medium To compile shaders for medium-quality common shadows.
Shadowmap High To compile shaders for high-quality common shadows.
Shadowmap Low PSSM To compile shaders for low-quality PSSM shadows.
Shadowmap Medium PSSM To compile shaders for medium-quality PSSM shadows.
Shadowmap High PSSM To compile shaders for high-quality PSSM shadows.
Stencil To compile shaders for stencil shadows.

Other

Name Description
Static Lighting To compile shaders for static lighting (lightmaps).

Maps Tab

Some objects on the map such as terrain create shaders, unique for this particular map. In order to precompute shaders of this type the whole map should be loaded in the process of compilation.

In this tab you may switch map preload on.

Currently, this mode works only with maps that have terrain on them.

Shader cache9.jpg

The "Check to load maps during shaders compilation" check-box switches the map preload mode on and off.

The textbox below is used for setting path to the maps or to the map search masks. You have to write the path from the Data folder of the project you are working on.

You can compile cache for one of the maps by setting the path to it. For example, Maps\TankDemo\Map.map.

You can also use all the maps from a certain folder (e.g.: Maps\*.map). The cache will be created with the use of all the maps from the Maps folder.

Finally, you may select all the maps available by means of the *.map mask.