BloomModel.cs 2.9 KB

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