docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Reduce shader variants

    The standard shaders in the High Definition Render Pipeline (HDRP) support a lot of different features, which can mean Unity compiles a lot of shader variants. To avoid your build growing too big, HDRP automatically excludes ('strips') shader variants for features you don't use in your build.

    You can change settings to make Unity strip more variants. This speeds up builds, and reduces memory usage and file sizes.

    If you want to examine the code that strips shaders in HDRP, see the following files:

    • Editor/Material/Lit/LitShaderPreprocessor.cs
    • Editor/Material/BaseShaderPreprocessor.cs
    • Editor/BuildProcessors/HDRPPreprocessShaders.cs

    The files use the IPreprocessShaders API.

    Check how many shader variants your build has

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

    1. Open the Graphics settings window.
    2. In the Additional Shader Stripping Settings section, select a logging level other than Disabled.
    3. Build your project.
    4. To see the logged information, open the Editor.log log file and search for ShaderStrippingReport. For the location of Editor.log, refer to log files.

    To log more detailed shader variant information, follow these steps:

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

    For more information, refer to the following in the Unity User Manual:

    • Check how many shader variants you have
    • Shader variant stripping

    Strip feature shader variants

    If you disable a feature, HDRP strips any shader variants where the feature is enabled.

    You must disable the feature in all the HDRP assets in your build. Unity includes in your build any HDRP asset you set as a Render Pipeline Asset in a Quality Settings level.

    Feature How to disable the feature
    Built-in fog In the Graphics settings window, in the Shader Stripping section, set Fog Modes to Custom, then disable Linear, Exponential, Exponential Squared. This strips built-in fog shaders that HDRP doesn't use.
    Cameras generate additional Arbitrary Output Variables (AOV) images In the HDRP asset, in the Rendering section, disable Runtime AOV API.
    Cameras use both Deferred and Forward rendering In the HDRP asset, in the Rendering section, set Lit Shader Mode to Deferred. This creates fewer variants than Forward or Both.
    Decals In the HDRP asset, disable Decals.
    Distortion In the HDRP asset, in the Material section, disable Distortion.
    GPU instancing variants you don't use In the Graphics settings window, in the Shader Stripping section, set Instancing Variants to Strip Unused.
    Holes in Terrain In the HDRP asset, in the Rendering section, disable Terrain Holes.
    Lightmaps HDRP doesn't use In the Graphics settings window, in the Shader Stripping section, set Lightmap Modes to Custom, and enable only the Baked Directional mode. This strips lightmap shader variants that HDRP doesn't use.
    Material Quality in Shader Graph shaders In the HDRP asset, in the Material section, disable any Available Material Quality levels you don't need. This only has an effect if you use the Material Quality Node in Shader Graph.
    Motion vectors In the HDRP asset, in the Rendering section, disable Motion Vectors. You shouldn't disable this unless your Scenes are fully static with no deformation.
    Realtime raytracing You can do one of the following in the HDRP asset, in the Rendering section:
    • Disable Realtime Raytracing.
    • Enable Realtime Raytracing, but set Supported Ray Tracing Mode to Performance.
    Performance mode doesn't support path tracing.
    Rendering Layers In the HDRP asset, in the Lighting section, disable Light Layers. This only has an effect if you also set Lit Shader Mode to Deferred.
    Subsurface scattering In the HDRP asset, in the Material section, disable Subsurface Scattering. This only removes a small number of variants, so you should only disable this if you need to.
    Transitions between GameObject level of detail (LOD) levels In the HDRP asset, in the Rendering section, disable Dithering Cross-fade.
    Transparent back-face render passes In the HDRP asset, in the Rendering section, disable Transparent Backface. Unity might incorrectly render transparent objects.
    Transparent depth render postpasses In the HDRP asset, in the Rendering section, disable Transparent Depth Postpass. Unity might incorrectly render transparent objects.
    Transparent depth render prepasses In the HDRP asset, in the Rendering section, disable Transparent Depth Prepass. Unity might incorrectly render transparent objects and screen space reflections.

    Strip XR and VR shader variants

    If you don't use XR or VR, you can disable the XR and VR modules. This allows HDRP to strip XR and VR related shader variants from its standard shaders.

    Strip debug shader variants

    If you don't need to use the Rendering Debugger in a development build, you can disable Runtime Debug Shaders under Miscellaneous in the Graphics settings window. This strips any debug shader variants that the Rendering Debugger uses.

    You don't need to do this if you disable Development Build in your Build Settings.

    Features that affect build time but not variants

    If you disable the following features, Unity doesn't reduce the number of variants but your build time will be faster.

    Feature How to disable the feature
    Decal layers In the HDRP asset, in the Decals section, disable Layers.
    High-quality area shadows In the HDRP asset, in the Lighting section, set Area Shadow Filtering Quality to Low.
    High-quality shadows In the HDRP asset, in the Lighting section, set Shadow Filtering Quality to Low.
    Light Probe system In the HDRP asset, in the Lighting section, set Light Probe System to Light Probe Groups (Legacy).
    Shadowmasks In the HDRP asset, in the Lighting section, disable Shadowmask.

    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • Check how many shader variants your build has
    • Strip feature shader variants
    • Strip XR and VR shader variants
    • Strip debug shader variants
    • Features that affect build time but not variants
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)