When we launch Atomic Heart, The Last of Us Part I, or S.T.A.L.K.E.R. 2: Heart of Chornobyl, the game asks us to wait for shader compilation. On some computers, this process takes 5 minutes, while on others, it can take from half an hour to several hours. In most games, there is no shader compilation option in the menu, and this process starts during gameplay, reducing FPS and causing constant freezes and stutters.
So what exactly are shaders? How do they affect performance, and why do gamers have to wait for compilation right in the main menu? Today, we will answer these questions.
What are shaders
Shaders are small programs, short lines of code. They tell the graphics card how to correctly render textures, 3D objects, and special effects in the game.
Shaders are divided into several types:
Pixel and ray tracing shaders. Used for correct calculations of lighting, shading, transparency, explosions, fire, and other physical effects.
Compute shaders. Used to speed up game rendering and perform complex mathematical calculations.
Vertex, geometry, surface, and domain shaders. Used to shape the boundaries of 3D objects.
How Shaders Affect FPS in Games
Thousands of shaders are used in modern games to create beautiful visuals. Many of them are simple and have little to no impact on performance. For example, shaders that apply textures to 3D models belong to this category. This is why the "texture quality" setting in graphics options hardly affects FPS (only if the game has enough RAM and VRAM from a gaming computer).
However, there are very complex shaders that significantly impact performance, such as ray tracing shaders. They handle a large amount of data and are used for properly rendering ray tracing effects. This is one of the reasons why enabling RTX drastically reduces FPS in games.
Shaders not only lower frame rates but also cause freezes and stutters (short micro-freezes). While FPS drops may still be tolerable, constant stutters severely disrupt the gaming experience.
How Shaders Affect Freezes and Stutters in Games
Shaders are written in a high-level programming language, which graphics cards do not understand. They can only process binary machine code. To translate shaders into a language that GPUs can comprehend, they must be compiled.
This task is handled by the central processor. Compiling one or a few shaders is not an issue, but modern games use thousands of shaders. When they need to be loaded in batches of dozens or even hundreds instantly, even the most powerful processors may struggle. This results in freezes.
How Developers Optimize Shader Compilation
Developers are aware that shaders negatively impact performance. There are three ways to address this issue:
Compiling all shaders on the first game launch. In this case, gamers have to wait in the main menu while the game compiles all shaders.
Loading and compiling shaders during gameplay. This can cause stuttering, and FPS may drop due to continuous compilations.
Compiling some shaders on the first game launch and loading the rest during gameplay. This is the most common approach used by most developers.
The impact of shaders on performance largely depends on the experience, skills, and qualifications of programmers. Skilled developers can predict which shaders will be needed and when. For example, if programmers know that certain shaders are unnecessary in a specific location, they can configure the game to avoid compiling those shaders. This reduces CPU load and helps eliminate freezes and stutters.
Unfortunately, not all programmers have high qualifications, which results in games like The Callisto Protocol or S.T.A.L.K.E.R. 2: Heart of Chornobyl. These projects run poorly even on high-end PCs.
Why Shaders Cannot Be Compiled During Game Installation
On Xbox and PlayStation consoles, shader compilation is not an issue because they are compiled during game installation. However, this is not possible on PCs. Shaders are compiled specifically for each individual PC configuration. If you change your processor, graphics card, or RAM, the game will need to recompile all shaders. Given the vast variety of PC components, developers simply cannot precompile shaders for all possible configurations.
How to Solve the Freezing Issue Caused by Shader Compilation
The problem of freezing due to shader compilation should be addressed by developers. As gamers who pay for games, we expect polished products. However, the industry is not perfect. There are several ways to reduce the number of freezes caused by shader compilation:
Installing the game on an SSD. Avoid using hard drives for modern games. Their speed is insufficient for quickly loading a large number of small files. This helps resolve issues with freezing and long loading times.
Using a more powerful processor. Shader compilation is handled by the processor. Upgrading to a more powerful CPU will speed up compilation, reducing freezes and FPS drops.
Closing all programs before launching the game. This ensures that all CPU resources are dedicated to the game, freeing up additional power for shader compilation. It is also recommended to optimize Windows.
Limiting the frame rate in game settings. If the maximum FPS is capped, the processor will not operate at full load. The freed-up performance can be used for faster shader compilation and eliminating freezes.
These methods will not completely eliminate the problem, but they will significantly help reduce the number of freezes and FPS drops.
Conclusion
To summarize:
A shader is a small program that tells the graphics card how to properly render a graphical effect in the game.
Modern games use thousands of shaders, which significantly impact performance and cause freezes.
Not all developers effectively manage shader libraries, which is why some games run smoothly while others experience freezes even on high-end PCs.
The issue of freezes caused by shader compilation can be partially mitigated by:
installing the game on an SSD;
upgrading to a more powerful processor in the PC;
closing all unnecessary programs before launching the game;
limiting the maximum frame rate in the settings.
Shader Compilation on HYPERPC Computers
We understand that shader compilation negatively affects performance in modern games. To solve this problem, we use in our PCs:
High-speed SSDs with NVMe data transfer protocol;
High-frequency DDR4 and DDR5 RAM modules;
Multi-core Intel and AMD processors of the latest generations.
These components significantly reduce the number of freezes and FPS drops in games due to shader compilation, ensuring smooth and stable gameplay.