diff --git a/.gitignore b/.gitignore index 3302269..2fd031f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ Logs/ obj/ Temp/ UserSettings/ +Builds/ diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 757bdc2..4f7ae80 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -315,7 +315,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 955cb66a9ecc20441a7e32934c9b4690, type: 3} m_Name: m_EditorClassIdentifier: - renderScale: 0.5 + qualityMode: 3 enableJitter: 1 --- !u!114 &963194230 MonoBehaviour: diff --git a/Assets/Scripts/Fsr2.cs b/Assets/Scripts/Fsr2.cs index aae34ac..6216d50 100644 --- a/Assets/Scripts/Fsr2.cs +++ b/Assets/Scripts/Fsr2.cs @@ -45,18 +45,19 @@ namespace FidelityFX return 2.0f; case QualityMode.UltraPerformance: return 3.0f; + case QualityMode.Native: default: return 1.0f; } } public static void GetRenderResolutionFromQualityMode( - out uint renderWidth, out uint renderHeight, + out int renderWidth, out int renderHeight, int displayWidth, int displayHeight, QualityMode qualityMode) { float ratio = GetUpscaleRatioFromQualityMode(qualityMode); - renderWidth = (uint)(displayWidth / ratio); - renderHeight = (uint)(displayHeight / ratio); + renderWidth = (int)(displayWidth / ratio); + renderHeight = (int)(displayHeight / ratio); } public static float GetMipmapBiasOffset(float renderScale) @@ -100,6 +101,7 @@ namespace FidelityFX public enum QualityMode { + Native = 0, Quality = 1, Balanced = 2, Performance = 3, diff --git a/Assets/Scripts/Fsr2Context.cs b/Assets/Scripts/Fsr2Context.cs index 89e147d..d5f924e 100644 --- a/Assets/Scripts/Fsr2Context.cs +++ b/Assets/Scripts/Fsr2Context.cs @@ -120,6 +120,7 @@ namespace FidelityFX bool resetAccumulation = dispatchParams.Reset || _firstExecution; _firstExecution = false; + // TODO: auto-exposure flag if (dispatchParams.Exposure == null) dispatchParams.Exposure = _resources.DefaultExposure; if (dispatchParams.Reactive == null) dispatchParams.Reactive = _resources.DefaultReactive; Fsr2Pipeline.RegisterResources(_commandBuffer, _contextDescription, dispatchParams); diff --git a/Assets/Scripts/SubsampleTest.cs b/Assets/Scripts/SubsampleTest.cs index 7b2dc61..71ec135 100644 --- a/Assets/Scripts/SubsampleTest.cs +++ b/Assets/Scripts/SubsampleTest.cs @@ -12,16 +12,19 @@ public class SubsampleTest : MonoBehaviour private GameObject outputCameraObject; private Camera outputCamera; - [SerializeField] - private float renderScale = 0.5f; + [SerializeField] + private Fsr2.QualityMode qualityMode; [SerializeField] private bool enableJitter; private Fsr2Controller _fsr2Controller; + private float _renderScale; private void OnEnable() { + _renderScale = 1.0f / Fsr2.GetUpscaleRatioFromQualityMode(qualityMode); + gameCamera = GetComponent(); if (outputCameraObject == null) { @@ -36,7 +39,7 @@ public class SubsampleTest : MonoBehaviour _fsr2Controller = outputCameraObject.AddComponent(); _fsr2Controller.gameCamera = gameCamera; _fsr2Controller.outputCamera = outputCamera; - _fsr2Controller.renderScale = renderScale; + _fsr2Controller.renderScale = _renderScale; _fsr2Controller.enabled = true; //outputCamera.CopyFrom(gameCamera); @@ -49,8 +52,10 @@ public class SubsampleTest : MonoBehaviour _fsr2Controller.enabled = true; } + Fsr2.GetRenderResolutionFromQualityMode(out var renderWidth, out var renderHeight, Screen.width, Screen.height, qualityMode); + gameCamera.targetTexture = new RenderTexture( - (int)(Screen.width * renderScale), (int)(Screen.height * renderScale), + renderWidth, renderHeight, 24, // Can we copy depth value from original camera? RenderTextureFormat.ARGBHalf); // Can we copy format from original camera? Or renderer quality settings? @@ -61,13 +66,13 @@ public class SubsampleTest : MonoBehaviour // Adjust texture mipmap LOD bias by log2(renderResolution/displayResolution) - 1.0; // May need to leave this to the game dev, as we don't know which textures do and don't belong to the 3D scene - float biasOffset = Fsr2.GetMipmapBiasOffset(renderScale); + float biasOffset = Fsr2.GetMipmapBiasOffset(_renderScale); Fsr2.GlobalCallbacks.ApplyMipmapBias(biasOffset); } private void OnDisable() { - float biasOffset = Fsr2.GetMipmapBiasOffset(renderScale); + float biasOffset = Fsr2.GetMipmapBiasOffset(_renderScale); Fsr2.GlobalCallbacks.ApplyMipmapBias(-biasOffset); gameCamera.targetTexture.Release(); @@ -109,6 +114,10 @@ public class SubsampleTest : MonoBehaviour _fsr2Controller.SetJitterOffset(new Vector2(jitterX, jitterY)); } + else + { + _fsr2Controller.SetJitterOffset(Vector2.zero); + } } private void OnPostRender() diff --git a/Packages/manifest.json b/Packages/manifest.json index 66775d9..daf5f04 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -5,6 +5,7 @@ "com.unity.ide.rider": "3.0.16", "com.unity.ide.visualstudio": "2.0.16", "com.unity.ide.vscode": "1.2.5", + "com.unity.memoryprofiler": "0.7.1-preview.1", "com.unity.test-framework": "1.1.31", "com.unity.textmeshpro": "3.0.6", "com.unity.timeline": "1.6.4", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 5bc5a0b..cdc7f3c 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -62,6 +62,15 @@ "dependencies": {}, "url": "https://packages.unity.com" }, + "com.unity.memoryprofiler": { + "version": "0.7.1-preview.1", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.editorcoroutines": "1.0.0" + }, + "url": "https://packages.unity.com" + }, "com.unity.nuget.newtonsoft-json": { "version": "3.0.2", "depth": 2, diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index 0147887..40917b0 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -4,5 +4,8 @@ EditorBuildSettings: m_ObjectHideFlags: 0 serializedVersion: 2 - m_Scenes: [] + m_Scenes: + - enabled: 1 + path: Assets/Scenes/SampleScene.unity + guid: 9fc0d4010bbf28b4594072e72b8655ab m_configObjects: {} diff --git a/ProjectSettings/QualitySettings.asset b/ProjectSettings/QualitySettings.asset index 1fe2c63..905e7e6 100644 --- a/ProjectSettings/QualitySettings.asset +++ b/ProjectSettings/QualitySettings.asset @@ -201,7 +201,7 @@ QualitySettings: skinWeights: 4 textureQuality: 0 anisotropicTextures: 2 - antiAliasing: 2 + antiAliasing: 0 softParticles: 1 softVegetation: 1 realtimeReflectionProbes: 1