using UnityEngine; using UnityEngine.Rendering.Universal; using X.Rendering.Feature; [ExecuteAlways] public class Test : MonoBehaviour { public Transform transform; int vrs = 0; static float[] resultions = new float[] { 1.0f, 0.75f, 0.66f, 0.5f, 0.33f }; static string[] dlssQualitys = new string[] { "MaximumPerformance", "Balanced", "MaximumQuality", "UltraPerformance" }; private int resultionIndex = 0; private bool dlssOn = false; private int dlssQuality; private bool xessOn = false; private void Start() { RenderingPlugin.InitSupportFeatures(); } public void OnClickVRS() { var asset = UniversalRenderPipeline.asset; if (asset != null) { vrs++; if (vrs > (int)RenderingPlugin.VRSPluginShadingRate.X1_PER_4X4_PIXELS) { vrs = 0; } asset.VRSRate = (RenderingPlugin.VRSPluginShadingRate)vrs; Debug.Log("VRS RATE" + asset.VRSRate); } } private void Update() { //transform?.Rotate(new Vector3(0, 0.1f, 0)); if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.R)) { resultionIndex++; resultionIndex = resultionIndex % resultions.Length; UniversalRenderPipeline.asset.renderScale = resultions[resultionIndex]; } if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.E)) { dlssOn = !dlssOn; var asset = UniversalRenderPipeline.asset; DLSS dlss = null; foreach (var item in asset.GetRenderer(0).rendererFeatures) { if (item is DLSS dl) { dlss = dl; break; } } if (dlssOn) { asset.superResolution = ESuperResolution.DLSS2; dlss.SetActive(true); } else { SuperResolutionParamSets.Instance.Set("NeedJitter", false); SuperResolutionParamSets.Instance.Set("MipmapBias", 0); asset.superResolution= ESuperResolution.None; dlss.SetActive(false); } } if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.Q)) { dlssQuality++; dlssQuality = dlssQuality % dlssQualitys.Length; var asset = UniversalRenderPipeline.asset; DLSS dlss = null; foreach (var item in asset.GetRenderer(0).rendererFeatures) { if (item is DLSS dl) { dlss = dl; break; } } dlss.quality = (UnityEngine.NVIDIA.DLSSQuality)dlssQuality; } if (Input.GetKey(KeyCode.LeftShift) && Input.GetKeyDown(KeyCode.X)) { xessOn = !xessOn; var asset = UniversalRenderPipeline.asset; XESS xess = null; foreach (var item in asset.GetRenderer(0).rendererFeatures) { if (item is XESS xe) { xess = xe; break; } } if (xessOn) { asset.superResolution = ESuperResolution.XESS13; xess.SetSR(ESuperResolution.XESS13); } else { SuperResolutionParamSets.Instance.Set("NeedJitter", false); SuperResolutionParamSets.Instance.Set("MipmapBias", 0); asset.superResolution = ESuperResolution.None; xess.SetSR(ESuperResolution.None); } } } GUIStyle font; private void Awake() { font = new GUIStyle(); font.normal.background = null; font.normal.textColor = Color.green; font.fontSize = 32; } private void OnGUI() { //if (GUI.Button(new Rect(100,10, 100, 50), "VRS")) //{ // OnClickVRS(); //} //if (GUI.Button(new Rect(100, 100, 100, 50), "FG")) //{ // X.Rendering.Feature.FG.UseFG = !X.Rendering.Feature.FG.UseFG; //} //if (GUI.Button(new Rect(100, 200, 100, 50), "MetalSR")) // // if (Input.GetKeyDown(KeyCode.P)) //{ // var asset = UniversalRenderPipeline.asset; // asset.superResolution = ESuperResolution.METAL_FX_SPATIAL_SR; // asset.UpdateSSSettings(); //} GUI.Label(new Rect(50, 100, 300, 100), $"ctrl + r resultion:{resultions[resultionIndex]}", font); GUI.Label(new Rect(50, 150, 300, 100), $"ctrl + e dlss:{(dlssOn ? "On" : "Off")}", font); GUI.Label(new Rect(50, 200, 300, 100), $"ctrl + q quality:{dlssQualitys[dlssQuality]}", font); GUI.Label(new Rect(50, 250, 300, 100), $"shift + x xess:{(xessOn ? "On" : "Off")}", font); } public static void TestBatchMode() { Debug.Log("TestBatchMode"); } }