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 1b7145a..1b3ac4b 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 @@ -216,6 +216,7 @@ namespace UnityEngine.Rendering.PostProcessing RenderTexture m_opaqueOnly; RenderTexture m_upscaledOutput; + RenderTexture m_originalTargetTexture; bool m_SettingsUpdateNeeded = true; bool m_IsRenderingInSceneView = false; @@ -296,7 +297,20 @@ namespace UnityEngine.Rendering.PostProcessing superResolution.ResetCameraViewport(m_CurrentContext); // Blit the upscaled image to the backbuffer - Graphics.Blit(m_upscaledOutput, dst); + if (m_originalTargetTexture != null) + { + Graphics.Blit(m_upscaledOutput, m_originalTargetTexture); + RenderTexture.active = dst; + + // Put the original target texture back at the end of the frame + m_Camera.targetTexture = m_originalTargetTexture; + m_originalTargetTexture = null; + } + else + { + Graphics.Blit(m_upscaledOutput, dst); + } + RenderTexture.ReleaseTemporary(m_upscaledOutput); m_upscaledOutput = null; return; @@ -448,6 +462,16 @@ namespace UnityEngine.Rendering.PostProcessing { volumeTrigger = transform; } + + void LateUpdate() + { + // Temporarily take control of the camera's target texture, so that the upscaled output doesn't get clipped + if (m_Camera.targetTexture != null && m_CurrentContext.IsSuperResolutionActive()) + { + m_originalTargetTexture = m_Camera.targetTexture; + m_Camera.targetTexture = null; + } + } void OnPreCull() {