taskforce

2023.11 - 3 Ways to Prewarm Your Lazy Shaders

November 1, 2023 ยท 2 min read

Shader hitches are not a cosmetic bug. In VR, in shooters, or in any commercial build, one lazy shader compile can wreck muscle memory, create stale frames, and make your game feel broken right when the player expects smooth action.

The brutal reality check: what you think is one shader is often a master shader that explodes into many variants, and the wrong warmup strategy can burn seconds to 15 minutes while still letting hitches leak into gameplay.

Start here: stop profiling this in the editor. Build the player, trigger a repeated spawn/use case, open the Timeline, and look for CreateGPUProgram. If shader compilation happens the first time the object shows up on screen, you are already too late.

Unity Profiler showing CreateGPUProgram on first use

This module then shows the three real ways to deal with it: API-based warmup, spawning what you need behind an opaque loading screen, or doing a scene fly-through so Unity compiles what the player is about to see before gameplay starts.

One warning: do not go nuclear and warm everything blindly. The lesson is explicit here: Shader.WarmupAllShaders is usually the wrong move, ShaderVariantCollection can still miss runtime context, and modern APIs like Vulkan, DX12, and Metal care about mesh vertex attributes too.

First validation pass: enable log shader compilation in Graphics Settings for dev/profile builds, then check the player log. The compiled-shader messages should happen during startup or the loading-screen phase, not in live gameplay.

Player log showing compiled shader entries during prewarm

CEO/Producer translation: this is how you kill the one-frame stutters that tank trust, create hotfix pressure, and get much uglier on performance-sensitive targets.

The members-only module is the full step-by-step playbook: the profiler workflow, the log workflow, ShaderVariantCollection, the newer Shader Warmup API with vertex attributes, and the loading-screen plus fly-through path that keeps shader compilation out of the player's face.

In this module:

Join to unlock the full module, audio, and resources.