Browse Source

Initial integration of FSR2 into the post-processing pipeline, as just an alternative to the standard TAA option. No upscaling yet.

Some issues with jittering still remain, but the basic functionality is there.
stable
Nico de Poel 3 years ago
parent
commit
99cbc183f8
  1. 3
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Editor/PostProcessLayerEditor.cs
  2. 17
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/PostProcessResources.asset
  3. 10
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/DepthOfField.cs
  4. 279
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/SuperResolution.cs
  5. 11
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/SuperResolution.cs.meta
  6. 45
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/PostProcessLayer.cs
  7. 12
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/PostProcessRenderContext.cs
  8. 23
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/PostProcessResources.cs

3
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Editor/PostProcessLayerEditor.cs

@ -47,7 +47,8 @@ namespace UnityEditor.Rendering.PostProcessing
new GUIContent("No Anti-aliasing"), new GUIContent("No Anti-aliasing"),
new GUIContent("Fast Approximate Anti-aliasing (FXAA)"), new GUIContent("Fast Approximate Anti-aliasing (FXAA)"),
new GUIContent("Subpixel Morphological Anti-aliasing (SMAA)"), new GUIContent("Subpixel Morphological Anti-aliasing (SMAA)"),
new GUIContent("Temporal Anti-aliasing (TAA)")
new GUIContent("Temporal Anti-aliasing (TAA)"),
new GUIContent("FidelityFX Super Resolution 2 (FSR2)")
}; };
enum ExportMode enum ExportMode

17
Packages/com.unity.postprocessing@3.2.2/PostProcessing/PostProcessResources.asset

@ -136,3 +136,20 @@ MonoBehaviour:
type: 3} type: 3}
gaussianDownsample: {fileID: 7200000, guid: 6dba4103d23a7904fbc49099355aff3e, gaussianDownsample: {fileID: 7200000, guid: 6dba4103d23a7904fbc49099355aff3e,
type: 3} type: 3}
namedShaders:
- name: FSR2/ffx_fsr2_compute_luminance_pyramid_pass
shader: {fileID: 7200000, guid: 0894ebeefb6aa7d4680c71dffbda3fee, type: 3}
- name: FSR2/ffx_fsr2_reconstruct_previous_depth_pass
shader: {fileID: 7200000, guid: 6ef1b4c25874e334dad5ba3ac6345e32, type: 3}
- name: FSR2/ffx_fsr2_depth_clip_pass
shader: {fileID: 7200000, guid: 8026d9d8542eab6499c32d5d46beb2b6, type: 3}
- name: FSR2/ffx_fsr2_lock_pass
shader: {fileID: 7200000, guid: 3c96d72b39a840c428c901628dab92c0, type: 3}
- name: FSR2/ffx_fsr2_accumulate_pass
shader: {fileID: 7200000, guid: 702560780e923c84394c9b22ba460a9c, type: 3}
- name: FSR2/ffx_fsr2_rcas_pass
shader: {fileID: 7200000, guid: 5a82801f160ff6a4eb47db567216e592, type: 3}
- name: FSR2/ffx_fsr2_autogen_reactive_pass
shader: {fileID: 7200000, guid: d18fb8811ca4753469c439784546104e, type: 3}
- name: FSR2/ffx_fsr2_tcr_autogen_pass
shader: {fileID: 7200000, guid: b478fba0a6a87b44b8be7c35deb5f0dc, type: 3}

10
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/DepthOfField.cs

@ -202,7 +202,15 @@ namespace UnityEngine.Rendering.PostProcessing
var jitter = context.temporalAntialiasing.jitter; var jitter = context.temporalAntialiasing.jitter;
sheet.properties.SetVector(ShaderIDs.TaaParams, new Vector3(jitter.x, jitter.y, blend)); sheet.properties.SetVector(ShaderIDs.TaaParams, new Vector3(jitter.x, jitter.y, blend));
}
else if (context.IsSuperResolutionActive())
{
var jitter = context.superResolution.jitter;
sheet.properties.SetVector(ShaderIDs.TaaParams, new Vector3(jitter.x, jitter.y, 0f));
}
if (context.IsTemporalAntialiasingActive() || context.IsSuperResolutionActive())
{
int pp = m_HistoryPingPong[context.xrActiveEye]; int pp = m_HistoryPingPong[context.xrActiveEye];
var historyRead = CheckHistory(context.xrActiveEye, ++pp % 2, context, cocFormat); var historyRead = CheckHistory(context.xrActiveEye, ++pp % 2, context, cocFormat);
var historyWrite = CheckHistory(context.xrActiveEye, ++pp % 2, context, cocFormat); var historyWrite = CheckHistory(context.xrActiveEye, ++pp % 2, context, cocFormat);
@ -233,7 +241,7 @@ namespace UnityEngine.Rendering.PostProcessing
cmd.BlitFullscreenTriangle(context.source, context.destination, sheet, (int)Pass.Combine); cmd.BlitFullscreenTriangle(context.source, context.destination, sheet, (int)Pass.Combine);
cmd.ReleaseTemporaryRT(ShaderIDs.DepthOfFieldTex); cmd.ReleaseTemporaryRT(ShaderIDs.DepthOfFieldTex);
if (!context.IsTemporalAntialiasingActive())
if (!context.IsTemporalAntialiasingActive() && !context.IsSuperResolutionActive())
cmd.ReleaseTemporaryRT(ShaderIDs.CoCTex); cmd.ReleaseTemporaryRT(ShaderIDs.CoCTex);
cmd.EndSample("DepthOfField"); cmd.EndSample("DepthOfField");

279
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/SuperResolution.cs

@ -0,0 +1,279 @@
// Copyright (c) 2023 Nico de Poel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.PostProcessing;
using FidelityFX;
namespace UnityEngine.Rendering.PostProcessing
{
[Serializable]
public class Fsr2QualityModeParameter : ParameterOverride<Fsr2.QualityMode>
{
}
[Serializable]
public class Fsr2GenerateReactiveParameters: ParameterOverride<Fsr2GenerateReactiveParams>
{
}
[Serializable]
public class Fsr2GenerateReactiveParams
{
[Range(0, 2)] public float scale = 0.5f;
[Range(0, 1)] public float cutoffThreshold = 0.2f;
[Range(0, 1)] public float binaryValue = 0.9f;
public Fsr2.GenerateReactiveFlags flags = Fsr2.GenerateReactiveFlags.ApplyTonemap | Fsr2.GenerateReactiveFlags.ApplyThreshold | Fsr2.GenerateReactiveFlags.UseComponentsMax;
}
[UnityEngine.Scripting.Preserve]
[Serializable]
public class SuperResolution
{
public Fsr2QualityModeParameter qualityMode = new Fsr2QualityModeParameter() { value = Fsr2.QualityMode.Quality };
public BoolParameter performSharpenPass = new BoolParameter() { value = true };
[Range(0, 1)] public FloatParameter sharpness = new FloatParameter() { value = 0.8f };
[Tooltip("Allow the use of half precision compute operations, potentially improving performance")]
public BoolParameter enableFP16 = new BoolParameter() { value = false };
[Header("Exposure")]
public BoolParameter enableAutoExposure = new BoolParameter() { value = true };
public FloatParameter preExposure = new FloatParameter() { value = 1.0f };
public TextureParameter exposure = new TextureParameter() { value = null };
[Header("Reactivity, Transparency & Composition")]
public TextureParameter reactiveMask = new TextureParameter() { value = null };
public TextureParameter transparencyAndCompositionMask = new TextureParameter() { value = null };
public BoolParameter autoGenerateReactiveMask = new BoolParameter() { value = true };
public Fsr2GenerateReactiveParameters generateReactiveParameters = new Fsr2GenerateReactiveParameters();
public Vector2 jitter { get; private set; }
private Fsr2Context _fsrContext;
private Vector2Int _renderSize;
private Vector2Int _displaySize;
private bool _reset;
private readonly Fsr2.DispatchDescription _dispatchDescription = new Fsr2.DispatchDescription();
private readonly Fsr2.GenerateReactiveDescription _genReactiveDescription = new Fsr2.GenerateReactiveDescription();
private RenderTexture _upscaledOutput;
private Fsr2.QualityMode _prevQualityMode;
private Vector2Int _prevDisplaySize;
public bool IsSupported()
{
return SystemInfo.supportsComputeShaders && SystemInfo.supportsMotionVectors;
}
public DepthTextureMode GetCameraFlags()
{
return DepthTextureMode.Depth | DepthTextureMode.MotionVectors;
}
public void ResetHistory()
{
_reset = true;
}
public void ConfigureJitteredProjectionMatrix(PostProcessRenderContext context)
{
ApplyJitter(context.camera);
}
public void Render(PostProcessRenderContext context)
{
var cmd = context.command;
if (!Application.isPlaying)
{
// We don't want this effect to start injecting scripts in edit mode, so just blit and skip the rest entirely
cmd.BlitFullscreenTriangle(context.source, context.destination);
return;
}
// Monitor for any resolution changes and recreate the FSR2 context if necessary
// We can't create an FSR2 context without info from the post-processing context, so delay the initial setup until here
if (_fsrContext == null || _displaySize.x != _prevDisplaySize.x || _displaySize.y != _prevDisplaySize.y || qualityMode != _prevQualityMode)
{
DestroyFsrContext();
CreateFsrContext(context);
_prevQualityMode = qualityMode;
}
// Effects rendering happens in OnPreCull, so this is the right place to apply camera jittering
ApplyJitter(context.camera);
cmd.SetGlobalTexture(Fsr2ShaderIDs.SrvInputColor, BuiltinRenderTextureType.CameraTarget, RenderTextureSubElement.Color);
cmd.SetGlobalTexture(Fsr2ShaderIDs.SrvInputDepth, BuiltinRenderTextureType.CameraTarget, RenderTextureSubElement.Depth);
cmd.SetGlobalTexture(Fsr2ShaderIDs.SrvInputMotionVectors, BuiltinRenderTextureType.MotionVectors);
SetupDispatchDescription(context);
if (autoGenerateReactiveMask)
{
// TODO: auto-generate reactive mask
}
cmd.GetTemporaryRT(Fsr2ShaderIDs.UavUpscaledOutput, _displaySize.x, _displaySize.y, 0, default, context.sourceFormat, default, 1, true);
// _dispatchDescription.Output = _upscaledOutput;
_fsrContext.Dispatch(_dispatchDescription, cmd);
cmd.BlitFullscreenTriangle(Fsr2ShaderIDs.UavUpscaledOutput, context.destination);
cmd.ReleaseTemporaryRT(Fsr2ShaderIDs.UavUpscaledOutput);
}
private void CreateFsrContext(PostProcessRenderContext context)
{
_displaySize = new Vector2Int(context.width, context.height);
_prevDisplaySize = _displaySize;
// TODO: re-enable actual resolution scaling
// Fsr2.GetRenderResolutionFromQualityMode(out var renderWidth, out var renderHeight, _displaySize.x, _displaySize.y, qualityMode);
// _renderSize = new Vector2Int(renderWidth, renderHeight);
_renderSize = _displaySize;
Fsr2.InitializationFlags flags = 0;
if (context.camera.allowHDR) flags |= Fsr2.InitializationFlags.EnableHighDynamicRange;
if (enableFP16) flags |= Fsr2.InitializationFlags.EnableFP16Usage;
if (enableAutoExposure) flags |= Fsr2.InitializationFlags.EnableAutoExposure;
_fsrContext = Fsr2.CreateContext(_displaySize, _renderSize, new Callbacks(context.resources), flags);
// Apply a mipmap bias so that textures retain their sharpness
float biasOffset = Fsr2.GetMipmapBiasOffset(_renderSize.x, _displaySize.x);
//Fsr2.GlobalCallbacks.ApplyMipmapBias(biasOffset);
_upscaledOutput = new RenderTexture(_displaySize.x, _displaySize.y, 0, context.sourceFormat) { name = "FSR2 Upscaled Output", enableRandomWrite = true };
_upscaledOutput.Create();
}
private void DestroyFsrContext()
{
if (_fsrContext != null)
{
_fsrContext.Destroy();
_fsrContext = null;
// Undo the previous mipmap bias adjustment
float biasOffset = Fsr2.GetMipmapBiasOffset(_renderSize.x, _prevDisplaySize.x);
//Fsr2.GlobalCallbacks.ApplyMipmapBias(-biasOffset);
}
if (_upscaledOutput != null)
{
_upscaledOutput.Release();
_upscaledOutput = null;
}
}
private void ApplyJitter(Camera camera)
{
// Perform custom jittering of the camera's projection matrix according to FSR2's recipe
int jitterPhaseCount = Fsr2.GetJitterPhaseCount(_renderSize.x, _displaySize.x);
Fsr2.GetJitterOffset(out float jitterX, out float jitterY, Time.frameCount, jitterPhaseCount);
_dispatchDescription.JitterOffset = new Vector2(jitterX, jitterY);
jitterX = 2.0f * jitterX / _renderSize.x;
jitterY = 2.0f * jitterY / _renderSize.y;
var jitterTranslationMatrix = Matrix4x4.Translate(new Vector3(jitterX, jitterY, 0));
camera.nonJitteredProjectionMatrix = camera.projectionMatrix;
camera.projectionMatrix = jitterTranslationMatrix * camera.nonJitteredProjectionMatrix;
camera.useJitteredProjectionMatrixForTransparentRendering = false;
jitter = new Vector2(jitterX, jitterY);
}
private void SetupDispatchDescription(PostProcessRenderContext context)
{
var camera = context.camera;
// Set up the main FSR2 dispatch parameters
// The input and output textures are left blank here, as they are already being bound elsewhere in this source file
_dispatchDescription.Color = null;
_dispatchDescription.Depth = null;
_dispatchDescription.MotionVectors = null;
_dispatchDescription.Exposure = null;
_dispatchDescription.Reactive = null;
_dispatchDescription.TransparencyAndComposition = null;
if (!enableAutoExposure && exposure.value != null) _dispatchDescription.Exposure = exposure.value;
if (reactiveMask.value != null) _dispatchDescription.Reactive = reactiveMask.value;
if (transparencyAndCompositionMask.value != null) _dispatchDescription.TransparencyAndComposition = transparencyAndCompositionMask.value;
_dispatchDescription.Output = null;
_dispatchDescription.PreExposure = preExposure;
_dispatchDescription.EnableSharpening = performSharpenPass;
_dispatchDescription.Sharpness = sharpness;
_dispatchDescription.MotionVectorScale.x = -_renderSize.x;
_dispatchDescription.MotionVectorScale.y = -_renderSize.y;
_dispatchDescription.RenderSize = _renderSize;
_dispatchDescription.FrameTimeDelta = Time.unscaledDeltaTime;
_dispatchDescription.CameraNear = camera.nearClipPlane;
_dispatchDescription.CameraFar = camera.farClipPlane;
_dispatchDescription.CameraFovAngleVertical = camera.fieldOfView * Mathf.Deg2Rad;
_dispatchDescription.ViewSpaceToMetersFactor = 1.0f; // 1 unit is 1 meter in Unity
_dispatchDescription.Reset = _reset;
_reset = false;
if (SystemInfo.usesReversedZBuffer)
{
// Swap the near and far clip plane distances as FSR2 expects this when using inverted depth
(_dispatchDescription.CameraNear, _dispatchDescription.CameraFar) = (_dispatchDescription.CameraFar, _dispatchDescription.CameraNear);
}
}
public void Release()
{
DestroyFsrContext();
}
private class Callbacks : Fsr2CallbacksBase
{
private readonly PostProcessResources _resources;
public Callbacks(PostProcessResources resources)
{
_resources = resources;
}
public override ComputeShader LoadComputeShader(string name)
{
return _resources.computeShaders.FindComputeShader(name);
}
public override void UnloadComputeShader(ComputeShader shader)
{
}
}
}
}

11
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/SuperResolution.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 804fb4cfea0948247a52576cc4a79609
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

45
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/PostProcessLayer.cs

@ -48,7 +48,12 @@ namespace UnityEngine.Rendering.PostProcessing
/// of it's temporal nature, it can introduce ghosting artifacts on fast moving objects /// of it's temporal nature, it can introduce ghosting artifacts on fast moving objects
/// in highly contrasted areas. /// in highly contrasted areas.
/// </summary> /// </summary>
TemporalAntialiasing
TemporalAntialiasing,
/// <summary>
/// FidelityFX Super Resolution 2 (FSR2).
/// </summary>
SuperResolution,
} }
/// <summary> /// <summary>
@ -91,6 +96,11 @@ namespace UnityEngine.Rendering.PostProcessing
/// </summary> /// </summary>
public TemporalAntialiasing temporalAntialiasing; public TemporalAntialiasing temporalAntialiasing;
/// <summary>
/// FSR2 upscaling & anti-aliasing settings for this camera.
/// </summary>
public SuperResolution superResolution;
/// <summary> /// <summary>
/// Subpixel Morphological Anti-aliasing settings for this camera. /// Subpixel Morphological Anti-aliasing settings for this camera.
/// </summary> /// </summary>
@ -286,6 +296,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 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);
@ -385,6 +396,7 @@ namespace UnityEngine.Rendering.PostProcessing
} }
temporalAntialiasing.Release(); temporalAntialiasing.Release();
superResolution.Release();
m_LogHistogram.Release(); m_LogHistogram.Release();
foreach (var bundle in m_Bundles.Values) foreach (var bundle in m_Bundles.Values)
@ -442,7 +454,7 @@ namespace UnityEngine.Rendering.PostProcessing
// We also need to force reset the non-jittered projection matrix here as it's not done // We also need to force reset the non-jittered projection matrix here as it's not done
// when ResetProjectionMatrix() is called and will break transparent rendering if TAA // when ResetProjectionMatrix() is called and will break transparent rendering if TAA
// is switched off and the FOV or any other camera property changes. // is switched off and the FOV or any other camera property changes.
if (m_CurrentContext.IsTemporalAntialiasingActive())
if (m_CurrentContext.IsTemporalAntialiasingActive() || m_CurrentContext.IsSuperResolutionActive())
{ {
#if UNITY_2018_2_OR_NEWER #if UNITY_2018_2_OR_NEWER
if (!m_Camera.usePhysicalProperties) if (!m_Camera.usePhysicalProperties)
@ -578,7 +590,7 @@ namespace UnityEngine.Rendering.PostProcessing
#if UNITY_2019_1_OR_NEWER #if UNITY_2019_1_OR_NEWER
if (context.stereoActive) if (context.stereoActive)
context.UpdateSinglePassStereoState(context.IsTemporalAntialiasingActive(), aoSupported, isScreenSpaceReflectionsActive);
context.UpdateSinglePassStereoState(context.IsTemporalAntialiasingActive() || context.IsSuperResolutionActive(), aoSupported, isScreenSpaceReflectionsActive);
#endif #endif
// Ambient-only AO is a special case and has to be done in separate command buffers // Ambient-only AO is a special case and has to be done in separate command buffers
if (isAmbientOcclusionDeferred) if (isAmbientOcclusionDeferred)
@ -702,7 +714,7 @@ namespace UnityEngine.Rendering.PostProcessing
if (RuntimeUtilities.scriptableRenderPipelineActive) if (RuntimeUtilities.scriptableRenderPipelineActive)
return; return;
if (m_CurrentContext.IsTemporalAntialiasingActive())
if (m_CurrentContext.IsTemporalAntialiasingActive() || m_CurrentContext.IsSuperResolutionActive())
{ {
#if UNITY_2018_2_OR_NEWER #if UNITY_2018_2_OR_NEWER
// TAA calls SetProjectionMatrix so if the camera projection mode was physical, it gets set to explicit. So we set it back to physical. // TAA calls SetProjectionMatrix so if the camera projection mode was physical, it gets set to explicit. So we set it back to physical.
@ -821,6 +833,9 @@ namespace UnityEngine.Rendering.PostProcessing
if (context.IsTemporalAntialiasingActive()) if (context.IsTemporalAntialiasingActive())
flags |= temporalAntialiasing.GetCameraFlags(); flags |= temporalAntialiasing.GetCameraFlags();
if (context.IsSuperResolutionActive())
flags |= superResolution.GetCameraFlags();
if (fog.IsEnabledAndSupported(context)) if (fog.IsEnabledAndSupported(context))
flags |= fog.GetCameraFlags(); flags |= fog.GetCameraFlags();
@ -902,6 +917,7 @@ namespace UnityEngine.Rendering.PostProcessing
context.debugLayer = debugLayer; context.debugLayer = debugLayer;
context.antialiasing = antialiasingMode; context.antialiasing = antialiasingMode;
context.temporalAntialiasing = temporalAntialiasing; context.temporalAntialiasing = temporalAntialiasing;
context.superResolution = superResolution;
context.logHistogram = m_LogHistogram; context.logHistogram = m_LogHistogram;
#if UNITY_2018_2_OR_NEWER #if UNITY_2018_2_OR_NEWER
@ -1070,6 +1086,27 @@ namespace UnityEngine.Rendering.PostProcessing
lastTarget = taaTarget; lastTarget = taaTarget;
} }
else if (context.IsSuperResolutionActive())
{
// TODO: perform camera projection jitter
superResolution.ConfigureJitteredProjectionMatrix(context);
// TODO: setup source and destination render textures (temp RTs)
var fsrTarget = m_TargetPool.Get();
var finalDestination = context.destination;
context.GetScreenSpaceTemporaryRT(cmd, fsrTarget, 0, context.sourceFormat);
context.destination = fsrTarget;
superResolution.Render(context);
context.source = fsrTarget;
context.destination = finalDestination;
if (lastTarget > -1)
cmd.ReleaseTemporaryRT(lastTarget);
lastTarget = fsrTarget;
// TODO: this is probably where we perform the camera viewport trick as well
}
bool hasBeforeStackEffects = HasActiveEffects(PostProcessEvent.BeforeStack, context); bool hasBeforeStackEffects = HasActiveEffects(PostProcessEvent.BeforeStack, context);
bool hasAfterStackEffects = HasActiveEffects(PostProcessEvent.AfterStack, context) && !breakBeforeColorGrading; bool hasAfterStackEffects = HasActiveEffects(PostProcessEvent.AfterStack, context) && !breakBeforeColorGrading;

12
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/PostProcessRenderContext.cs

@ -207,6 +207,11 @@ namespace UnityEngine.Rendering.PostProcessing
/// </summary> /// </summary>
public TemporalAntialiasing temporalAntialiasing { get; internal set; } public TemporalAntialiasing temporalAntialiasing { get; internal set; }
/// <summary>
/// A reference to the FSR2 settings for the rendering layer.
/// </summary>
public SuperResolution superResolution { get; internal set; }
// Internal values used for builtin effects // Internal values used for builtin effects
// Beware, these may not have been set before a specific builtin effect has been executed // Beware, these may not have been set before a specific builtin effect has been executed
internal PropertySheet uberSheet; internal PropertySheet uberSheet;
@ -275,6 +280,13 @@ namespace UnityEngine.Rendering.PostProcessing
&& temporalAntialiasing.IsSupported(); && temporalAntialiasing.IsSupported();
} }
public bool IsSuperResolutionActive()
{
return antialiasing == PostProcessLayer.Antialiasing.SuperResolution
&& !isSceneView
&& superResolution.IsSupported();
}
/// <summary> /// <summary>
/// Checks if a specific debug overlay is enabled. /// Checks if a specific debug overlay is enabled.
/// </summary> /// </summary>

23
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/PostProcessResources.cs

@ -213,6 +213,11 @@ namespace UnityEngine.Rendering.PostProcessing
/// </summary> /// </summary>
public ComputeShader gaussianDownsample; public ComputeShader gaussianDownsample;
/// <summary>
/// Compute shaders that need to be looked up by name.
/// </summary>
public NamedComputeShader[] namedShaders;
/// <summary> /// <summary>
/// Returns a copy of this class and its content. /// Returns a copy of this class and its content.
/// </summary> /// </summary>
@ -221,6 +226,24 @@ namespace UnityEngine.Rendering.PostProcessing
{ {
return (ComputeShaders)MemberwiseClone(); return (ComputeShaders)MemberwiseClone();
} }
public ComputeShader FindComputeShader(string name)
{
for (int i = 0; i < namedShaders.Length; ++i)
{
if (namedShaders[i].name == name)
return namedShaders[i].shader;
}
return null;
}
}
[Serializable]
public class NamedComputeShader
{
public string name;
public ComputeShader shader;
} }
/// <summary> /// <summary>

Loading…
Cancel
Save