diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/CustomPassDrawer.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/CustomPassDrawer.cs index eb22b48ccc0..f06ea077a6e 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/CustomPassDrawer.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/CustomPassDrawer.cs @@ -167,6 +167,16 @@ void DoCommonSettingsGUI(ref Rect rect) { EditorGUI.PropertyField(rect, m_TargetDepthBuffer, Styles.targetDepthBuffer); rect.y += Styles.defaultLineSpace; + + CustomPass.TargetBuffer requestedDepth = m_TargetDepthBuffer.GetEnumValue(); + if (m_CustomPass.getConstrainedDepthBuffer() != requestedDepth) + { + Rect helpBoxRect = rect; + float helpBoxHeight = EditorGUIUtility.singleLineHeight * 2; + helpBoxRect.height = helpBoxHeight; + EditorGUI.HelpBox(helpBoxRect, "Camera depth isn't supported when dynamic scaling is on. We will automatically fall back to not doing depth-testing for this pass.", MessageType.Warning); + rect.y += helpBoxHeight; + } } if ((commonPassUIFlags & PassUIFlag.ClearFlags) != 0) @@ -259,6 +269,13 @@ internal float GetPropertyHeight(SerializedProperty property, GUIContent label) } height += Styles.defaultLineSpace * lines; + + // Add height for the help box if it will be shown + if ((commonPassUIFlags & PassUIFlag.TargetDepthBuffer) != 0 && + m_CustomPass.getConstrainedDepthBuffer() != m_TargetDepthBuffer.GetEnumValue()) + { + height += EditorGUIUtility.singleLineHeight * 2; // Help box height + } } return height + GetPassHeight(property); diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPass.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPass.cs index 907fda1a823..d3170956e93 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPass.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPass.cs @@ -52,6 +52,24 @@ internal ProfilingSampler profilingSampler /// public TargetBuffer targetDepthBuffer; + // The actual depth buffer has to follow some constraints, and thus may not be the same result as the target + // depth buffer that the user has requested. Apply these constraints and return a result. + internal TargetBuffer getConstrainedDepthBuffer() + { + TargetBuffer depth = targetDepthBuffer; + if (depth == TargetBuffer.Camera && + HDRenderPipeline.currentAsset.currentPlatformRenderPipelineSettings.dynamicResolutionSettings.enabled && + currentHDCamera.allowDynamicResolution && + injectionPoint == CustomPassInjectionPoint.AfterPostProcess) + { + // This custom pass is injected after postprocessing, and Dynamic Resolution Scaling is enabled, which + // means an upscaler is active. In this case, the camera color buffer is the full display resolution, + // but the camera depth buffer is a lower, pre-upscale resolution. So we cannot do depth testing here. + depth = TargetBuffer.None; + } + return depth; + } + /// /// What clear to apply when the color and depth buffer are bound /// @@ -270,7 +288,7 @@ internal void ExecuteInternal(RenderGraph renderGraph, HDCamera hdCamera, Cullin customPass.isExecuting = false; // Set back the camera color buffer if we were using a custom buffer as target - if (customPass.targetDepthBuffer != TargetBuffer.Camera) + if (customPass.getConstrainedDepthBuffer() != TargetBuffer.Camera) CoreUtils.SetRenderTarget(ctx.cmd, outputColorBuffer); }); } @@ -307,16 +325,17 @@ bool IsMSAAEnabled(HDCamera hdCamera) // This function must be only called from the ExecuteInternal method (requires current render target and current RT manager) void SetCustomPassTarget(CommandBuffer cmd) { + TargetBuffer depth = getConstrainedDepthBuffer(); // In case all the buffer are set to none, we can't bind anything - if (targetColorBuffer == TargetBuffer.None && targetDepthBuffer == TargetBuffer.None) + if (targetColorBuffer == TargetBuffer.None && depth == TargetBuffer.None) return; RTHandle colorBuffer = (targetColorBuffer == TargetBuffer.Custom) ? currentRenderTarget.customColorBuffer.Value : currentRenderTarget.colorBufferRG; - RTHandle depthBuffer = (targetDepthBuffer == TargetBuffer.Custom) ? currentRenderTarget.customDepthBuffer.Value : currentRenderTarget.depthBufferRG; + RTHandle depthBuffer = (depth == TargetBuffer.Custom) ? currentRenderTarget.customDepthBuffer.Value : currentRenderTarget.depthBufferRG; - if (targetColorBuffer == TargetBuffer.None && targetDepthBuffer != TargetBuffer.None) + if (targetColorBuffer == TargetBuffer.None && depth != TargetBuffer.None) CoreUtils.SetRenderTarget(cmd, depthBuffer, clearFlags); - else if (targetColorBuffer != TargetBuffer.None && targetDepthBuffer == TargetBuffer.None) + else if (targetColorBuffer != TargetBuffer.None && depth == TargetBuffer.None) CoreUtils.SetRenderTarget(cmd, colorBuffer, clearFlags); else { diff --git a/Packages/com.unity.render-pipelines.universal/Editor/2D/Renderer2DMenus.cs b/Packages/com.unity.render-pipelines.universal/Editor/2D/Renderer2DMenus.cs index f15f6c1f660..f7afb82e500 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/2D/Renderer2DMenus.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/2D/Renderer2DMenus.cs @@ -76,7 +76,8 @@ internal static void Place(GameObject go, GameObject parent) static Light2D CreateLight(MenuCommand menuCommand, Light2D.LightType type, Vector3[] shapePath = null) { - GameObject go = ObjectFactory.CreateGameObject("Light 2D", typeof(Light2D)); + var lightName = type != Light2D.LightType.Point ? type.ToString() : "Spot"; + GameObject go = ObjectFactory.CreateGameObject(lightName + " Light 2D", typeof(Light2D)); Light2D light2D = go.GetComponent(); light2D.lightType = type; diff --git a/Tests/SRPTests/Projects/HDRP_RuntimeTests/Assets/Tests/TestFilters/TestCaseFilters.asset b/Tests/SRPTests/Projects/HDRP_RuntimeTests/Assets/Tests/TestFilters/TestCaseFilters.asset index 2a5a6b786b6..a54382f3a0f 100644 --- a/Tests/SRPTests/Projects/HDRP_RuntimeTests/Assets/Tests/TestFilters/TestCaseFilters.asset +++ b/Tests/SRPTests/Projects/HDRP_RuntimeTests/Assets/Tests/TestFilters/TestCaseFilters.asset @@ -103,3 +103,23 @@ MonoBehaviour: XrSdk: StereoModes: 0 Reason: 'Unstable on PS4: https://jira.unity3d.com/browse/UUM-113462 ' + - FilteredScene: {fileID: 0} + FilteredScenes: + - {fileID: 102900000, guid: 32f9dd5fabc57284bb43468761c84f36, type: 3} + ColorSpace: 1 + BuildPlatform: 31 + GraphicsDevice: 4 + Architecture: 0 + XrSdk: + StereoModes: 0 + Reason: 'Unstable on PS4: https://jira.unity3d.com/browse/UUM-113462 ' + - FilteredScene: {fileID: 0} + FilteredScenes: + - {fileID: 102900000, guid: 500813a390ad4074cba926bf26eef57a, type: 3} + ColorSpace: 1 + BuildPlatform: 31 + GraphicsDevice: 4 + Architecture: 0 + XrSdk: + StereoModes: 0 + Reason: 'Unstable on PS4: https://jira.unity3d.com/browse/UUM-113462 '