In the realm of PC gaming, performance is a central focus for developers and gamers alike. A defining aspect of a smooth gameplay experience is how well a game compiles and manages its shaders—a process often happening quietly behind the scenes. Today, we're delving into the intricate world of shader compilation within Star Citizen, a game as renowned for its ambitious scope as it is for its extensive developmental journey.
Our experiment seeks to shine a light on the game's behavior during the initial launch when the shader cache is empty. This is a particularly crucial phase for players who are just starting their space-faring adventure or have cleared their cache after an update. Star Citizen is know that the first Minutes in Game can be very slow and unperformant.
By observing and recording how the game generates shaders, particularly the amount and size increase over an 18-minute window, we aim to understand better the performance implications from startup through to actual gameplay.
Meassure of Shader GenerationTo assess Star Citizen's shader generation in version 3.21.1, all existing shader files were removed to simulate a fresh game launch. The test was carried out on a system equipped with an AMD 5800X3D processor, 64GB of RAM, an RTX 4080 graphics card and a NVMe SSD. A tiny script was written to track changes in the shader cache directory, recording both the count and size of shader files every 10 seconds. This data was overlayed onto the game, alongside real-time FPS metrics. The entire process, beginning from the launcher with 0 Shaders to reaching 4,301 shaders, was captured in an 18-minute video.
Amount of Shaders generated in X Minutes:
Bytes of Shaders generated in X Minutes:
Findings from Star Citizen's Shader TestThe test revealed some unexpected behavior in shader compilation. Contrary to what one might assume, the game began generating shaders not just when engaged in the full 3D game world, but right from the main menu. This undercuts the notion that shader creation occurs exclusively during active gameplay.
A significant majority of shader files were swiftly constructed within the initial 90 seconds post-launch, indicating an aggressive loading strategy. Further a subsequent test focused solely on stying in the menu screen: Even without venturing into the verse, just staying in the Menue, approximately 2,000 shaders around 128MB, were compiled—substantially more than initially expected.
The takeaway from this experiment is a nuanced one. The common advice to idle in the game's spawning apartment, to allow shaders to build does hold some truth, yet it's not the complete picture. A more effective strategy to avoid stutter slow gameplay after a Shader clear, would be to first let the game generate shaders from the menu for a bunch of minutes before entering the verse and then gradually move around in-game locations, as I did in the Video at GrimHex station.
The tests confirmed that spending a short period in the menu before jumping into gameplay aids in building a solid shader foundation. Within approximately already 5 minutes, including some initial time spent navigating menus and then moving around, the game appears to reach a stable state in terms of shader compilation.
However, be aware that as new environments and assets load, the game will continue generating shaders, a process not triggered by idleness but by active exploration and interaction within Star Citizen's universe.