What Can I Disable?

beginner tasks

Shader Control · Quick Start

Shader Control lists every shader and keyword in your build, but it cannot know which features your game really uses, so that decision is yours. The best order is to start with the shaders that have the most variants and check whether your game needs each of them at all, and then look at the keywords of the heaviest shaders that you keep. This page shows how to do both safely, step by step, and how to undo a change if something stops working.

Start with whole shaders

Unity compiles each shader into many versions, called variants, and each variant adds build time and build size. Open the Build View, set Sort By to Shader Variant Count and look at the shaders at the top of the list. Before looking at their keywords, check whether your game needs each of those shaders at all. Many assets from the Asset Store come with a large variety of shaders, for example for their demo scenes or for features you never use, and some of them can end up in your build even if your game does not use them. Removing a whole shader removes all its variants at once, so this step alone can save a lot of build time.

Then you can look at the keywords of the heaviest shaders that are left. The step by step guide below covers both.

What a keyword does

A keyword turns one feature of a shader on or off, for example normal maps, emission or soft shadows. Unity compiles a separate variant of the shader for each combination of keywords, so a shader with many keywords can produce thousands of variants.

Removing a keyword that nothing uses saves build time and does no harm. Removing a keyword that your game uses makes that feature stop working in the build, for example a material loses its normal map or the shadows disappear. The Build View never changes your project files, so you can always put a keyword back.

The three kinds of keywords

KindWhat turns it onExamplesCan I remove it?
Material keywordsAn option in the material inspector, like a normal map slot or an emission toggle._NORMALMAP, _EMISSION, _ALPHATEST_ONYes, when no material in your build uses that option. Step 7 below shows how to check it.
Render pipeline keywordsUnity itself while the game runs, depending on your URP or HDRP settings, your lights and your quality levels._MAIN_LIGHT_SHADOWS, _ADDITIONAL_LIGHTS, _SHADOWS_SOFT, LIGHTMAP_ON, FOG_EXP2Only when your game never uses that feature, in any quality level or platform. If you are not sure, keep them.
Keywords set by scriptsThe scripts of an asset, for example when you change a quality option in one of its components.Usually keywords that start with the prefix of that assetCheck the documentation of that asset or ask its author.

Render pipeline keywords and keywords set by scripts never appear in materials, so an empty material list does not prove that they are unused.

Step by step

  1. Back up your project or commit it to version control.
  2. Open Shader Control from Assets > Browse Shaders... and select the Build View tab.
  3. Click Quick Build, then build your project as usual (File > Build Profiles in Unity 6, File > Build Settings in older versions). Shaders show in pink in this special build, which is normal. When it finishes, the Build View lists every shader and keyword that went into your build.
  4. Set Sort By to Shader Variant Count. Each shader shows its number of keywords and variants next to its name, and the shaders at the top of the list cost the most build time, so work on those first and leave the rest alone.
  5. For each shader at the top, check first whether your game uses it. Expand the shader and click Show In Project View, then expand the shader there and click List Materials to see the materials that use it. If those materials only belong to the demo scenes or examples of an asset, your game probably does not need that shader. If the shader is not listed in the Project View, set Sort By to Variants Count, untick Hide read-only/internal shaders, tick Force scan all shaders and click Scan Project Folders. If there is no List Materials button, no material in your project uses that shader, but the scripts of its asset may still use it, so keep it if you use the features of that asset. Shaders marked as internal belong to Unity, so keep them.
  6. Back in the Build View, uncheck Include next to the name of each shader your game does not need. If the shader is in the Always Included Shaders list of the Graphics settings, Shader Control asks to remove it from that list, so click Yes, because Unity always includes the shaders of that list in the build.
  7. Now expand the heaviest shaders that you keep to see their keywords, each one with an Include checkbox, and find the kind of each keyword in the table above. In the material list of the Project View, the materials that use each keyword appear under it, so a material keyword with no materials under it is a good candidate to remove. Uncheck Include next to the keywords you decided to remove, and change only a few at a time.
  8. Build again as usual, this time without Quick Build, and test the build, looking at the objects that used the shaders you removed and at the features those keywords controlled.
  9. If something looks wrong or is missing, check Include again for the last shaders or keywords you removed and build again.
  10. When you are happy with the result, click Save in the Configuration box to keep these settings. Load brings them back and Reset removes all exclusions.

Unity already leaves out of the build the keywords declared with shader_feature that no material uses. That is why a keyword that no material uses can still appear in the Build View: it is usually declared with multi_compile, and those keywords are where most of the savings are.

Objects that use an excluded shader will not render correctly in the build, so remove a whole shader only when you are sure your game never uses it.

What about the Project View?

The Project View changes the shader files themselves. When you uncheck a keyword there and click Save, Shader Control edits the shader and keeps a backup copy that Restore brings back. You do not need it to reduce build times, because the Build View does that without touching any file. If you use it, keep these points in mind:

  • Read-only shaders, such as the ones inside Unity packages, and Shader Graph shaders cannot be edited there. Use the Build View for them.
  • Updating an asset can overwrite its shaders and bring the keywords back.
  • To clean up your project, tick List shaders not used in last build to see the shaders that did not go into your last build. They add no build time, but you can remove the ones you do not need from the project with the Delete button that appears when you expand them. This cannot be undone, so make a backup first, and if you build for more than one platform, keep in mind that this list only knows about your last build.
  • Clean All Materials only removes from your materials the keywords you have already disabled in the Project View. If you have not disabled any keyword there, it does nothing, so there is no need to press it.

Quick rules

  • If you are not sure about a shader or a keyword, keep it.
  • Start with the few shaders at the top of the Build View, sorted by variant count, and check first whether your game needs them at all.
  • Change a few shaders or keywords at a time, then build and test.
  • Ask the author of an asset before removing the keywords of its shaders.

Next steps

Learn more about how shader keywords work, or read the FAQ.

Was this page helpful?