Compare commits

...

18 Commits

Author SHA1 Message Date
Nico de Poel 9af43c4f85 FSR 2.3.4/3.1.5 update 5 months ago
Nico de Poel c822943546 Backported fixes for auto-exposure and new locks 9 months ago
Nico de Poel 10de723158 Added settings and UI for the new advanced configuration features 9 months ago
Nico de Poel 076155a916 Updated to FSR 3.1.4 and backported a couple of previous PPV2 fixes 9 months ago
Nico de Poel b71f556a0b Updated gitignore to filter out some more stuff 9 months ago
Nico de Poel 2afedcb836 Renamed FSR 2.2 to 2.3 because that's what it's called now apparently 1 year ago
Nico de Poel 8a57d7a219 Updated FSR package version number to 1.0.1 1 year ago
Nico de Poel 291aaef808 Unity 2020.x profiler fix 1 year ago
Nico de Poel 72d5400659 Some cleanup and minor fixes 1 year ago
Nico de Poel 3f1c851616 Some cleanup and minor fixes 1 year ago
Nico de Poel 56e7baa308 Auto-exposure reset fix for OpenGL on Nvidia 1 year ago
Nico de Poel 0522f1446f Optimized multi-compile keywords 1 year ago
Nico de Poel 250307d22b Additional OpenGL Core fixes 1 year ago
Nico de Poel 2c36578d66 Added OpenGL Core bindings limit fix 1 year ago
Nico de Poel b7dc3f6a27 Updated to FSR 3.1.3 and integrated velocity factor into the UI 1 year ago
Nico de Poel 9e97cb3ac5 Reverted frame count hack originating from the WW1 code 1 year ago
Nico de Poel 509950b879 Went back to the vanilla FSR 3.1.1 package code and removed all CAS and standalone reactive mask code, to make the Upscaler abstraction as clean as possible. 1 year ago
Nico de Poel a374290d99 Renamed "upscaling" field back to "superResolution" so as not to unnecessarily break API compatibility, and removed references to non-FSR upscaling techniques 1 year ago
  1. 8
      .gitignore
  2. 28
      Assets/Scripts/DebugDumper.cs
  3. 31
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Editor/PostProcessLayerEditor.cs
  4. 1
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/PostProcessResources.asset
  5. 35
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling.cs
  6. 2
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/FSR2Upscaler.cs
  7. 7
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/FSR3Upscaler.cs
  8. 193
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/Upscaler.cs
  9. 38
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/PostProcessLayer.cs
  10. 6
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/PostProcessResources.cs
  11. 2
      Packages/com.unity.postprocessing@3.2.2/package.json
  12. 2
      Packages/fidelityfx.fsr
  13. 2
      Packages/packages-lock.json

8
.gitignore

@ -8,3 +8,11 @@ Temp/
UserSettings/
Builds/
screenshot-*.png
.vs
Tools/PSSRPlugin/Prospero_Debug/
*.user
Tools/PSSRPlugin/Prospero_Release/
Prospero_Debug/
Prospero_Release/
Data/
Tools/

28
Assets/Scripts/DebugDumper.cs

@ -76,40 +76,40 @@ public class DebugDumper : MonoBehaviour
if (_layer.antialiasingMode == PostProcessLayer.Antialiasing.None)
{
_layer.antialiasingMode = PostProcessLayer.Antialiasing.AdvancedUpscaling;
_layer.upscaling.upscalerType = default;
_layer.superResolution.upscalerType = default;
}
else
{
int newUpscalerType = (int)_layer.upscaling.upscalerType + 1;
int newUpscalerType = (int)_layer.superResolution.upscalerType + 1;
if (newUpscalerType >= Enum.GetValues(typeof(Upscaling.UpscalerType)).Length)
{
_layer.antialiasingMode = PostProcessLayer.Antialiasing.None;
_layer.upscaling.upscalerType = default;
_layer.superResolution.upscalerType = default;
}
else
{
_layer.antialiasingMode = PostProcessLayer.Antialiasing.AdvancedUpscaling;
_layer.upscaling.upscalerType = (Upscaling.UpscalerType)newUpscalerType;
_layer.superResolution.upscalerType = (Upscaling.UpscalerType)newUpscalerType;
}
}
}
if (Input.GetButtonDown("Fire2"))
{
int quality = (int)_layer.upscaling.qualityMode;
int quality = (int)_layer.superResolution.qualityMode;
quality = (quality + 1) % Enum.GetValues(typeof(Fsr2.QualityMode)).Length;
_layer.upscaling.qualityMode = (Fsr2.QualityMode)quality;
_layer.superResolution.qualityMode = (Fsr2.QualityMode)quality;
}
if (Input.GetButtonDown("Fire3"))
{
_layer.upscaling.exposureSource =
_layer.upscaling.exposureSource != Upscaling.ExposureSource.Auto ? Upscaling.ExposureSource.Auto : Upscaling.ExposureSource.Default;
_layer.superResolution.exposureSource =
_layer.superResolution.exposureSource != Upscaling.ExposureSource.Auto ? Upscaling.ExposureSource.Auto : Upscaling.ExposureSource.Default;
}
if (Input.GetButtonDown("Jump"))
{
_layer.upscaling.ResetHistory();
_layer.superResolution.ResetHistory();
}
float vertical = Input.GetAxis("Vertical");
@ -134,13 +134,13 @@ public class DebugDumper : MonoBehaviour
GUI.matrix = Matrix4x4.Scale(new Vector3(scale, scale, scale));
}
var renderSize = _layer.upscaling.MaxRenderSize;
var displaySize = _layer.upscaling.UpscaleSize;
var renderSize = _layer.superResolution.MaxRenderSize;
var displaySize = _layer.superResolution.UpscaleSize;
GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));
GUILayout.Label($"Upscaler: {(_layer.antialiasingMode == PostProcessLayer.Antialiasing.AdvancedUpscaling ? _layer.upscaling.upscalerType.ToString() : "None")}");
GUILayout.Label($"Quality: {_layer.upscaling.qualityMode}");
GUILayout.Label($"Exposure: {(_layer.upscaling.exposureSource)}");
GUILayout.Label($"Upscaler: {(_layer.antialiasingMode == PostProcessLayer.Antialiasing.AdvancedUpscaling ? _layer.superResolution.upscalerType.ToString() : "None")}");
GUILayout.Label($"Quality: {_layer.superResolution.qualityMode}");
GUILayout.Label($"Exposure: {(_layer.superResolution.exposureSource)}");
GUILayout.Label($"Scale: {Mathf.RoundToInt(_scaleFactor * 100)}%");
GUILayout.Label($"Render: {Mathf.CeilToInt(renderSize.x * _scaleFactor)}x{Mathf.CeilToInt(renderSize.y * _scaleFactor)}");
GUILayout.Label($"Display: {displaySize.x}x{displaySize.y}");

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

@ -44,6 +44,7 @@ namespace UnityEditor.Rendering.PostProcessing
SerializedProperty m_FsrAutoTcr;
SerializedProperty m_FsrAutoTcrParams;
SerializedProperty m_FsrTcrMaskTexture;
SerializedProperty m_FsrAdvancedConfig;
SerializedProperty m_FogEnabled;
SerializedProperty m_FogExcludeSkybox;
@ -90,20 +91,21 @@ namespace UnityEditor.Rendering.PostProcessing
m_FxaaFastMode = FindProperty(x => x.fastApproximateAntialiasing.fastMode);
m_FxaaKeepAlpha = FindProperty(x => x.fastApproximateAntialiasing.keepAlpha);
m_UpscalerType = FindProperty(x => x.upscaling.upscalerType);
m_FsrQualityMode = FindProperty(x => x.upscaling.qualityMode);
m_FsrPerformSharpen = FindProperty(x => x.upscaling.performSharpenPass);
m_FsrSharpness = FindProperty(x => x.upscaling.sharpness);
m_FsrExposureSource = FindProperty(x => x.upscaling.exposureSource);
m_FsrExposureTexture = FindProperty(x => x.upscaling.exposure);
m_FsrPreExposure = FindProperty(x => x.upscaling.preExposure);
m_FsrDebugView = FindProperty(x => x.upscaling.enableDebugView);
m_FsrAutoReactive = FindProperty(x => x.upscaling.autoGenerateReactiveMask);
m_FsrAutoReactiveParams = FindProperty(x => x.upscaling.generateReactiveParameters);
m_FsrReactiveMaskTexture = FindProperty(x => x.upscaling.reactiveMask);
m_FsrAutoTcr = FindProperty(x => x.upscaling.autoGenerateTransparencyAndComposition);
m_FsrAutoTcrParams = FindProperty(x => x.upscaling.generateTransparencyAndCompositionParameters);
m_FsrTcrMaskTexture = FindProperty(x => x.upscaling.transparencyAndCompositionMask);
m_UpscalerType = FindProperty(x => x.superResolution.upscalerType);
m_FsrQualityMode = FindProperty(x => x.superResolution.qualityMode);
m_FsrPerformSharpen = FindProperty(x => x.superResolution.performSharpenPass);
m_FsrSharpness = FindProperty(x => x.superResolution.sharpness);
m_FsrExposureSource = FindProperty(x => x.superResolution.exposureSource);
m_FsrExposureTexture = FindProperty(x => x.superResolution.exposure);
m_FsrPreExposure = FindProperty(x => x.superResolution.preExposure);
m_FsrDebugView = FindProperty(x => x.superResolution.enableDebugView);
m_FsrAutoReactive = FindProperty(x => x.superResolution.autoGenerateReactiveMask);
m_FsrAutoReactiveParams = FindProperty(x => x.superResolution.generateReactiveParameters);
m_FsrReactiveMaskTexture = FindProperty(x => x.superResolution.reactiveMask);
m_FsrAutoTcr = FindProperty(x => x.superResolution.autoGenerateTransparencyAndComposition);
m_FsrAutoTcrParams = FindProperty(x => x.superResolution.generateTransparencyAndCompositionParameters);
m_FsrTcrMaskTexture = FindProperty(x => x.superResolution.transparencyAndCompositionMask);
m_FsrAdvancedConfig = FindProperty(x => x.superResolution.advancedConfiguration);
m_FogEnabled = FindProperty(x => x.fog.enabled);
m_FogExcludeSkybox = FindProperty(x => x.fog.excludeSkybox);
@ -238,6 +240,7 @@ namespace UnityEditor.Rendering.PostProcessing
EditorGUILayout.PropertyField(m_FsrAutoReactive.boolValue ? m_FsrAutoReactiveParams : m_FsrReactiveMaskTexture);
EditorGUILayout.PropertyField(m_FsrAutoTcr);
EditorGUILayout.PropertyField(m_FsrAutoTcr.boolValue ? m_FsrAutoTcrParams : m_FsrTcrMaskTexture);
EditorGUILayout.PropertyField(m_FsrAdvancedConfig);
}
}
EditorGUI.indentLevel--;

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

@ -127,7 +127,6 @@ MonoBehaviour:
multiScaleAORender: {fileID: 7200000, guid: 34a460e8a2e66c243a9c12024e5a798d, type: 3}
multiScaleAOUpsample: {fileID: 7200000, guid: 600d6212b59bb40409d19d750b5fd1e9, type: 3}
gaussianDownsample: {fileID: 7200000, guid: 6dba4103d23a7904fbc49099355aff3e, type: 3}
casSharpening: {fileID: 7200000, guid: 00e3ffafadd35564780d8a12adcbeff7, type: 3}
fsr2Upscaler:
computeLuminancePyramidPass: {fileID: 7200000, guid: 04c3480675e29a340808141e68d4cc8b, type: 3}
reconstructPreviousDepthPass: {fileID: 7200000, guid: 5060dfafe45aa67459629186ceb7464e, type: 3}

35
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling.cs

@ -13,11 +13,8 @@ namespace UnityEngine.Rendering.PostProcessing
public enum UpscalerType
{
[InspectorName("FidelityFX Super Resolution 2.2 (FSR2)")] FSR2,
[InspectorName("FidelityFX Super Resolution 2.3 (FSR2)")] FSR2,
[InspectorName("FidelityFX Super Resolution 3.1 (FSR3)")] FSR3,
//[InspectorName("Arm Accuracy Super Resolution (ASR)")] ASR,
//[InspectorName("Snapdragon Game Super Resolution 2 (SGSR2)")] SGSR2,
[InspectorName("PlayStation Spectral Super Resolution (PSSR)")] PSSR,
}
[Tooltip("Which upscaling technology to use.")]
@ -30,7 +27,7 @@ namespace UnityEngine.Rendering.PostProcessing
public bool performSharpenPass = true;
[Tooltip("Strength of the sharpening effect.")]
[Range(0, 1)] public float sharpness = 0.8f;
[Tooltip("Choose where to get the exposure value from. Use auto-exposure from either the upscaler or Unity, provide a manual exposure texture, or use a default value.")]
public ExposureSource exposureSource = ExposureSource.Auto;
[Tooltip("Value by which the input signal will be divided, to get back to the original signal produced by the game.")]
@ -88,7 +85,25 @@ namespace UnityEngine.Rendering.PostProcessing
[Tooltip("Maximum value reactivity can reach.")]
[Range(0, 1)] public float autoReactiveMax = 0.9f;
}
[Tooltip("Advanced upscaler settings")]
public AdvancedConfiguration advancedConfiguration = new AdvancedConfiguration();
[Serializable]
public class AdvancedConfiguration
{
[Tooltip("Adjust the influence of motion vectors on temporal accumulation.")]
[Range(0, 1)] public float velocityFactor = 1.0f;
[Tooltip("Adjust how strongly reactiveness affects temporal accumulation.")]
[Range(0, 1)] public float reactivenessScale = 1.0f;
[Tooltip("Adjust how strongly shading change affects temporal accumulation.")]
[Range(0, 1)] public float shadingChangeScale = 1.0f;
[Tooltip("Adjust how strongly previous frames are weighted for temporal accumulation.")]
[Range(0, 1)] public float accumulationAddedPerFrame = 1.0f / 3.0f;
[Tooltip("Adjust the amount of temporal accumulation in disoccluded areas.")]
[Range(-1, 1)] public float minDisocclusionAccumulation = -1.0f / 3.0f;
}
public Vector2 Jitter { get; private set; }
public Vector2 JitterOffset { get; private set; }
public Vector2Int MaxRenderSize => _maxRenderSize;
@ -218,19 +233,13 @@ namespace UnityEngine.Rendering.PostProcessing
}
}
private int _frameIndex;
private void ApplyJitter(Camera camera)
{
var scaledRenderSize = GetScaledRenderSize(camera);
// Stop frame debugger from freaking out
if (Time.deltaTime > 0)
_frameIndex++;
// Perform custom jittering of the camera's projection matrix according to FSR's recipe
int jitterPhaseCount = Fsr2.GetJitterPhaseCount(scaledRenderSize.x, _upscaleSize.x);
Fsr2.GetJitterOffset(out float jitterX, out float jitterY, _frameIndex, jitterPhaseCount);
Fsr2.GetJitterOffset(out float jitterX, out float jitterY, Time.frameCount, jitterPhaseCount);
JitterOffset = new Vector2(jitterX, jitterY);
@ -255,7 +264,7 @@ namespace UnityEngine.Rendering.PostProcessing
internal static BuiltinRenderTextureType GetDepthTexture(Camera cam)
{
return cam.renderingPath is RenderingPath.Forward or RenderingPath.VertexLit ? BuiltinRenderTextureType.Depth : BuiltinRenderTextureType.CameraTarget;
return cam.actualRenderingPath is RenderingPath.Forward or RenderingPath.VertexLit ? BuiltinRenderTextureType.Depth : BuiltinRenderTextureType.CameraTarget;
}
}

2
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/FSR2Upscaler.cs

@ -26,8 +26,6 @@ namespace UnityEngine.Rendering.PostProcessing
public override void DestroyContext()
{
base.DestroyContext();
if (_fsrContext != null)
{
_fsrContext.Destroy();

7
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/FSR3Upscaler.cs

@ -26,8 +26,6 @@ namespace UnityEngine.Rendering.PostProcessing
public override void DestroyContext()
{
base.DestroyContext();
if (_fsrContext != null)
{
_fsrContext.Destroy();
@ -90,6 +88,11 @@ namespace UnityEngine.Rendering.PostProcessing
_dispatchDescription.CameraFar = camera.farClipPlane;
_dispatchDescription.CameraFovAngleVertical = camera.fieldOfView * Mathf.Deg2Rad;
_dispatchDescription.ViewSpaceToMetersFactor = 1.0f; // 1 unit is 1 meter in Unity
_dispatchDescription.VelocityFactor = config.advancedConfiguration.velocityFactor;
_dispatchDescription.ReactivenessScale = config.advancedConfiguration.reactivenessScale;
_dispatchDescription.ShadingChangeScale = config.advancedConfiguration.shadingChangeScale;
_dispatchDescription.AccumulationAddedPerFrame = config.advancedConfiguration.accumulationAddedPerFrame;
_dispatchDescription.MinDisocclusionAccumulation = config.advancedConfiguration.minDisocclusionAccumulation;
_dispatchDescription.Reset = config.Reset;
// Set up the parameters for the optional experimental auto-TCR feature

193
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/Upscaler.cs

@ -1,8 +1,4 @@
using System;
using System.Runtime.InteropServices;
using FidelityFX;
using FidelityFX.FSR2;
using UnityEngine.Experimental.Rendering;
namespace UnityEngine.Rendering.PostProcessing
{
@ -10,195 +6,8 @@ namespace UnityEngine.Rendering.PostProcessing
{
public abstract void CreateContext(PostProcessRenderContext context, Upscaling config);
public virtual void DestroyContext()
{
DestroyRenderTexture(ref _reactiveMask);
DestroyConstantsBuffer(ref _reactiveMaskConstants);
DestroyConstantsBuffer(ref _sharpeningConstants);
}
public abstract void DestroyContext();
public abstract void Render(PostProcessRenderContext context, Upscaling config);
private ConstantsBuffer<GenerateReactiveConstants> _reactiveMaskConstants;
private RenderTexture _reactiveMask;
/// <summary>
/// Generalized standalone version of the FSR2 reactive mask auto-generating pass that can be used without needing an active FSR2 context.
/// This allows auto-generated reactive masks to be reused for other non-FSR upscaling techniques.
/// </summary>
protected Texture GenerateReactiveMask(CommandBuffer cmd, PostProcessRenderContext context, Upscaling config, GraphicsFormat format = GraphicsFormat.R8_UNorm)
{
ComputeShader shader = context.resources.computeShaders.fsr2Upscaler?.autoGenReactivePass;
if (shader == null)
return Texture2D.blackTexture;
_reactiveMaskConstants ??= ConstantsBuffer<GenerateReactiveConstants>.Create();
if (_reactiveMask == null)
{
// Use a persistent RT so it can easily be passed to native render plugins
CreateRenderTexture(ref _reactiveMask, "Reactive Mask", config.MaxRenderSize, format, true);
}
Vector2Int scaledRenderSize = config.GetScaledRenderSize(context.camera);
const int threadGroupWorkRegionDim = 8;
int dispatchX = (scaledRenderSize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim;
int dispatchY = (scaledRenderSize.y + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim;
cmd.BeginSample("Generate Reactive Mask");
_reactiveMaskConstants.Value.scale = config.generateReactiveParameters.scale;
_reactiveMaskConstants.Value.threshold = config.generateReactiveParameters.cutoffThreshold;
_reactiveMaskConstants.Value.binaryValue = config.generateReactiveParameters.binaryValue;
_reactiveMaskConstants.Value.flags = (uint)config.generateReactiveParameters.flags;
_reactiveMaskConstants.UpdateBufferData(cmd);
int kernelIndex = shader.FindKernel("CS");
cmd.SetComputeTextureParam(shader, kernelIndex, Fsr2ShaderIDs.SrvOpaqueOnly, config.ColorOpaqueOnly);
cmd.SetComputeTextureParam(shader, kernelIndex, Fsr2ShaderIDs.SrvInputColor, context.source);
cmd.SetComputeTextureParam(shader, kernelIndex, Fsr2ShaderIDs.UavAutoReactive, _reactiveMask);
cmd.SetComputeConstantBufferParam(shader, Fsr2ShaderIDs.CbGenReactive, _reactiveMaskConstants, 0, Marshal.SizeOf<GenerateReactiveConstants>());
cmd.DispatchCompute(shader, kernelIndex, dispatchX, dispatchY, 1);
cmd.EndSample("Generate Reactive Mask");
return _reactiveMask;
}
[Serializable, StructLayout(LayoutKind.Sequential)]
internal struct GenerateReactiveConstants
{
public float scale;
public float threshold;
public float binaryValue;
public uint flags;
}
private ConstantsBuffer<CasConstants> _sharpeningConstants;
private static readonly int CasInputColor = Shader.PropertyToID("r_input_color");
private static readonly int CasOutputColor = Shader.PropertyToID("rw_output_color");
private static readonly int CasConstantBuffer = Shader.PropertyToID("cbCAS");
/// <summary>
/// Generalized standalone version of the CAS sharpening filter that can be applied after any non-FSR upscaling technique.
/// </summary>
protected void ApplySharpening(CommandBuffer cmd, PostProcessRenderContext context, in Vector2Int imageSize, float sharpness, RenderTargetIdentifier input, RenderTargetIdentifier output)
{
ComputeShader shader = context.resources.computeShaders.casSharpening;
if (shader == null)
{
cmd.CopyTexture(input, output);
return;
}
const int threadGroupWorkRegionDimRcas = 16;
int threadGroupsX = (imageSize.x + threadGroupWorkRegionDimRcas - 1) / threadGroupWorkRegionDimRcas;
int threadGroupsY = (imageSize.y + threadGroupWorkRegionDimRcas - 1) / threadGroupWorkRegionDimRcas;
cmd.BeginSample("CAS Sharpening");
// Compute the constants
_sharpeningConstants ??= ConstantsBuffer<CasConstants>.Create();
int sharpnessIndex = Mathf.RoundToInt(Mathf.Clamp01(sharpness) * (CasConfigs.Length - 1));
_sharpeningConstants.Value = CasConfigs[sharpnessIndex];
_sharpeningConstants.UpdateBufferData(cmd);
// Dispatch CAS
int kernelIndex = shader.FindKernel("CS");
cmd.SetComputeTextureParam(shader, kernelIndex, CasInputColor, input);
cmd.SetComputeTextureParam(shader, kernelIndex, CasOutputColor, output);
cmd.SetComputeConstantBufferParam(shader, CasConstantBuffer, _sharpeningConstants, 0, Marshal.SizeOf<CasConstants>());
cmd.DispatchCompute(shader, kernelIndex, threadGroupsX, threadGroupsY, 1);
cmd.EndSample("CAS Sharpening");
}
[Serializable, StructLayout(LayoutKind.Sequential)]
private struct CasConstants
{
public CasConstants(uint sharpness, uint halfSharp)
{
// Since we don't use CAS for scaling, most of these values end up being constants
scaling0 = scaling1 = 1065353216;
scaling2 = scaling3 = 0;
sharpness0 = sharpness;
sharpness1 = halfSharp;
sharpness2 = 1090519040;
sharpness3 = 0;
}
public readonly uint scaling0;
public readonly uint scaling1;
public readonly uint scaling2;
public readonly uint scaling3;
public readonly uint sharpness0;
public readonly uint sharpness1;
public readonly uint sharpness2;
public readonly uint sharpness3;
}
/// <summary>
/// The FidelityFX C++ codebase uses floats bitwise converted to ints to pass sharpness parameters to the CAS shader.
/// This is not possible in C# without enabling unsafe code compilation, so to avoid that we instead use a table of precomputed values.
/// </summary>
private static readonly CasConstants[] CasConfigs =
{
new(3187671040u, 45056u),
new(3187831332u, 45075u),
new(3187997869u, 45095u),
new(3188171023u, 45117u),
new(3188351197u, 45139u),
new(3188538827u, 45161u),
new(3188734385u, 45185u),
new(3188938384u, 45210u),
new(3189151382u, 45236u),
new(3189373991u, 45263u),
new(3189606873u, 45292u),
new(3189850757u, 45322u),
new(3190106443u, 45353u),
new(3190374807u, 45386u),
new(3190656816u, 45420u),
new(3190953540u, 45456u),
new(3191266159u, 45494u),
new(3191595985u, 45535u),
new(3191944482u, 45577u),
new(3192313280u, 45622u),
new(3192704205u, 45670u),
};
protected bool CreateRenderTexture(ref RenderTexture rt, string name, in Vector2Int size, GraphicsFormat format, bool enableRandomWrite = false)
{
rt = new RenderTexture(size.x, size.y, 0, format) { name = name, enableRandomWrite = enableRandomWrite };
return rt.Create();
}
protected bool CreateRenderTexture(ref RenderTexture rt, string name, in Vector2Int size, RenderTextureFormat format, bool enableRandomWrite = false)
{
rt = new RenderTexture(size.x, size.y, 0, format) { name = name, enableRandomWrite = enableRandomWrite };
return rt.Create();
}
protected void DestroyRenderTexture(ref RenderTexture rt)
{
if (rt == null)
return;
rt.Release();
rt = null;
}
protected void DestroyConstantsBuffer<TConst>(ref ConstantsBuffer<TConst> cb)
where TConst: struct
{
if (cb == null)
return;
cb.Destroy();
cb = null;
}
}
}

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

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine.Assertions;
using UnityEngine.Serialization;
namespace UnityEngine.Rendering.PostProcessing
{
@ -100,7 +99,7 @@ namespace UnityEngine.Rendering.PostProcessing
/// <summary>
/// Advanced upscaling & anti-aliasing settings for this camera.
/// </summary>
public Upscaling upscaling;
public Upscaling superResolution;
/// <summary>
/// Subpixel Morphological Anti-aliasing settings for this camera.
@ -302,7 +301,7 @@ namespace UnityEngine.Rendering.PostProcessing
if (!finalBlitToCameraTarget && m_CurrentContext.IsSuperResolutionActive())
{
// 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
if (m_originalTargetTexture != null)
@ -342,7 +341,7 @@ namespace UnityEngine.Rendering.PostProcessing
if (resources != null) m_Resources = resources;
RuntimeUtilities.CreateIfNull(ref temporalAntialiasing);
RuntimeUtilities.CreateIfNull(ref upscaling);
RuntimeUtilities.CreateIfNull(ref superResolution);
RuntimeUtilities.CreateIfNull(ref subpixelMorphologicalAntialiasing);
RuntimeUtilities.CreateIfNull(ref fastApproximateAntialiasing);
RuntimeUtilities.CreateIfNull(ref dithering);
@ -445,7 +444,7 @@ namespace UnityEngine.Rendering.PostProcessing
}
temporalAntialiasing.Release();
upscaling.Release();
superResolution.Release();
m_LogHistogram.Release();
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
if (context.IsSuperResolutionActive())
{
upscaling.ConfigureCameraViewport(context);
context.SetRenderSize(upscaling.MaxRenderSize);
superResolution.ConfigureCameraViewport(context);
context.SetRenderSize(superResolution.MaxRenderSize);
}
else
{
// Ensure all of FSR2's resources are released when it's not in use
upscaling.Release();
superResolution.Release();
if (m_originalTargetTexture != null)
{
@ -740,10 +739,9 @@ namespace UnityEngine.Rendering.PostProcessing
}
// 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);
m_opaqueOnly = context.GetScreenSpaceTemporaryRT(colorFormat: sourceFormat, widthOverride: scaledRenderSize.x, heightOverride: scaledRenderSize.y);
m_opaqueOnly = context.GetScreenSpaceTemporaryRT(colorFormat: sourceFormat);
m_LegacyCmdBufferOpaque.BuiltinBlit(cameraTarget, m_opaqueOnly);
}
@ -776,7 +774,7 @@ namespace UnityEngine.Rendering.PostProcessing
if (!finalBlitToCameraTarget && m_CurrentContext.IsSuperResolutionActive())
{
var displaySize = upscaling.UpscaleSize;
var displaySize = superResolution.UpscaleSize;
m_upscaledOutput = context.GetScreenSpaceTemporaryRT(widthOverride: displaySize.x, heightOverride: displaySize.y);
context.destination = m_upscaledOutput;
}
@ -813,7 +811,7 @@ namespace UnityEngine.Rendering.PostProcessing
// Set the camera back to its original parameters, so we can output at full display resolution
if (finalBlitToCameraTarget && m_CurrentContext.IsSuperResolutionActive())
{
upscaling.ResetCameraViewport(m_CurrentContext);
superResolution.ResetCameraViewport(m_CurrentContext);
}
if (m_CurrentContext.IsTemporalAntialiasingActive() || m_CurrentContext.IsSuperResolutionActive())
@ -936,7 +934,7 @@ namespace UnityEngine.Rendering.PostProcessing
flags |= temporalAntialiasing.GetCameraFlags();
if (context.IsSuperResolutionActive())
flags |= upscaling.GetCameraFlags();
flags |= superResolution.GetCameraFlags();
if (fog.IsEnabledAndSupported(context))
flags |= fog.GetCameraFlags();
@ -958,7 +956,7 @@ namespace UnityEngine.Rendering.PostProcessing
bundle.Value.ResetHistory();
temporalAntialiasing.ResetHistory();
upscaling.ResetHistory();
superResolution.ResetHistory();
}
/// <summary>
@ -1020,7 +1018,7 @@ namespace UnityEngine.Rendering.PostProcessing
context.debugLayer = debugLayer;
context.antialiasing = antialiasingMode;
context.temporalAntialiasing = temporalAntialiasing;
context.upscaling = upscaling;
context.upscaling = superResolution;
context.logHistogram = m_LogHistogram;
#if UNITY_2018_2_OR_NEWER
@ -1195,17 +1193,17 @@ namespace UnityEngine.Rendering.PostProcessing
}
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
context.SetRenderSize(upscaling.UpscaleSize);
context.SetRenderSize(superResolution.UpscaleSize);
var upscaleTarget = m_TargetPool.Get();
var finalDestination = context.destination;
context.GetScreenSpaceTemporaryRT(cmd, upscaleTarget, 0, context.sourceFormat, isUpscaleOutput: true);
context.destination = upscaleTarget;
upscaling.ColorOpaqueOnly = m_opaqueOnly;
upscaling.Render(context);
superResolution.ColorOpaqueOnly = m_opaqueOnly;
superResolution.Render(context);
context.source = upscaleTarget;
context.destination = finalDestination;

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

@ -1,7 +1,6 @@
using System;
using FidelityFX.FSR2;
using FidelityFX.FSR3;
using UnityEngine.Serialization;
namespace UnityEngine.Rendering.PostProcessing
{
@ -216,11 +215,6 @@ namespace UnityEngine.Rendering.PostProcessing
/// </summary>
public ComputeShader gaussianDownsample;
/// <summary>
/// The compute shader used by the CAS sharpening filter.
/// </summary>
public ComputeShader casSharpening;
/// <summary>
/// Compute shaders used by the FidelityFX Super Resolution 2 (FSR2) Upscaler.
/// </summary>

2
Packages/com.unity.postprocessing@3.2.2/package.json

@ -6,6 +6,6 @@
"description": "The post-processing stack (v2) comes with a collection of effects and image filters you can apply to your cameras to improve the visuals of your games.",
"dependencies": {
"com.unity.modules.physics": "1.0.0",
"fidelityfx.fsr": "1.0.0"
"fidelityfx.fsr": "1.0.1"
}
}

2
Packages/fidelityfx.fsr

@ -1 +1 @@
Subproject commit d65cc3a35de270a1011c8158810e3d56c579953f
Subproject commit 89f8f0d71f85c8455c5a375fcfae30bbdf0e77f1

2
Packages/packages-lock.json

@ -82,7 +82,7 @@
"source": "embedded",
"dependencies": {
"com.unity.modules.physics": "1.0.0",
"fidelityfx.fsr": "1.0.0"
"fidelityfx.fsr": "1.0.1"
}
},
"com.unity.settings-manager": {

Loading…
Cancel
Save