Browse Source

Take control of the camera target texture and blit directly to it. This allows FSR2 upscaling to work on cameras that output to a target texture.

stable
Nico de Poel 3 years ago
parent
commit
c37b796404
  1. 24
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/PostProcessLayer.cs

24
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
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;
@ -449,6 +463,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()
{
// Unused in scriptable render pipelines

Loading…
Cancel
Save