Quick answer: Open the Boolean keyword’s settings in Shader Graph. Set Scope = Local, Definition = Shader Feature. Now variants strip if no Material in the project enables that combination. Global + Multi Compile always builds every combination.
You add a USE_DETAIL_TEX keyword to a Shader Graph. Build doubles in shader variants. The default Global scope always builds both states.
The Symptom
Build Report shows shader variant counts climbing per keyword added. Even when only one material uses one state.
The Fix
In Shader Graph, click the Boolean keyword in the Blackboard. Inspector:
Reference: _USE_DETAIL_TEX
Scope: Local // per-material
Definition: Shader Feature // strippable
Default: Off
Local + Shader Feature emits #pragma shader_feature_local _USE_DETAIL_TEX. Variants build only if a Material in the project uses that state.
Multi Compile When You Need It
If you toggle the keyword via Material.EnableKeyword/DisableKeyword at runtime (rather than per-material in the editor), use Multi Compile. The cost is per-build, but you get runtime flexibility.
Global Scope
Global keywords (e.g. _RAIN_ON) affect every shader globally via Shader.EnableKeyword. Use sparingly because they’re always built and contribute to the global keyword cap.
Verifying
Build the project. Check Build Report → Shader Variants → filter by your shader. After switching to Local + Shader Feature, variant count should drop. If two materials use opposite states, you still get two variants (correct).
“Local + Shader Feature for per-material toggles. Variants strip.”
Related Issues
For ShaderLab keyword limit, see keyword limit. For SRP Batcher, see SRP Batcher.
Local Shader Feature. Strippable.