Version: 2022.1
Shader variant stripping
Shader loading

Shader variant collections

A shaderA program that runs on the GPU. More info
See in Glossary
variant collection is effectively a list of shader variantsA verion of a shader program that Unity generates according to a specific combination of shader keywords and their status. A Shader object can contain multiple shader variants. More info
See in Glossary
. Use shader variant collections to prewarm shader variants, or to ensure that shader variants that are required at runtime but not referenced in a sceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary
are not excluded (“stripped”) from your build.

Creating a shader variant collection asset

You can create a shader variant collection asset in the following ways:

  • In the Create Asset menu, choose Shader > Shader Variant Collection.
  • The Unity Editor can track which shader variants your application uses when it runs, and automatically create a shader variant collection asset that contains them. For more information, see Graphics Settings: Shader loading.

Viewing and editing a shader variant collection

Shader variant collection inspector
Shader variant collection inspector

When you select a shader variant collection asset in your project, you can view and edit it in the InspectorA Unity window that displays information about the currently selected GameObject, asset or project settings, allowing you to inspect and edit the values. More info
See in Glossary
.

Use the controls to build a list of Pass types and shader keyword combinations to load in advance.

You can also configure a shader variant collection asset using the ShaderVariantCollection API.

Prewarming a shader variant collection

To avoid visible stalls at performance-intensive times, Unity can ask the graphics driver to create GPU representations of shader variants before they are first needed. This is called prewarming. For more information on prewarming the shader variants in a shader variant collection, see Shader loading: Prewarming shader variants.

Shader variant stripping
Shader loading
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961