Skip to content

Screen Coordinates Override, Move Stripping To Global Settings #7121

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 @@ -119,7 +119,6 @@ This section allows you to fine-tune global post-processing settings.
| __Grading Mode__ | Select the [color grading](https://docs.unity3d.com/Manual/PostProcessing-ColorGrading.html) mode to use for the Project.<br />&#8226; __High Dynamic Range__: This mode works best for high precision grading similar to movie production workflows. Unity applies color grading before tonemapping.<br />&#8226; __Low Dynamic Range__: This mode follows a more classic workflow. Unity applies a limited range of color grading after tonemapping. |
| __LUT Size__ | Set the size of the internal and external [look-up textures (LUTs)](https://docs.unity3d.com/Manual/PostProcessing-ColorGrading.html) that the Universal Render Pipeline uses for color grading. Higher sizes provide more precision, but have a potential cost of performance and memory use. You cannot mix and match LUT sizes, so decide on a size before you start the color grading process.<br />The default value, **32**, provides a good balance of speed and quality. |
| __Fast sRGB/Liner Conversions__ | Select this option to use faster, but less accurate approximation functions when converting between the sRGB and Linear color spaces.|
| __Screen Coordinates Override__ | Select this option to allow cameras to use Screen Coordinates Override.|
| __Volume Update Mode__ | Select how Unity updates Volumes: every frame or when triggered via scripting. In the Editor, Unity updates Volumes every frame when not in the Play mode.|


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ The check boxes in this section define which shader variants Unity strips when y
| 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. |
| Strip Screen Coord Override Variants | When enabled, Unity strips Screen Coordinates Override shader variants in Player builds. |
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class SerializedUniversalRenderPipelineGlobalSettings : ISerializedRenderPipelin
public SerializedProperty stripDebugVariants;
public SerializedProperty stripUnusedPostProcessingVariants;
public SerializedProperty stripUnusedVariants;
public SerializedProperty stripScreenCoordOverrideVariants;

public SerializedUniversalRenderPipelineGlobalSettings(SerializedObject serializedObject)
{
Expand Down Expand Up @@ -52,6 +53,7 @@ public SerializedUniversalRenderPipelineGlobalSettings(SerializedObject serializ
stripDebugVariants = serializedObject.FindProperty("m_StripDebugVariants");
stripUnusedPostProcessingVariants = serializedObject.FindProperty("m_StripUnusedPostProcessingVariants");
stripUnusedVariants = serializedObject.FindProperty("m_StripUnusedVariants");
stripScreenCoordOverrideVariants = serializedObject.FindProperty("m_StripScreenCoordOverrideVariants");
shaderVariantLogLevel = serializedObject.FindProperty("m_ShaderVariantLogLevel");
exportShaderVariants = serializedObject.FindProperty("m_ExportShaderVariants");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ static void OnContextClickLightLayerNames(Vector2 position, SerializedUniversalR
EditorGUILayout.PropertyField(universalRenderPipelineGlobalSettings.stripDebugVariants, Styles.stripDebugVariantsLabel);
EditorGUILayout.PropertyField(universalRenderPipelineGlobalSettings.stripUnusedPostProcessingVariants, Styles.stripUnusedPostProcessingVariantsLabel);
EditorGUILayout.PropertyField(universalRenderPipelineGlobalSettings.stripUnusedVariants, Styles.stripUnusedVariantsLabel);
EditorGUILayout.PropertyField(universalRenderPipelineGlobalSettings.stripScreenCoordOverrideVariants, Styles.stripScreenCoordOverrideVariants);
}
}))),
CED.Group((serialized, owner) => EditorGUILayout.Space())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ internal class Styles
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 GUIContent stripScreenCoordOverrideVariants = EditorGUIUtility.TrTextContent("Strip Screen Coord Override Variants", "Controls whether Screen Coordinates Override shader variants are stripped.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ enum ShaderFeatures
ScreenSpaceOcclusionAfterOpaque = (1 << 28),
AdditionalLightsKeepOffVariants = (1 << 29),
ShadowsKeepOffVariants = (1 << 30),
ScreenCoordOverride = (1 << 31),
}

[Flags]
Expand Down Expand Up @@ -359,6 +358,11 @@ bool StripUnusedFeatures(ShaderFeatures features, Shader shader, ShaderSnippetDa
return true;
}

if (globalSettings != null && globalSettings.stripScreenCoordOverrideVariants && compilerData.shaderKeywordSet.IsEnabled(m_ScreenCoordOverride))
{
return true;
}

var stripUnusedVariants = UniversalRenderPipelineGlobalSettings.instance?.stripUnusedVariants == true;
var stripTool = new StripTool<ShaderFeatures>(features, shader, snippetData, compilerData.shaderKeywordSet, stripUnusedVariants);

Expand Down Expand Up @@ -506,9 +510,6 @@ bool StripUnusedFeatures(ShaderFeatures features, Shader shader, ShaderSnippetDa
m_DecalNormalBlendHigh, ShaderFeatures.DecalNormalBlendHigh))
return true;

if (stripTool.StripMultiCompile(m_ScreenCoordOverride, ShaderFeatures.ScreenCoordOverride))
return true;

return false;
}

Expand Down Expand Up @@ -932,9 +933,6 @@ private static ShaderFeatures GetSupportedShaderFeatures(UniversalRenderPipeline
if (pipelineAsset.useFastSRGBLinearConversion)
shaderFeatures |= ShaderFeatures.UseFastSRGBLinearConversion;

if (pipelineAsset.useScreenCoordOverride)
shaderFeatures |= ShaderFeatures.ScreenCoordOverride;

if (pipelineAsset.supportsLightLayers)
shaderFeatures |= ShaderFeatures.LightLayers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ internal class SerializedUniversalRenderPipelineAsset
public SerializedProperty colorGradingLutSize { get; }
public SerializedProperty useFastSRGBLinearConversion { get; }

public SerializedProperty useScreenCoordOverride { get; }

#if ADAPTIVE_PERFORMANCE_2_0_0_OR_NEWER
public SerializedProperty useAdaptivePerformance { get; }
#endif
Expand Down Expand Up @@ -136,8 +134,6 @@ public SerializedUniversalRenderPipelineAsset(SerializedObject serializedObject)

useFastSRGBLinearConversion = serializedObject.FindProperty("m_UseFastSRGBLinearConversion");

useScreenCoordOverride = serializedObject.FindProperty("m_UseScreenCoordOverride");

#if ADAPTIVE_PERFORMANCE_2_0_0_OR_NEWER
useAdaptivePerformance = serializedObject.FindProperty("m_UseAdaptivePerformance");
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,6 @@ static void DrawPostProcessing(SerializedUniversalRenderPipelineAsset serialized
EditorGUILayout.HelpBox(Styles.colorGradingLutSizeWarning, MessageType.Warning);

EditorGUILayout.PropertyField(serialized.useFastSRGBLinearConversion, Styles.useFastSRGBLinearConversion);

EditorGUILayout.PropertyField(serialized.useScreenCoordOverride, Styles.useScreenCoordOverride);
}

static void DrawPostProcessingAdditional(SerializedUniversalRenderPipelineAsset serialized, Editor ownerEditor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ internal static class Styles
public static string colorGradingLutSizeWarning = "The minimal recommended LUT size for the high dynamic range color grading mode is 32. Using lower values will potentially result in color banding and posterization effects.";
public static GUIContent volumeFrameworkUpdateMode = EditorGUIUtility.TrTextContent("Volume Update Mode", "Select how Unity updates Volumes: every frame or when triggered via scripting. In the Editor, Unity updates Volumes every frame when not in the Play mode.");

public static GUIContent useScreenCoordOverride = EditorGUIUtility.TrTextContent("Screen Coordinates Override", "Allow cameras to use Screen Coordinates Override.");

// Adaptive performance settings
public static GUIContent useAdaptivePerformance = EditorGUIUtility.TrTextContent("Use adaptive performance", "Allows Adaptive Performance to adjust rendering quality during runtime");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ public partial class UniversalRenderPipelineAsset : RenderPipelineAsset, ISerial
[SerializeField] ColorGradingMode m_ColorGradingMode = ColorGradingMode.LowDynamicRange;
[SerializeField] int m_ColorGradingLutSize = 32;
[SerializeField] bool m_UseFastSRGBLinearConversion = false;
[SerializeField] bool m_UseScreenCoordOverride = false;

// Deprecated settings
[SerializeField] ShadowQuality m_ShadowType = ShadowQuality.HardShadows;
Expand Down Expand Up @@ -1130,14 +1129,6 @@ public bool useFastSRGBLinearConversion
get { return m_UseFastSRGBLinearConversion; }
}

/// <summary>
/// Returns true if cameras may use Screen Coordinates Override.
/// </summary>
public bool useScreenCoordOverride
{
get { return m_UseScreenCoordOverride; }
}

/// <summary>
/// Set to true to allow Adaptive performance to modify graphics quality settings during runtime.
/// Only applicable when Adaptive performance package is available.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ internal void ResetRenderingLayerNames()

[SerializeField] bool m_StripUnusedVariants = true;

[SerializeField] bool m_StripScreenCoordOverrideVariants = true;

/// <summary>
/// Controls whether debug display shaders for Rendering Debugger are available in Player builds.
/// </summary>
Expand All @@ -344,6 +346,11 @@ internal void ResetRenderingLayerNames()
/// </summary>
public bool stripUnusedVariants { get => m_StripUnusedVariants; set { m_StripUnusedVariants = value; } }

/// <summary>
/// Controls whether Screen Coordinates Override shader variants are automatically stripped.
/// </summary>
public bool stripScreenCoordOverrideVariants { get => m_StripScreenCoordOverrideVariants; set => m_StripScreenCoordOverrideVariants = value; }

#endregion
}
}