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 7e1cc09..15e3774 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 @@ -210,6 +210,7 @@ namespace UnityEngine.Rendering.PostProcessing CommandBuffer m_LegacyCmdBufferBeforeLighting; CommandBuffer m_LegacyCmdBufferOpaque; CommandBuffer m_LegacyCmdBuffer; + CommandBuffer m_BlitCmdBuffer; Camera m_Camera; PostProcessRenderContext m_CurrentContext; LogHistogram m_LogHistogram; @@ -251,6 +252,7 @@ namespace UnityEngine.Rendering.PostProcessing m_LegacyCmdBufferBeforeLighting = new CommandBuffer { name = "Deferred Ambient Occlusion" }; m_LegacyCmdBufferOpaque = new CommandBuffer { name = "Opaque Only Post-processing" }; m_LegacyCmdBuffer = new CommandBuffer { name = "Post-processing" }; + m_BlitCmdBuffer = new CommandBuffer { name = "Backbuffer blit" }; m_Camera = GetComponent(); @@ -281,6 +283,16 @@ namespace UnityEngine.Rendering.PostProcessing [ImageEffectUsesCommandBuffer] void OnRenderImage(RenderTexture src, RenderTexture dst) { + if (!finalBlitToCameraTarget && m_CurrentContext.IsSuperResolutionActive()) + { + // Blit the upscaled image to the backbuffer + m_BlitCmdBuffer.Blit(m_CurrentContext.destination, dst); + Graphics.ExecuteCommandBuffer(m_BlitCmdBuffer); + + RenderTexture.active = dst; + return; + } + if (finalBlitToCameraTarget && !m_CurrentContext.stereoActive && DynamicResolutionAllowsFinalBlitToCameraTarget()) RenderTexture.active = dst; // silence warning else @@ -572,6 +584,7 @@ namespace UnityEngine.Rendering.PostProcessing m_LegacyCmdBufferBeforeLighting.Clear(); m_LegacyCmdBufferOpaque.Clear(); m_LegacyCmdBuffer.Clear(); + m_BlitCmdBuffer.Clear(); SetupContext(context); @@ -627,7 +640,7 @@ namespace UnityEngine.Rendering.PostProcessing bool isFogActive = fog.IsEnabledAndSupported(context); bool hasCustomOpaqueOnlyEffects = HasOpaqueOnlyEffects(context); int opaqueOnlyEffects = 0; - // TODO: if FSR2 is active, add opaque-only copy step + // TODO: if FSR2 is active & using auto-reactive/TCR, add opaque-only copy step opaqueOnlyEffects += isScreenSpaceReflectionsActive ? 1 : 0; opaqueOnlyEffects += isFogActive ? 1 : 0; opaqueOnlyEffects += hasCustomOpaqueOnlyEffects ? 1 : 0; @@ -701,6 +714,13 @@ namespace UnityEngine.Rendering.PostProcessing context.destination = cameraTarget; + if (!finalBlitToCameraTarget && m_CurrentContext.IsSuperResolutionActive()) + { + // Use the main display buffer for temporarily storing the upscaled full-resolution image + context.flip = true; + context.destination = Display.main.colorBuffer; + } + #if UNITY_2019_1_OR_NEWER if (finalBlitToCameraTarget && !m_CurrentContext.stereoActive && !RuntimeUtilities.scriptableRenderPipelineActive && DynamicResolutionAllowsFinalBlitToCameraTarget()) {