Shader Variants
Compiled versions of one shader
Also known as: Shader keywords · Shader stripping · Shader permutations · Shader variant collection
Definition
A shader variant is one compiled version of a shader for a particular combination of keywords, such as fog on or off, shadows on or off, or normal map on or off. A single shader with many keywords can produce thousands of variants, which slows builds, increases build size and can cause hitches when a variant first compiles at runtime. Unity strips variants it can prove are unused, and you can reduce the rest yourself.
In production
Avoid adding keywords to shaders without a reason, use shader_feature rather than multi_compile for options that are decided in the editor, and check which variants a build includes. Shader Graph keywords such as Boolean and Enum keywords create variants too, so use them sparingly. Prewarming with a Shader Variant Collection stops first-use stutters. The same problem exists in Unreal as shader permutations.