Version: Unity 6.6 Alpha (6000.6)
Language : English
Reducing shader variants in URP
Strip shader variants in URP

Check how many shader variants your build has in URP

Use logging to check how many shaderA program that runs on the GPU. More info
See in Glossary
variants Unity compiles if you use the Universal Render PipelineA series of operations that take the contents of a Scene, and displays them on a screen. Unity lets you choose from pre-built render pipelines, or write your own. More info
See in Glossary
(URP).

Note: For more methods you can use to check how many shader variants you have, refer to Check how many shader variants you have.

To log how many variants Unity compiles and strips in total in URP, follow these steps:

  1. Open the Graphics settings window.
  2. Open the URP tab.
  3. In the Additional Shader Stripping Settings section, select a Shader Variant Log Level other than Disabled.
  4. From the main menu, select File > Build Profiles.
  5. Enable Development BuildA development build includes debug symbols and enables the Profiler. More info
    See in Glossary
    .
  6. Build your project.

Unity logs the shader variant information to the following locations:

  • The Console windowA Unity Editor window that shows errors, warnings and other messages generated by Unity, or your own scripts. More info
    See in Glossary
  • The Editor.log log file. Search for the section that begins with Shader Stripping. For the location of Editor.log, refer to log files.

For each shader, Unity uses the format Total=<Number of variants in build>/<Total number of variants>(<Percentage in build>). For example, the following log indicates that Unity kept 8 of the 39 variants of the Lit shader, including 1 of the 6 vertex shader variants of the ForwardLit shader pass:

Universal Render Pipeline/Lit - Total=8/39(20.51%)
- ForwardLit (ScriptableRenderPipeline) (SubShader: 0) (ShaderType: Vertex) - Total=1/6(16.67%) - Time=0.0691ms
...

To export the information in JSON format, follow these steps:

  1. In the Graphics settings window, open the URP tab.
  2. In the Additional Shader Stripping Settings section, enable Export Shader Variants.
  3. Build your project.
  4. In your project folder, open the Temp/graphics-settings-stripping.json and Temp/shader-stripping.json files.

Additional resources

Reducing shader variants in URP
Strip shader variants in URP