Quick answer: Switch multi_compile to multi_compile_local in your shaders so keywords do not consume the global budget. Audit URP/HDRP unused features and disable them to free slots. Use shader_feature_local when keywords are material-driven rather than runtime-toggled.
Here is how to fix Unity emitting Maximum number of shader keywords exceeded errors when you add another shader feature. The error appears in the console; some materials render incorrectly. Each project shares a global keyword budget; once exhausted, new keywords get dropped silently or emit errors.
The Symptom
Console error: Maximum number of shader keywords exceeded! Keyword 'X' is dropped. Shaders that depend on the dropped keyword render with the wrong variant. Often appears after adding a new third-party shader pack.
What Causes This
Too many global keywords. Unity caps global keyword count (256 historically, raised to 384+ in recent versions). Custom shaders + URP/HDRP defaults can blow past it.
multi_compile instead of local. multi_compile declares global keywords. multi_compile_local declares per-shader, not consuming global budget.
Forgotten keywords. Unused keywords still count. Cleaning shader source removes them.
The Fix
Step 1: Convert multi_compile to local.
// Before
#pragma multi_compile _WIND_ON _WIND_OFF
// After
#pragma multi_compile_local _WIND_ON _WIND_OFF
Local keywords stay scoped to this shader. Material code still toggles them via material.EnableKeyword.
Step 2: Use shader_feature for material-time choices.
// Compile-time choice baked into material asset
#pragma shader_feature_local _NORMALMAP _NORMALMAP_OFF
shader_feature variants are only included if at least one material uses them, saving build size and runtime budget.
Step 3: Audit URP/HDRP features. Open the URP/HDRP Asset and disable unused features (additional lights, baked shadows for unused light types, post-processing volumes you do not use). Each feature contributes keywords.
Step 4: Inspect declared keywords.
using UnityEngine.Rendering;
void ListGlobalKeywords()
{
foreach (var kw in Shader.globalKeywords)
Debug.Log(kw.name);
Debug.Log($"Total enabled: {Shader.globalKeywords.Length}");
}
Helps identify a chatty subsystem.
Step 5: Remove unused keywords from third-party shaders. If a shader pack declares _GLITCH_MODE, _RAINBOW, etc. you never use, edit the shader to drop the multi_compile lines. Or fork a stripped version.
Project-wide Keyword Budget
Unity 2023+ raised the budget to 384 globals plus 65k locals. If you still hit limits, your project has substantial shader feature usage; the only fix is reducing total declared keywords through audits and stripping.
“_local everything you can. shader_feature for material choices. Audit URP/HDRP. Free the global slots.”
Related Issues
For shader stripping in builds, see AssetBundle Shader Stripped. For variant collection, see Shader Variant Collection.
_local keywords. shader_feature for materials. Audit URP. Errors stop.