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/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 2c2c9918daa..65e0dc1b8e7 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -154,6 +154,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed GBuffer clear option in FrameSettings not working - Fixed usage of Panini Projection with floating point HDRP and Post Processing color buffers. - Fixed a NaN generating in Area light code. +- 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 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 cb1ae277836..6ca6e8ad3f5 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);