Skip to Content
Engine User Settings

Shader Compiler

Pre-compile material, Niagara and PSO shaders in game to remove shader compilation stutter.

Unreal Engine can hitch while shaders are compiled the first time a material or Niagara system is rendered. The plugin gives you two tools:

  • ABP_ShadersCompiler loads every material and Niagara system of the project ahead of time, e.g. in a loading screen or main menu.
  • PSO precompilation nodes report and speed up the compilation of the bundled PSO cache and PSO precaching in packaged games.

ABP_ShadersCompiler

Drag and drop ABP_ShadersCompiler into your menu level.

Get a reference to the actor and call its Start function.

Bind to On Shader Compiled to update a progress bar and to On Finish to continue to the game.

Avoid compiling shaders in the editor: it also compiles the engine's built-in materials and can greatly increase RAM usage. Test it in a packaged build.

Variables

Use these variables to display progress, e.g. Materials Count / Materials Length.

Variables
Materials CountMaterials LengthNiagara CountNiagara LengthShaders CountShaders Length
PinTypeDescription
Materials CountOutputIntegerNumber of materials whose shaders have been compiled.
Materials LengthOutputIntegerTotal number of materials to compile.
Niagara CountOutputIntegerNumber of Niagara systems compiled.
Niagara LengthOutputIntegerTotal number of Niagara systems to compile.
Shaders CountOutputIntegerNumber of shaders compiled so far (materials + Niagara).
Shaders LengthOutputIntegerTotal number of shaders to compile.

Start

Starts the shader compilation.

Function node: Start
StartTarget is ABP Shaders Compiler
Target

Stop

Stops the shader compilation.

Function node: Stop
StopTarget is ABP Shaders Compiler
Target

On Started

Called when the compilation starts.

Event node: On Started
Bind Event to On Started
Target
Event
On StartedCustom Event

On Shader Compiled

Called every time a shader has been compiled.

Event node: On Shader Compiled
Bind Event to On Shader Compiled
Target
Event
On Shader CompiledCustom Event
Shaders Compiled
PinTypeDescription
Shaders CompiledOutputIntegerNumber of shaders compiled so far.

On Finish

Called when every shader has been compiled.

Event node: On Finish
Bind Event to On Finish
Target
Event
On FinishCustom Event

PSO precompilation & shader nodes

Get Shader Precompile Progress

Subsystem

PSOs still compiling (bundled PSO cache + PSO precaching). Works in packaged games.

Pure function node: Get Shader Precompile Progress
Get Shader Precompile ProgressTarget is Engine User Settings Subsystem
Target
Return Value
FEUSShaderPrecompileProgressStruct
FieldTypeDefaultDescription
Remainingint0PSOs still to compile (bundled PSO cache + PSO precaching).
In Progressboolfalse—

Set Shader Precompile Mode

Subsystem

Fast/Precompile while a loading or "preparing shaders" screen is visible, Background while playing.

Function node: Set Shader Precompile Mode
Set Shader Precompile ModeTarget is Engine User Settings Subsystem
Target
ModeBackground
EEUSShaderPrecompileModeEnum
ValueDescription
BackgroundSmall batches: compiles while playing with minimal hitches.
FastLarger batches: use while a loading screen is shown.
PrecompileEverything as fast as possible: use behind a "preparing shaders" screen.

Get All Materials

Every material asset in the project (asset registry), e.g. to warm up shaders on a loading screen.

Pure function node: Get All Materials
Get All MaterialsTarget is Engine User Settings Subsystem
Return Value

Get All Niagara Systems

Every Niagara system asset in the project (asset registry).

Pure function node: Get All Niagara Systems
Get All Niagara SystemsTarget is Engine User Settings Subsystem
Return Value

Are Shaders Compiling

Shaders (editor) or PSOs (packaged game: bundled PSO cache + PSO precaching) are still compiling.

Pure function node: Are Shaders Compiling
Are Shaders CompilingTarget is Engine User Settings Subsystem
Return Value

On Shaders Ready

Subsystem

Event dispatcher of the subsystem, fired once all pending PSO compilation finished (after some was pending). Bind to it from your loading screen and switch to Set Shader Precompile Mode Background when it fires.

Event node: On Shaders Ready
Bind Event to On Shaders Ready
Target
Event
On Shaders ReadyCustom Event
Edit on GitHub

On this page