From 432f69662bbceb6f7c1d8239738a3af9bd3000b1 Mon Sep 17 00:00:00 2001 From: Antoine Lelievre Date: Fri, 9 Apr 2021 11:44:35 +0200 Subject: [PATCH 1/2] Fixed custom pass scaling issues when using RTHandles allocated from a RenderTexture --- .../Runtime/Textures/RTHandle.cs | 3 +++ .../RenderPipeline/RenderPass/CustomPass/CustomPassUtils.cs | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.core/Runtime/Textures/RTHandle.cs b/com.unity.render-pipelines.core/Runtime/Textures/RTHandle.cs index e06218a8585..d82f4a9a175 100644 --- a/com.unity.render-pipelines.core/Runtime/Textures/RTHandle.cs +++ b/com.unity.render-pipelines.core/Runtime/Textures/RTHandle.cs @@ -155,6 +155,9 @@ public void Release() /// Input size scaled by the RTHandle scale factor. public Vector2Int GetScaledSize(Vector2Int refSize) { + if (!useScaling) + return refSize; + if (scaleFunc != null) { return scaleFunc(refSize); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassUtils.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassUtils.cs index 7d7ca2a1604..d2caeba6621 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassUtils.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassUtils.cs @@ -569,7 +569,11 @@ internal static void SetRenderTargetWithScaleBias(in CustomPassContext ctx, Mate { // viewport with RT handle scale and scale factor: Rect viewport = new Rect(); - Vector2 destSize = viewport.size = destination.GetScaledSize(destination.rtHandleProperties.currentViewportSize); + if (destination.useScaling) + viewport.size = destination.GetScaledSize(destination.rtHandleProperties.currentViewportSize); + else + viewport.size = new Vector2Int(destination.rt.width, destination.rt.height); + Vector2 destSize = viewport.size; viewport.position = new Vector2(viewport.size.x * destScaleBias.z, viewport.size.y * destScaleBias.w); viewport.size *= new Vector2(destScaleBias.x, destScaleBias.y); From ffec49deadd7fe88a0306559d572f35f9eadf7cc Mon Sep 17 00:00:00 2001 From: Antoine Lelievre Date: Fri, 9 Apr 2021 11:44:58 +0200 Subject: [PATCH 2/2] Updated changelog --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index fd3bbfe3786..b07b920659f 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -136,6 +136,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed volumetric fog being visually chopped or missing when using hardware Dynamic Resolution Scaling. - Fixed generation of the packed depth pyramid when hardware Dynamic Resolution Scaling is enabled. - Fixed Decal's UV edit mode with negative UV +- Fixed CustomPassUtils scaling issues when used with RTHandles allocated from a RenderTexture. ### Changed - Changed Window/Render Pipeline/HD Render Pipeline Wizard to Window/Rendering/HDRP Wizard