Trouble understaning how Shader Warmup works

Apologies if this is obvious, but I couldn’t find this clearly stated anywhere.

I am currently warming up my shaders at game start, which takes around 1 minute. This is way too long for me as I have a quite small game.

I get the log message that 80 shaders are being warmed up with around 25k variants.

That raises some questions for me:

  • How are the Shaders that are being warmed up selected? All Shaders from the Project? All Shaders in Resources Folders? All Shaders linked to GOs?
  • What is the actual performance impact of assinging a ShaderVariantCollection. I did a game run, Collected all Shaders, (only around 40 with 180 Variants) saved as A ShaderVariantCollection and added it under Graphic Settings. However, the warmup time stayed the same

Any help is much appreciated!

EDIT: To clarify, I’m currently using Shader.WarmupAllShaders

25k variants in 1 minute comes down to 2.4 ms per shader variant, which seems reasonable.

The shaders that get selected are all that are linked in the scene and all in resources. The variants depend on how they are defined:

  • multi_compile, always include all variants
  • shader_feature, only include the variants used in the scene/materials

If you are using some custom shaders, you might want to change some multi_compile to shader_feature. More about that here:

To use a ShaderVariantCollection, you should warmup those instead of using Shader.WarmupAllShaders:

2 Likes

To use a ShaderVariantCollection, you should warmup those instead of using Shader.WarmupAllShaders:

Thanks a lot, thats what I did. SteamVR had a warmup for all shaders in it’s code, I commented that out and added my own shader asset under Graphic settings. My load times are around 3 seconds now!

Thanks a lot mate!

That’s good to know actually. I’m trying to avoid specific VR plugins, but Unity 5.6 VR isn’t up for that in terms of tracking information. 2017.1 seems a lot better, but we haven’t migrated there yet.

If you wanna use the Loadlevel Method, it’s in there