From 2bbb4f3a1f9bce5a0334a1aee48964bbbc22a688 Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Tue, 13 Jun 2023 16:17:03 +0200 Subject: [PATCH] Fixed incorrect scaled render size during FSR dispatch because of course, global variables and side-effects are bad m'kay. At least dynamic scaling works now, so we can go from here. --- .../PostProcessing/Runtime/Effects/SuperResolution.cs | 2 +- .../PostProcessing/Runtime/PostProcessLayer.cs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/SuperResolution.cs b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/SuperResolution.cs index 6cbff70..a77914a 100644 --- a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/SuperResolution.cs +++ b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/SuperResolution.cs @@ -294,7 +294,7 @@ namespace UnityEngine.Rendering.PostProcessing _dispatchDescription.MotionVectorScale.x = -scaledRenderSize.x; _dispatchDescription.MotionVectorScale.y = -scaledRenderSize.y; _dispatchDescription.RenderSize = scaledRenderSize; - _dispatchDescription.InputResourceSize = scaledRenderSize; + _dispatchDescription.InputResourceSize = _maxRenderSize; _dispatchDescription.FrameTimeDelta = Time.unscaledDeltaTime; _dispatchDescription.CameraNear = camera.nearClipPlane; _dispatchDescription.CameraFar = camera.farClipPlane; diff --git a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/PostProcessLayer.cs b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/PostProcessLayer.cs index 5a210cc..592351e 100644 --- a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/PostProcessLayer.cs +++ b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/PostProcessLayer.cs @@ -1188,17 +1188,20 @@ namespace UnityEngine.Rendering.PostProcessing // Set the upscaler's output to full display resolution, as well as for all following post-processing effects context.SetRenderSize(superResolution.displaySize); - RuntimeUtilities.EnableDynamicResolution = false; - + var fsrTarget = m_TargetPool.Get(); var finalDestination = context.destination; + RuntimeUtilities.EnableDynamicResolution = false; context.GetScreenSpaceTemporaryRT(cmd, fsrTarget, 0, context.sourceFormat, enableRandomWrite: true); context.destination = fsrTarget; superResolution.colorOpaqueOnly = m_opaqueOnly; + RuntimeUtilities.EnableDynamicResolution = true; superResolution.Render(context); context.source = fsrTarget; context.destination = finalDestination; + RuntimeUtilities.EnableDynamicResolution = false; + if (lastTarget > -1) cmd.ReleaseTemporaryRT(lastTarget);