@ -2,7 +2,6 @@ using System;
using System.Collections.Generic ;
using System.Collections.Generic ;
using System.Linq ;
using System.Linq ;
using UnityEngine.Assertions ;
using UnityEngine.Assertions ;
using UnityEngine.Serialization ;
namespace UnityEngine.Rendering.PostProcessing
namespace UnityEngine.Rendering.PostProcessing
{
{
@ -100,7 +99,7 @@ namespace UnityEngine.Rendering.PostProcessing
/// <summary>
/// <summary>
/// Advanced upscaling & anti-aliasing settings for this camera.
/// Advanced upscaling & anti-aliasing settings for this camera.
/// </summary>
/// </summary>
public Upscaling upscaling ;
public Upscaling superResolution ;
/// <summary>
/// <summary>
/// Subpixel Morphological Anti-aliasing settings for this camera.
/// Subpixel Morphological Anti-aliasing settings for this camera.
@ -302,7 +301,7 @@ namespace UnityEngine.Rendering.PostProcessing
if ( ! finalBlitToCameraTarget & & m_CurrentContext . IsSuperResolutionActive ( ) )
if ( ! finalBlitToCameraTarget & & m_CurrentContext . IsSuperResolutionActive ( ) )
{
{
// Set the camera back to its original parameters, so we can output at full display resolution
// Set the camera back to its original parameters, so we can output at full display resolution
upscaling . ResetCameraViewport ( m_CurrentContext ) ;
superResolution . ResetCameraViewport ( m_CurrentContext ) ;
// Blit the upscaled image to the backbuffer
// Blit the upscaled image to the backbuffer
if ( m_originalTargetTexture ! = null )
if ( m_originalTargetTexture ! = null )
@ -342,7 +341,7 @@ namespace UnityEngine.Rendering.PostProcessing
if ( resources ! = null ) m_Resources = resources ;
if ( resources ! = null ) m_Resources = resources ;
RuntimeUtilities . CreateIfNull ( ref temporalAntialiasing ) ;
RuntimeUtilities . CreateIfNull ( ref temporalAntialiasing ) ;
RuntimeUtilities . CreateIfNull ( ref upscaling ) ;
RuntimeUtilities . CreateIfNull ( ref superResolution ) ;
RuntimeUtilities . CreateIfNull ( ref subpixelMorphologicalAntialiasing ) ;
RuntimeUtilities . CreateIfNull ( ref subpixelMorphologicalAntialiasing ) ;
RuntimeUtilities . CreateIfNull ( ref fastApproximateAntialiasing ) ;
RuntimeUtilities . CreateIfNull ( ref fastApproximateAntialiasing ) ;
RuntimeUtilities . CreateIfNull ( ref dithering ) ;
RuntimeUtilities . CreateIfNull ( ref dithering ) ;
@ -445,7 +444,7 @@ namespace UnityEngine.Rendering.PostProcessing
}
}
temporalAntialiasing . Release ( ) ;
temporalAntialiasing . Release ( ) ;
upscaling . Release ( ) ;
superResolution . Release ( ) ;
m_LogHistogram . Release ( ) ;
m_LogHistogram . Release ( ) ;
foreach ( var bundle in m_Bundles . Values )
foreach ( var bundle in m_Bundles . Values )
@ -635,13 +634,13 @@ namespace UnityEngine.Rendering.PostProcessing
// Modify internal rendering resolution for both the camera and the pre-upscaling post-processing effects
// Modify internal rendering resolution for both the camera and the pre-upscaling post-processing effects
if ( context . IsSuperResolutionActive ( ) )
if ( context . IsSuperResolutionActive ( ) )
{
{
upscaling . ConfigureCameraViewport ( context ) ;
context . SetRenderSize ( upscaling . MaxRenderSize ) ;
superResolution . ConfigureCameraViewport ( context ) ;
context . SetRenderSize ( superResolution . MaxRenderSize ) ;
}
}
else
else
{
{
// Ensure all of FSR2's resources are released when it's not in use
// Ensure all of FSR2's resources are released when it's not in use
upscaling . Release ( ) ;
superResolution . Release ( ) ;
if ( m_originalTargetTexture ! = null )
if ( m_originalTargetTexture ! = null )
{
{
@ -740,9 +739,9 @@ namespace UnityEngine.Rendering.PostProcessing
}
}
// Create a copy of the opaque-only color buffer for auto-reactive mask generation
// Create a copy of the opaque-only color buffer for auto-reactive mask generation
if ( context . IsSuperResolutionActive ( ) & & ( upscaling . autoGenerateReactiveMask | | upscaling . autoGenerateTransparencyAndComposition ) )
if ( context . IsSuperResolutionActive ( ) & & ( superResolution . autoGenerateReactiveMask | | superResolution . autoGenerateTransparencyAndComposition ) )
{
{
Vector2Int scaledRenderSize = upscaling . GetScaledRenderSize ( context . camera ) ;
Vector2Int scaledRenderSize = superResolution . GetScaledRenderSize ( context . camera ) ;
m_opaqueOnly = context . GetScreenSpaceTemporaryRT ( colorFormat : sourceFormat , widthOverride : scaledRenderSize . x , heightOverride : scaledRenderSize . y ) ;
m_opaqueOnly = context . GetScreenSpaceTemporaryRT ( colorFormat : sourceFormat , widthOverride : scaledRenderSize . x , heightOverride : scaledRenderSize . y ) ;
m_LegacyCmdBufferOpaque . BuiltinBlit ( cameraTarget , m_opaqueOnly ) ;
m_LegacyCmdBufferOpaque . BuiltinBlit ( cameraTarget , m_opaqueOnly ) ;
}
}
@ -776,7 +775,7 @@ namespace UnityEngine.Rendering.PostProcessing
if ( ! finalBlitToCameraTarget & & m_CurrentContext . IsSuperResolutionActive ( ) )
if ( ! finalBlitToCameraTarget & & m_CurrentContext . IsSuperResolutionActive ( ) )
{
{
var displaySize = upscaling . UpscaleSize ;
var displaySize = superResolution . UpscaleSize ;
m_upscaledOutput = context . GetScreenSpaceTemporaryRT ( widthOverride : displaySize . x , heightOverride : displaySize . y ) ;
m_upscaledOutput = context . GetScreenSpaceTemporaryRT ( widthOverride : displaySize . x , heightOverride : displaySize . y ) ;
context . destination = m_upscaledOutput ;
context . destination = m_upscaledOutput ;
}
}
@ -813,7 +812,7 @@ namespace UnityEngine.Rendering.PostProcessing
// Set the camera back to its original parameters, so we can output at full display resolution
// Set the camera back to its original parameters, so we can output at full display resolution
if ( finalBlitToCameraTarget & & m_CurrentContext . IsSuperResolutionActive ( ) )
if ( finalBlitToCameraTarget & & m_CurrentContext . IsSuperResolutionActive ( ) )
{
{
upscaling . ResetCameraViewport ( m_CurrentContext ) ;
superResolution . ResetCameraViewport ( m_CurrentContext ) ;
}
}
if ( m_CurrentContext . IsTemporalAntialiasingActive ( ) | | m_CurrentContext . IsSuperResolutionActive ( ) )
if ( m_CurrentContext . IsTemporalAntialiasingActive ( ) | | m_CurrentContext . IsSuperResolutionActive ( ) )
@ -936,7 +935,7 @@ namespace UnityEngine.Rendering.PostProcessing
flags | = temporalAntialiasing . GetCameraFlags ( ) ;
flags | = temporalAntialiasing . GetCameraFlags ( ) ;
if ( context . IsSuperResolutionActive ( ) )
if ( context . IsSuperResolutionActive ( ) )
flags | = upscaling . GetCameraFlags ( ) ;
flags | = superResolution . GetCameraFlags ( ) ;
if ( fog . IsEnabledAndSupported ( context ) )
if ( fog . IsEnabledAndSupported ( context ) )
flags | = fog . GetCameraFlags ( ) ;
flags | = fog . GetCameraFlags ( ) ;
@ -958,7 +957,7 @@ namespace UnityEngine.Rendering.PostProcessing
bundle . Value . ResetHistory ( ) ;
bundle . Value . ResetHistory ( ) ;
temporalAntialiasing . ResetHistory ( ) ;
temporalAntialiasing . ResetHistory ( ) ;
upscaling . ResetHistory ( ) ;
superResolution . ResetHistory ( ) ;
}
}
/// <summary>
/// <summary>
@ -1020,7 +1019,7 @@ namespace UnityEngine.Rendering.PostProcessing
context . debugLayer = debugLayer ;
context . debugLayer = debugLayer ;
context . antialiasing = antialiasingMode ;
context . antialiasing = antialiasingMode ;
context . temporalAntialiasing = temporalAntialiasing ;
context . temporalAntialiasing = temporalAntialiasing ;
context . upscaling = upscaling ;
context . upscaling = superResolution ;
context . logHistogram = m_LogHistogram ;
context . logHistogram = m_LogHistogram ;
#if UNITY_2018_2_OR_NEWER
#if UNITY_2018_2_OR_NEWER
@ -1195,17 +1194,17 @@ namespace UnityEngine.Rendering.PostProcessing
}
}
else if ( context . IsSuperResolutionActive ( ) )
else if ( context . IsSuperResolutionActive ( ) )
{
{
upscaling . ConfigureJitteredProjectionMatrix ( context ) ;
superResolution . ConfigureJitteredProjectionMatrix ( context ) ;
// Set the upscaler's output to full display resolution, as well as for all following post-processing effects
// Set the upscaler's output to full display resolution, as well as for all following post-processing effects
context . SetRenderSize ( upscaling . UpscaleSize ) ;
context . SetRenderSize ( superResolution . UpscaleSize ) ;
var upscaleTarget = m_TargetPool . Get ( ) ;
var upscaleTarget = m_TargetPool . Get ( ) ;
var finalDestination = context . destination ;
var finalDestination = context . destination ;
context . GetScreenSpaceTemporaryRT ( cmd , upscaleTarget , 0 , context . sourceFormat , isUpscaleOutput : true ) ;
context . GetScreenSpaceTemporaryRT ( cmd , upscaleTarget , 0 , context . sourceFormat , isUpscaleOutput : true ) ;
context . destination = upscaleTarget ;
context . destination = upscaleTarget ;
upscaling . ColorOpaqueOnly = m_opaqueOnly ;
upscaling . Render ( context ) ;
superResolution . ColorOpaqueOnly = m_opaqueOnly ;
superResolution . Render ( context ) ;
context . source = upscaleTarget ;
context . source = upscaleTarget ;
context . destination = finalDestination ;
context . destination = finalDestination ;