summaryrefslogtreecommitdiff
path: root/UnityEngine.PostProcessing/BloomModel.cs
blob: 0569d626c5376a542ec7e26cbf36eca000edefcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using System;

namespace UnityEngine.PostProcessing;

[Serializable]
public class BloomModel : PostProcessingModel
{
	[Serializable]
	public struct BloomSettings
	{
		[Min(0f)]
		[Tooltip("Strength of the bloom filter.")]
		public float intensity;

		[Min(0f)]
		[Tooltip("Filters out pixels under this level of brightness.")]
		public float threshold;

		[Range(0f, 1f)]
		[Tooltip("Makes transition between under/over-threshold gradual (0 = hard threshold, 1 = soft threshold).")]
		public float softKnee;

		[Range(1f, 7f)]
		[Tooltip("Changes extent of veiling effects in a screen resolution-independent fashion.")]
		public float radius;

		[Tooltip("Reduces flashing noise with an additional filter.")]
		public bool antiFlicker;

		public float thresholdLinear
		{
			get
			{
				return Mathf.GammaToLinearSpace(threshold);
			}
			set
			{
				threshold = Mathf.LinearToGammaSpace(value);
			}
		}

		public static BloomSettings defaultSettings
		{
			get
			{
				BloomSettings result = default(BloomSettings);
				result.intensity = 0.5f;
				result.threshold = 1.1f;
				result.softKnee = 0.5f;
				result.radius = 4f;
				result.antiFlicker = false;
				return result;
			}
		}
	}

	[Serializable]
	public struct LensDirtSettings
	{
		[Tooltip("Dirtiness texture to add smudges or dust to the lens.")]
		public Texture texture;

		[Min(0f)]
		[Tooltip("Amount of lens dirtiness.")]
		public float intensity;

		public static LensDirtSettings defaultSettings
		{
			get
			{
				LensDirtSettings result = default(LensDirtSettings);
				result.texture = null;
				result.intensity = 3f;
				return result;
			}
		}
	}

	[Serializable]
	public struct Settings
	{
		public BloomSettings bloom;

		public LensDirtSettings lensDirt;

		public static Settings defaultSettings
		{
			get
			{
				Settings result = default(Settings);
				result.bloom = BloomSettings.defaultSettings;
				result.lensDirt = LensDirtSettings.defaultSettings;
				return result;
			}
		}
	}

	[SerializeField]
	private Settings m_Settings = Settings.defaultSettings;

	public Settings settings
	{
		get
		{
			return m_Settings;
		}
		set
		{
			m_Settings = value;
		}
	}

	public override void Reset()
	{
		m_Settings = Settings.defaultSettings;
	}
}