BloomModel.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. using System;
  2. namespace UnityEngine.PostProcessing
  3. {
  4. [Serializable]
  5. public class BloomModel : PostProcessingModel
  6. {
  7. public BloomModel.Settings settings
  8. {
  9. get
  10. {
  11. return this.m_Settings;
  12. }
  13. set
  14. {
  15. this.m_Settings = value;
  16. }
  17. }
  18. public override void Reset()
  19. {
  20. this.m_Settings = BloomModel.Settings.defaultSettings;
  21. }
  22. [SerializeField]
  23. private BloomModel.Settings m_Settings = BloomModel.Settings.defaultSettings;
  24. [Serializable]
  25. public struct BloomSettings
  26. {
  27. public float thresholdLinear
  28. {
  29. get
  30. {
  31. return Mathf.GammaToLinearSpace(this.threshold);
  32. }
  33. set
  34. {
  35. this.threshold = Mathf.LinearToGammaSpace(value);
  36. }
  37. }
  38. public static BloomModel.BloomSettings defaultSettings
  39. {
  40. get
  41. {
  42. return new BloomModel.BloomSettings
  43. {
  44. intensity = 0.5f,
  45. threshold = 1.1f,
  46. softKnee = 0.5f,
  47. radius = 4f,
  48. antiFlicker = false
  49. };
  50. }
  51. }
  52. [Min(0f)]
  53. [Tooltip("Strength of the bloom filter.")]
  54. public float intensity;
  55. [Min(0f)]
  56. [Tooltip("Filters out pixels under this level of brightness.")]
  57. public float threshold;
  58. [Range(0f, 1f)]
  59. [Tooltip("Makes transition between under/over-threshold gradual (0 = hard threshold, 1 = soft threshold).")]
  60. public float softKnee;
  61. [Range(1f, 7f)]
  62. [Tooltip("Changes extent of veiling effects in a screen resolution-independent fashion.")]
  63. public float radius;
  64. [Tooltip("Reduces flashing noise with an additional filter.")]
  65. public bool antiFlicker;
  66. }
  67. [Serializable]
  68. public struct LensDirtSettings
  69. {
  70. public static BloomModel.LensDirtSettings defaultSettings
  71. {
  72. get
  73. {
  74. return new BloomModel.LensDirtSettings
  75. {
  76. texture = null,
  77. intensity = 3f
  78. };
  79. }
  80. }
  81. [Tooltip("Dirtiness texture to add smudges or dust to the lens.")]
  82. public Texture texture;
  83. [Min(0f)]
  84. [Tooltip("Amount of lens dirtiness.")]
  85. public float intensity;
  86. }
  87. [Serializable]
  88. public struct Settings
  89. {
  90. public static BloomModel.Settings defaultSettings
  91. {
  92. get
  93. {
  94. return new BloomModel.Settings
  95. {
  96. bloom = BloomModel.BloomSettings.defaultSettings,
  97. lensDirt = BloomModel.LensDirtSettings.defaultSettings
  98. };
  99. }
  100. }
  101. public BloomModel.BloomSettings bloom;
  102. public BloomModel.LensDirtSettings lensDirt;
  103. }
  104. }
  105. }