BuiltinDebugViewsModel.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using System;
  2. namespace UnityEngine.PostProcessing
  3. {
  4. [Serializable]
  5. public class BuiltinDebugViewsModel : PostProcessingModel
  6. {
  7. [Serializable]
  8. public struct DepthSettings
  9. {
  10. [Range(0f, 1f), Tooltip("Scales the camera far plane before displaying the depth map.")]
  11. public float scale;
  12. public static DepthSettings defaultSettings
  13. {
  14. get
  15. {
  16. return new DepthSettings
  17. {
  18. scale = 1f
  19. };
  20. }
  21. }
  22. }
  23. [Serializable]
  24. public struct MotionVectorsSettings
  25. {
  26. [Range(0f, 1f), Tooltip("Opacity of the source render.")]
  27. public float sourceOpacity;
  28. [Range(0f, 1f), Tooltip("Opacity of the per-pixel motion vector colors.")]
  29. public float motionImageOpacity;
  30. [Min(0f), Tooltip("Because motion vectors are mainly very small vectors, you can use this setting to make them more visible.")]
  31. public float motionImageAmplitude;
  32. [Range(0f, 1f), Tooltip("Opacity for the motion vector arrows.")]
  33. public float motionVectorsOpacity;
  34. [Range(8, 64), Tooltip("The arrow density on screen.")]
  35. public int motionVectorsResolution;
  36. [Min(0f), Tooltip("Tweaks the arrows length.")]
  37. public float motionVectorsAmplitude;
  38. public static MotionVectorsSettings defaultSettings
  39. {
  40. get
  41. {
  42. return new MotionVectorsSettings
  43. {
  44. sourceOpacity = 1f,
  45. motionImageOpacity = 0f,
  46. motionImageAmplitude = 16f,
  47. motionVectorsOpacity = 1f,
  48. motionVectorsResolution = 24,
  49. motionVectorsAmplitude = 64f
  50. };
  51. }
  52. }
  53. }
  54. public enum Mode
  55. {
  56. None,
  57. Depth,
  58. Normals,
  59. MotionVectors,
  60. AmbientOcclusion,
  61. EyeAdaptation,
  62. FocusPlane,
  63. PreGradingLog,
  64. LogLut,
  65. UserLut
  66. }
  67. [Serializable]
  68. public struct Settings
  69. {
  70. public Mode mode;
  71. public DepthSettings depth;
  72. public MotionVectorsSettings motionVectors;
  73. public static Settings defaultSettings
  74. {
  75. get
  76. {
  77. return new Settings
  78. {
  79. mode = Mode.None,
  80. depth = DepthSettings.defaultSettings,
  81. motionVectors = MotionVectorsSettings.defaultSettings
  82. };
  83. }
  84. }
  85. }
  86. [SerializeField]
  87. Settings m_Settings = Settings.defaultSettings;
  88. public Settings settings
  89. {
  90. get { return m_Settings; }
  91. set { m_Settings = value; }
  92. }
  93. public bool willInterrupt
  94. {
  95. get
  96. {
  97. return !IsModeActive(Mode.None)
  98. && !IsModeActive(Mode.EyeAdaptation)
  99. && !IsModeActive(Mode.PreGradingLog)
  100. && !IsModeActive(Mode.LogLut)
  101. && !IsModeActive(Mode.UserLut);
  102. }
  103. }
  104. public override void Reset()
  105. {
  106. settings = Settings.defaultSettings;
  107. }
  108. public bool IsModeActive(Mode mode)
  109. {
  110. return m_Settings.mode == mode;
  111. }
  112. }
  113. }