Skip to content

[2021.2] Shader Stripping Improvements #5563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2ec995e51a6e251468d2a3fd8a686257, type: 3}
m_Name: UniversalRenderPipelineGlobalSettings
m_EditorClassIdentifier:
k_AssetVersion: 1
k_AssetPreviousVersion: 1
k_AssetVersion: 2
lightLayerName0: Light Layer default
lightLayerName1: Light Layer 1
lightLayerName2: Light Layer 2
Expand All @@ -22,3 +21,7 @@ MonoBehaviour:
lightLayerName5: Light Layer 5
lightLayerName6: Light Layer 6
lightLayerName7: Light Layer 7
m_StripDebugVariants: 1
m_StripUnusedPostProcessingVariants: 1
m_StripUnusedVariants: 1
supportRuntimeDebugDisplay: 0
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2ec995e51a6e251468d2a3fd8a686257, type: 3}
m_Name: UniversalRenderPipelineGlobalSettings
m_EditorClassIdentifier:
k_AssetVersion: 1
k_AssetPreviousVersion: 1
k_AssetVersion: 2
lightLayerName0: Light Layer default
lightLayerName1: Light Layer 1
lightLayerName2: Light Layer 2
Expand All @@ -22,3 +21,7 @@ MonoBehaviour:
lightLayerName5: Light Layer 5
lightLayerName6: Light Layer 6
lightLayerName7: Light Layer 7
m_StripDebugVariants: 1
m_StripUnusedPostProcessingVariants: 1
m_StripUnusedVariants: 1
supportRuntimeDebugDisplay: 0
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2ec995e51a6e251468d2a3fd8a686257, type: 3}
m_Name: UniversalRenderPipelineGlobalSettings
m_EditorClassIdentifier:
k_AssetVersion: 1
k_AssetPreviousVersion: 1
k_AssetVersion: 2
lightLayerName0: Light Layer default
lightLayerName1: Light Layer 1
lightLayerName2: Light Layer 2
Expand All @@ -22,3 +21,7 @@ MonoBehaviour:
lightLayerName5: Light Layer 5
lightLayerName6: Light Layer 6
lightLayerName7: Light Layer 7
m_StripDebugVariants: 1
m_StripUnusedPostProcessingVariants: 1
m_StripUnusedVariants: 1
supportRuntimeDebugDisplay: 0
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ EditorBuildSettings:
- enabled: 1
path: Assets/Scenes/152_Lighting_EnlightenEnvironment.unity
guid: fb8f8e7cc18a5314f8d66d2ddfbfbaec
- enabled: 1
path: Assets/Scenes/153_Lighting_EnlightenTerrain.unity
guid: 677cb6424a7fe3947974395b6c3d70a4
- enabled: 1
path: Assets/Scenes/200_DepthDeferred.unity
guid: 3bbe19bef8dcc4e65b7aaa710c4114c6
Expand Down
2 changes: 2 additions & 0 deletions com.unity.render-pipelines.universal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- XR: Added Late Latching support to reduce VR latency (Quest).
- Fixed incorrect shadow fade in deferred rendering mode.
- Added a help button on material editor to show the shader documentation page
- URP global setting for stripping post processing shader variants.
- URP global setting for stripping off shader variants.

### Changed
- Moved fog evaluation from vertex shader to pixel shader. This improves rendering of fog for big triangles and fog quality. This can change the look of the fog slightly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ The section contains the following settings.

Use this section to define the names of Light Layers. Light Layers only work with 3D Renderers.

## Miscellaneous
## Shader Stripping

The check boxes in this section define which shader variants Unity strips when you build the Player.

| **Property** | **Description** |
| --------------------------| ------------------------------------------------------------ |
| Runtime Debug Shaders | When disabled, all debug display shader variants are removed when you build for the Unity Player. This decreases build time, but prevents the use of Rendering Debugger in Player builds. |
| Strip Debug Variants | When enabled, Unity strips all debug view shader variants when you build the Player. This decreases build time, but prevents the use of Rendering Debugger in Player builds. |
| Strip Unused Post Processing Variants | When enabled, Unity assumes that the Player does not create new [Volume Profiles](VolumeProfile.md) at runtime. With this assumption, Unity only keeps the shader variants that the existing [Volume Profiles](VolumeProfile.md) use, and strips all the other variants. Unity keeps shader variants used in Volume Profiles even if the Scenes in the project do not use the Profiles. |
| Strip Unused Variants | When enabled, Unity performs shader stripping in a more efficient way. This option reduces the amount of shader variants in the Player by a factor of 2 if the project uses the following URP features:<ul><li>Light Layers</li><li>Native Render Pass</li><li>Reflection Probe Blending</li><li>Reflection Probe Box Projection</li><li>SSAO Renderer Feature</li><li>Decal Renderer Feature</li><li>Certain post-processing effects</li></ul>Disable this option only if you see issues in the Player. |
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ class SerializedUniversalRenderPipelineGlobalSettings
public SerializedProperty lightLayerName6;
public SerializedProperty lightLayerName7;

public SerializedProperty supportRuntimeDebugDisplay;
public SerializedProperty stripDebugVariants;
public SerializedProperty stripUnusedPostProcessingVariants;
public SerializedProperty stripUnusedVariants;

public SerializedUniversalRenderPipelineGlobalSettings(SerializedObject serializedObject)
{
Expand All @@ -44,7 +46,9 @@ public SerializedUniversalRenderPipelineGlobalSettings(SerializedObject serializ
lightLayerName6 = serializedObject.Find((UniversalRenderPipelineGlobalSettings s) => s.lightLayerName6);
lightLayerName7 = serializedObject.Find((UniversalRenderPipelineGlobalSettings s) => s.lightLayerName7);

supportRuntimeDebugDisplay = serializedObject.Find((UniversalRenderPipelineGlobalSettings s) => s.supportRuntimeDebugDisplay);
stripDebugVariants = serializedObject.FindProperty("m_StripDebugVariants");
stripUnusedPostProcessingVariants = serializedObject.FindProperty("m_StripUnusedPostProcessingVariants");
stripUnusedVariants = serializedObject.FindProperty("m_StripUnusedVariants");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal partial class UniversalGlobalSettingsPanelIMGUI
{
internal class Styles
{
public const int labelWidth = 220;
public const int labelWidth = 260;

public static readonly GUIContent lightLayersLabel = EditorGUIUtility.TrTextContent("Light Layer Names (3D)", "If the Light Layers feature is enabled in the URP Asset, Unity allocates memory for processing Light Layers. In the Deferred Rendering Path, this allocation includes an extra render target in GPU memory, which reduces performance.");
public static readonly GUIContent lightLayerName0 = EditorGUIUtility.TrTextContent("Light Layer 0", "The display name for Light Layer 0.");
Expand All @@ -25,8 +25,10 @@ internal class Styles
public static readonly GUIContent lightLayerName6 = EditorGUIUtility.TrTextContent("Light Layer 6", "The display name for Light Layer 6.");
public static readonly GUIContent lightLayerName7 = EditorGUIUtility.TrTextContent("Light Layer 7", "The display name for Light Layer 7.");

public static readonly GUIContent miscSettingsLabel = EditorGUIUtility.TrTextContent("Miscellaneous", "Miscellaneous settings");
public static readonly GUIContent supportRuntimeDebugDisplayContentLabel = EditorGUIUtility.TrTextContent("Runtime Debug Shaders", "When disabled, all debug display shader variants are removed when you build for the Unity Player. This decreases build time, but prevents the use of Rendering Debugger in Player builds.");
public static readonly GUIContent miscSettingsLabel = EditorGUIUtility.TrTextContent("Shader Stripping", "Shader Stripping settings");
public static readonly GUIContent stripDebugVariantsLabel = EditorGUIUtility.TrTextContent("Strip Debug Variants", "When disabled, all debug display shader variants are removed when you build for the Unity Player. This decreases build time, but prevents the use of Rendering Debugger in Player builds.");
public static readonly GUIContent stripUnusedPostProcessingVariantsLabel = EditorGUIUtility.TrTextContent("Strip Unused Post Processing Variants", "Controls whether strips automatically post processing shader variants based on VolumeProfile components. It strips based on VolumeProfiles in project and not scenes that actually uses it.");
public static readonly GUIContent stripUnusedVariantsLabel = EditorGUIUtility.TrTextContent("Strip Unused Variants", "Controls whether strip disabled keyword variants if the feature is enabled.");

public static readonly string warningUrpNotActive = "Project graphics settings do not refer to a URP Asset. Check the settings: Graphics > Scriptable Render Pipeline Settings, Quality > Render Pipeline Asset.";
public static readonly string warningGlobalSettingsMissing = "The Settings property does not contain a valid URP Global Settings asset. There might be issues in rendering. Select a valid URP Global Settings asset.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ static void DrawMiscSettings(SerializedUniversalRenderPipelineGlobalSettings ser

using (new EditorGUI.IndentLevelScope())
{
EditorGUILayout.PropertyField(serialized.supportRuntimeDebugDisplay, Styles.supportRuntimeDebugDisplayContentLabel);
EditorGUILayout.PropertyField(serialized.stripDebugVariants, Styles.stripDebugVariantsLabel);
EditorGUILayout.PropertyField(serialized.stripUnusedPostProcessingVariants, Styles.stripUnusedPostProcessingVariantsLabel);
EditorGUILayout.PropertyField(serialized.stripUnusedVariants, Styles.stripUnusedVariantsLabel);
}

EditorGUIUtility.labelWidth = oldWidth;
Expand Down
Loading