From 7798ae524ceab019d5cd17061483ece15ec47891 Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Sat, 3 Jun 2023 19:26:39 +0200 Subject: [PATCH] Added various controls for changing FSR2 settings at run-time --- Assets/Scripts/Debug/DebugDumper.cs | 50 +++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/Assets/Scripts/Debug/DebugDumper.cs b/Assets/Scripts/Debug/DebugDumper.cs index ee109f1..de78b26 100644 --- a/Assets/Scripts/Debug/DebugDumper.cs +++ b/Assets/Scripts/Debug/DebugDumper.cs @@ -24,10 +24,13 @@ using System.Collections.Generic; using System.IO; using System.Reflection; using System.Text; +using FidelityFX; using UnityEngine; public class DebugDumper : MonoBehaviour { + private Fsr2ImageEffect _fsr; + void Start() { var sb = new StringBuilder("SystemInfo:\n"); @@ -37,6 +40,8 @@ public class DebugDumper : MonoBehaviour } Debug.Log(sb); + + _fsr = GetComponent(); } void Update() @@ -47,5 +52,50 @@ public class DebugDumper : MonoBehaviour ScreenCapture.CaptureScreenshot(path); Debug.Log($"Screenshot saved to: {path}"); } + + if (_fsr == null) + return; + + if (Input.GetButtonDown("Fire1")) + { + _fsr.enabled = !_fsr.enabled; + } + + if (Input.GetButtonDown("Fire2")) + { + int quality = (int)_fsr.qualityMode; + quality = (quality + 1) % Enum.GetValues(typeof(Fsr2.QualityMode)).Length; + _fsr.qualityMode = (Fsr2.QualityMode)quality; + } + + if (Input.GetButtonDown("Fire3")) + { + _fsr.enableAutoExposure = !_fsr.enableAutoExposure; + } + + if (Input.GetButtonDown("Jump")) + { + _fsr.ResetHistory(); + } + } + + private void OnGUI() + { + if (_fsr == null) + return; + + float scale = Screen.height / 720f; + if (scale > Mathf.Epsilon) + { + GUI.matrix = Matrix4x4.Scale(new Vector3(scale, scale, scale)); + } + + GUILayout.Label($"FSR2: {(_fsr.enabled ? "Enabled" : "Disabled")}"); + GUILayout.Label($"Quality: {_fsr.qualityMode}"); + GUILayout.Label($"Auto-exposure: {(_fsr.enableAutoExposure ? "Enabled" : "Disabled")}"); + if (Input.GetButton("Jump")) + { + GUILayout.Label("Reset"); + } } }