diff --git a/com.unity.render-pipelines.universal/CHANGELOG.md b/com.unity.render-pipelines.universal/CHANGELOG.md
index 242de9575d6..5ffcb15417c 100644
--- a/com.unity.render-pipelines.universal/CHANGELOG.md
+++ b/com.unity.render-pipelines.universal/CHANGELOG.md
@@ -4,6 +4,11 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
+## [Unreleased]
+
+### Added
+- Added option to enable/disable Adaptive Performance when it's package is available.
+
## [7.5.0] - 2020-06-08
Version Updated
diff --git a/com.unity.render-pipelines.universal/Documentation~/universalrp-asset.md b/com.unity.render-pipelines.universal/Documentation~/universalrp-asset.md
index f103ceb00fc..ace83b69545 100644
--- a/com.unity.render-pipelines.universal/Documentation~/universalrp-asset.md
+++ b/com.unity.render-pipelines.universal/Documentation~/universalrp-asset.md
@@ -16,6 +16,7 @@ In the URP, you can configure settings for:
- [__Shadows__](#shadows)
- [__Post-processing__](#post-processing)
- [__Advanced__](#advanced)
+- [__Adaptive Performance__](#adaptive-performance)
@@ -99,3 +100,13 @@ This section allows you to fine-tune less commonly changed settings, which impac
| __Mixed Lighting__ | Enable [Mixed Lighting](https://docs.unity3d.com/Manual/LightMode-Mixed.html), to tell the pipeline to include mixed lighting shader variants in the build. |
| __Debug Level__ | Set the level of debug information that the render pipeline generates. The values are:
**Disabled**: Debugging is disabled. This is the default.
**Profiling**: Makes the render pipeline provide detailed information tags, which you can see in the FrameDebugger. |
| __Shader Variant Log Level__ | Set the level of information about Shader Stripping and Shader Variants you want to display when Unity finishes a build. Values are:
**Disabled**: Unity doesn’t log anything.
**Only Universal**: Unity logs information for all of the [URP Shaders](shaders-in-universalrp.md).
**All**: Unity logs information for all Shaders in your build.
You can see the information in Console panel when your build has finished. |
+
+
+
+### Adaptive Performance
+
+This section appears if Adaptive Performance package is installed. It allows to change settings how Adaptive performance and render pipeline interact.
+
+| __Property__ | __Description__ |
+| ----------------------- | ------------------------------------------------------------ |
+| __Use adaptive performance__ | Allows Adaptive Performance to adjust rendering quality during runtime. |
\ No newline at end of file
diff --git a/com.unity.render-pipelines.universal/Editor/Unity.RenderPipelines.Universal.Editor.asmdef b/com.unity.render-pipelines.universal/Editor/Unity.RenderPipelines.Universal.Editor.asmdef
index d8b54213ce9..e720fbf5339 100644
--- a/com.unity.render-pipelines.universal/Editor/Unity.RenderPipelines.Universal.Editor.asmdef
+++ b/com.unity.render-pipelines.universal/Editor/Unity.RenderPipelines.Universal.Editor.asmdef
@@ -22,6 +22,11 @@
"name": "com.unity.postprocessing",
"expression": "2.0.0",
"define": "POST_PROCESSING_STACK_2_0_0_OR_NEWER"
+ },
+ {
+ "name": "com.unity.adaptiveperformance",
+ "expression": "2.0.0-preview.7",
+ "define": "ADAPTIVE_PERFORMANCE_2_0_0_OR_NEWER"
}
]
}
diff --git a/com.unity.render-pipelines.universal/Editor/UniversalRenderPipelineAssetEditor.cs b/com.unity.render-pipelines.universal/Editor/UniversalRenderPipelineAssetEditor.cs
index db0ef1ebcfd..92fda58676a 100644
--- a/com.unity.render-pipelines.universal/Editor/UniversalRenderPipelineAssetEditor.cs
+++ b/com.unity.render-pipelines.universal/Editor/UniversalRenderPipelineAssetEditor.cs
@@ -18,6 +18,7 @@ internal class Styles
public static GUIContent shadowSettingsText = EditorGUIUtility.TrTextContent("Shadows");
public static GUIContent postProcessingSettingsText = EditorGUIUtility.TrTextContent("Post-processing");
public static GUIContent advancedSettingsText = EditorGUIUtility.TrTextContent("Advanced");
+ public static GUIContent adaptivePerformanceText = EditorGUIUtility.TrTextContent("Adaptive Performance");
// General
public static GUIContent rendererHeaderText = EditorGUIUtility.TrTextContent("Renderer List", "Lists all the renderers available to this Render Pipeline Asset.");
@@ -71,6 +72,9 @@ internal class Styles
public static GUIContent debugLevel = EditorGUIUtility.TrTextContent("Debug Level", "Controls the level of debug information generated by the render pipeline. When Profiling is selected, the pipeline provides detailed profiling tags.");
public static GUIContent shaderVariantLogLevel = EditorGUIUtility.TrTextContent("Shader Variant Log Level", "Controls the level logging in of shader variants information is outputted when a build is performed. Information will appear in the Unity console when the build finishes.");
+ // Adaptive performance settings
+ public static GUIContent useAdaptivePerformance = EditorGUIUtility.TrTextContent("Use adaptive performance", "Allows Adaptive Performance to adjust rendering quality during runtime");
+
// Renderer List Messages
public static GUIContent rendererListDefaultMessage =
EditorGUIUtility.TrTextContent("Cannot remove Default Renderer",
@@ -93,6 +97,7 @@ internal class Styles
SavedBool m_ShadowSettingsFoldout;
SavedBool m_PostProcessingSettingsFoldout;
SavedBool m_AdvancedSettingsFoldout;
+ SavedBool m_AdaptivePerformanceFoldout;
SerializedProperty m_RendererDataProp;
SerializedProperty m_DefaultRendererProp;
@@ -137,6 +142,8 @@ internal class Styles
SerializedProperty m_ColorGradingMode;
SerializedProperty m_ColorGradingLutSize;
+ SerializedProperty m_UseAdaptivePerformance;
+
public override void OnInspectorGUI()
{
serializedObject.Update();
@@ -147,6 +154,9 @@ public override void OnInspectorGUI()
DrawShadowSettings();
DrawPostProcessingSettings();
DrawAdvancedSettings();
+#if ADAPTIVE_PERFORMANCE_2_0_0_OR_NEWER
+ DrawAdaptivePerformance();
+#endif
serializedObject.ApplyModifiedProperties();
}
@@ -159,6 +169,7 @@ void OnEnable()
m_ShadowSettingsFoldout = new SavedBool($"{target.GetType()}.ShadowSettingsFoldout", false);
m_PostProcessingSettingsFoldout = new SavedBool($"{target.GetType()}.PostProcessingSettingsFoldout", false);
m_AdvancedSettingsFoldout = new SavedBool($"{target.GetType()}.AdvancedSettingsFoldout", false);
+ m_AdaptivePerformanceFoldout = new SavedBool($"{target.GetType()}.AdaptivePerformanceFoldout", false);
m_RendererDataProp = serializedObject.FindProperty("m_RendererDataList");
m_DefaultRendererProp = serializedObject.FindProperty("m_DefaultRendererIndex");
@@ -203,6 +214,8 @@ void OnEnable()
m_ColorGradingMode = serializedObject.FindProperty("m_ColorGradingMode");
m_ColorGradingLutSize = serializedObject.FindProperty("m_ColorGradingLutSize");
+ m_UseAdaptivePerformance = serializedObject.FindProperty("m_UseAdaptivePerformance");
+
selectedLightRenderingMode = (LightRenderingMode)m_AdditionalLightsRenderingModeProp.intValue;
}
@@ -401,6 +414,20 @@ void DrawAdvancedSettings()
EditorGUILayout.EndFoldoutHeaderGroup();
}
+ void DrawAdaptivePerformance()
+ {
+ m_AdaptivePerformanceFoldout.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_AdaptivePerformanceFoldout.value, Styles.adaptivePerformanceText);
+ if (m_AdaptivePerformanceFoldout.value)
+ {
+ EditorGUI.indentLevel++;
+ EditorGUILayout.PropertyField(m_UseAdaptivePerformance, Styles.useAdaptivePerformance);
+ EditorGUI.indentLevel--;
+ EditorGUILayout.Space();
+ EditorGUILayout.Space();
+ }
+ EditorGUILayout.EndFoldoutHeaderGroup();
+ }
+
void DrawRendererListLayout(ReorderableList list, SerializedProperty prop)
{
list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
diff --git a/com.unity.render-pipelines.universal/Runtime/Data/UniversalRenderPipelineAsset.cs b/com.unity.render-pipelines.universal/Runtime/Data/UniversalRenderPipelineAsset.cs
index 70e982dd6a6..112bac9ed1d 100644
--- a/com.unity.render-pipelines.universal/Runtime/Data/UniversalRenderPipelineAsset.cs
+++ b/com.unity.render-pipelines.universal/Runtime/Data/UniversalRenderPipelineAsset.cs
@@ -190,6 +190,9 @@ public class UniversalRenderPipelineAsset : RenderPipelineAsset, ISerializationC
[SerializeField] bool m_MixedLightingSupported = true;
[SerializeField] PipelineDebugLevel m_DebugLevel = PipelineDebugLevel.Disabled;
+ // Adaptive performance settings
+ [SerializeField] bool m_UseAdaptivePerformance = false;
+
// Post-processing settings
#pragma warning disable 414 // 'field' is assigned but never used
[SerializeField] PostProcessingFeatureSet m_PostProcessingFeatureSet = PostProcessingFeatureSet.Integrated;
@@ -687,6 +690,16 @@ public int colorGradingLutSize
set { m_ColorGradingLutSize = Mathf.Clamp(value, k_MinLutSize, k_MaxLutSize); }
}
+ ///
+ /// Set to true to allow Adaptive performance to modify graphics quality settings during runtime.
+ /// Only applicable when Adaptive performance package is available.
+ ///
+ public bool useAdaptivePerformance
+ {
+ get { return m_UseAdaptivePerformance; }
+ set { m_UseAdaptivePerformance = value; }
+ }
+
public override Material defaultMaterial
{
get { return GetMaterial(DefaultMaterialType.Standard); }
diff --git a/com.unity.render-pipelines.universal/Runtime/Unity.RenderPipelines.Universal.Runtime.asmdef b/com.unity.render-pipelines.universal/Runtime/Unity.RenderPipelines.Universal.Runtime.asmdef
index 7fe353ecef5..0654e06edf2 100644
--- a/com.unity.render-pipelines.universal/Runtime/Unity.RenderPipelines.Universal.Runtime.asmdef
+++ b/com.unity.render-pipelines.universal/Runtime/Unity.RenderPipelines.Universal.Runtime.asmdef
@@ -3,7 +3,8 @@
"references": [
"GUID:d60799ab2a985554ea1a39cd38695018",
"GUID:df380645f10b7bc4b97d4f5eb6303d95",
- "GUID:ab67fb10353d84448ac887a7367cbda8"
+ "GUID:ab67fb10353d84448ac887a7367cbda8",
+ "GUID:7dbf32976982c98448af054f2512cb79"
],
"includePlatforms": [],
"excludePlatforms": [],
@@ -23,6 +24,11 @@
"expression": "0.0.1",
"define": "VISUAL_EFFECT_GRAPH_0_0_1_OR_NEWER"
},
+ {
+ "name": "com.unity.adaptiveperformance",
+ "expression": "2.0.0-preview.7",
+ "define": "ADAPTIVE_PERFORMANCE_2_0_0_OR_NEWER"
+ },
{
"name": "com.unity.modules.vr",
"expression": "1.0.0",
diff --git a/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs b/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs
index 3f9aa3ae673..a8d8cdcb2c2 100644
--- a/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs
+++ b/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs
@@ -228,6 +228,10 @@ public static void RenderSingleCamera(ScriptableRenderContext context, Camera ca
}
InitializeCameraData(camera, additionalCameraData, true, out var cameraData);
+#if ADAPTIVE_PERFORMANCE_2_0_0_OR_NEWER
+ if (asset.useAdaptivePerformance)
+ ApplyAdaptivePerformance(ref cameraData);
+#endif
RenderSingleCamera(context, cameraData, cameraData.postProcessEnabled);
}
@@ -274,6 +278,11 @@ static void RenderSingleCamera(ScriptableRenderContext context, CameraData camer
var cullResults = context.Cull(ref cullingParameters);
InitializeRenderingData(asset, ref cameraData, ref cullResults, anyPostProcessingEnabled, out var renderingData);
+#if ADAPTIVE_PERFORMANCE_2_0_0_OR_NEWER
+ if (asset.useAdaptivePerformance)
+ ApplyAdaptivePerformance(ref renderingData);
+#endif
+
renderer.Setup(context, ref renderingData);
renderer.Execute(context, ref renderingData);
}
@@ -375,6 +384,10 @@ static void RenderCameraStack(ScriptableRenderContext context, Camera baseCamera
#endif
UpdateVolumeFramework(baseCamera, baseCameraAdditionalData);
InitializeCameraData(baseCamera, baseCameraAdditionalData, !isStackedRendering, out var baseCameraData);
+#if ADAPTIVE_PERFORMANCE_2_0_0_OR_NEWER
+ if (asset.useAdaptivePerformance)
+ ApplyAdaptivePerformance(ref baseCameraData);
+#endif
RenderSingleCamera(context, baseCameraData, anyPostProcessingEnabled);
EndCameraRendering(context, baseCamera);
@@ -923,5 +936,71 @@ static void SetupPerFrameShaderConstants()
// Used when subtractive mode is selected
Shader.SetGlobalVector(PerFrameBuffer._SubtractiveShadowColor, CoreUtils.ConvertSRGBToActiveColorSpace(RenderSettings.subtractiveShadowColor));
}
+
+#if ADAPTIVE_PERFORMANCE_2_0_0_OR_NEWER
+ static void ApplyAdaptivePerformance(ref CameraData cameraData)
+ {
+ var noFrontToBackOpaqueFlags = SortingCriteria.SortingLayer | SortingCriteria.RenderQueue | SortingCriteria.OptimizeStateChanges | SortingCriteria.CanvasOrder;
+ if (AdaptivePerformance.AdaptivePerformanceRenderSettings.SkipFrontToBackSorting)
+ cameraData.defaultOpaqueSortFlags = noFrontToBackOpaqueFlags;
+
+ var MaxShadowDistanceMultiplier = AdaptivePerformance.AdaptivePerformanceRenderSettings.MaxShadowDistanceMultiplier;
+ cameraData.maxShadowDistance *= MaxShadowDistanceMultiplier;
+
+ var RenderScaleMultiplier = AdaptivePerformance.AdaptivePerformanceRenderSettings.RenderScaleMultiplier;
+ cameraData.renderScale *= RenderScaleMultiplier;
+
+ // TODO
+ if (!cameraData.isStereoEnabled)
+ {
+ cameraData.cameraTargetDescriptor.width = (int)(cameraData.camera.pixelWidth * cameraData.renderScale);
+ cameraData.cameraTargetDescriptor.height = (int)(cameraData.camera.pixelHeight * cameraData.renderScale);
+ }
+
+ var antialiasingQualityIndex = (int)cameraData.antialiasingQuality - AdaptivePerformance.AdaptivePerformanceRenderSettings.AntiAliasingQualityBias;
+ if (antialiasingQualityIndex < 0)
+ cameraData.antialiasing = AntialiasingMode.None;
+ cameraData.antialiasingQuality = (AntialiasingQuality)Mathf.Clamp(antialiasingQualityIndex, (int)AntialiasingQuality.Low, (int)AntialiasingQuality.High);
+ }
+ static void ApplyAdaptivePerformance(ref RenderingData renderingData)
+ {
+ if (AdaptivePerformance.AdaptivePerformanceRenderSettings.SkipDynamicBatching)
+ renderingData.supportsDynamicBatching = false;
+
+ var MainLightShadowmapResolutionMultiplier = AdaptivePerformance.AdaptivePerformanceRenderSettings.MainLightShadowmapResolutionMultiplier;
+ renderingData.shadowData.mainLightShadowmapWidth = (int)(renderingData.shadowData.mainLightShadowmapWidth * MainLightShadowmapResolutionMultiplier);
+ renderingData.shadowData.mainLightShadowmapHeight = (int)(renderingData.shadowData.mainLightShadowmapHeight * MainLightShadowmapResolutionMultiplier);
+
+ var MainLightShadowCascadesCountBias = AdaptivePerformance.AdaptivePerformanceRenderSettings.MainLightShadowCascadesCountBias;
+ renderingData.shadowData.mainLightShadowCascadesCount = Mathf.Clamp(renderingData.shadowData.mainLightShadowCascadesCount - MainLightShadowCascadesCountBias, 0, 4);
+
+ var shadowQualityIndex = AdaptivePerformance.AdaptivePerformanceRenderSettings.ShadowQualityBias;
+ for (int i = 0; i < shadowQualityIndex; i++)
+ {
+ if (renderingData.shadowData.supportsSoftShadows)
+ {
+ renderingData.shadowData.supportsSoftShadows = false;
+ continue;
+ }
+
+ if (renderingData.shadowData.supportsAdditionalLightShadows)
+ {
+ renderingData.shadowData.supportsAdditionalLightShadows = false;
+ continue;
+ }
+
+ if (renderingData.shadowData.supportsMainLightShadows)
+ {
+ renderingData.shadowData.supportsMainLightShadows = false;
+ continue;
+ }
+
+ break;
+ }
+
+ if (AdaptivePerformance.AdaptivePerformanceRenderSettings.LutBias >= 1 && renderingData.postProcessingData.lutSize == 32)
+ renderingData.postProcessingData.lutSize = 16;
+ }
+#endif
}
}