GlobalDynamicResolutionSettings.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. namespace UnityEngine.Rendering
  3. {
  4. /// <summary>
  5. /// Types of dynamic resolution that can be requested. Note that if Hardware is selected, but not available on the platform, the system will fallback to Software.
  6. /// </summary>
  7. public enum DynamicResolutionType : byte
  8. {
  9. /// <summary>
  10. /// Software dynamic resolution.
  11. /// </summary>
  12. Software,
  13. /// <summary>
  14. /// Hardware dynamic resolution.
  15. /// </summary>
  16. Hardware,
  17. }
  18. /// <summary>
  19. /// Types of filters that can be used to upscale rendered result to native resolution.
  20. /// </summary>
  21. public enum DynamicResUpscaleFilter : byte
  22. {
  23. /// <summary>
  24. /// Bilinear upscaling filter.
  25. /// </summary>
  26. Bilinear,
  27. /// <summary>
  28. /// Bicubic Catmull-Rom upscaling filter.
  29. /// </summary>
  30. CatmullRom,
  31. /// <summary>
  32. /// Lanczos upscaling filter.
  33. /// </summary>
  34. Lanczos,
  35. /// <summary>
  36. /// Contrast Adaptive Sharpening upscaling filter.
  37. /// </summary>
  38. ContrastAdaptiveSharpen,
  39. }
  40. /// <summary>User-facing settings for dynamic resolution.</summary>
  41. [Serializable]
  42. public struct GlobalDynamicResolutionSettings
  43. {
  44. /// <summary>Default GlobalDynamicResolutionSettings</summary>
  45. /// <returns></returns>
  46. public static GlobalDynamicResolutionSettings NewDefault() => new GlobalDynamicResolutionSettings()
  47. {
  48. maxPercentage = 100.0f,
  49. minPercentage = 100.0f,
  50. // It fall-backs to software when not supported, so it makes sense to have it on by default.
  51. dynResType = DynamicResolutionType.Hardware,
  52. upsampleFilter = DynamicResUpscaleFilter.CatmullRom,
  53. forcedPercentage = 100.0f
  54. };
  55. /// <summary>Select whether the dynamic resolution is enabled or not.</summary>
  56. public bool enabled;
  57. /// <summary>The maximum resolution percentage that dynamic resolution can reach.</summary>
  58. public float maxPercentage;
  59. /// <summary>The minimum resolution percentage that dynamic resolution can reach.</summary>
  60. public float minPercentage;
  61. /// <summary>The type of dynamic resolution method.</summary>
  62. public DynamicResolutionType dynResType;
  63. /// <summary>The type of upscaling filter to use.</summary>
  64. public DynamicResUpscaleFilter upsampleFilter;
  65. /// <summary>Select whether dynamic resolution system will force a specific resolution percentage.</summary>
  66. public bool forceResolution;
  67. /// <summary>The resolution percentage forced in case forceResolution is set to true.</summary>
  68. public float forcedPercentage;
  69. }
  70. }