5 namespace UnityStandardAssets.ImageEffects
7 [CustomEditor (typeof(Bloom))]
10 SerializedProperty tweakMode;
11 SerializedProperty screenBlendMode;
13 SerializedObject serObj;
15 SerializedProperty hdr;
16 SerializedProperty quality;
17 SerializedProperty sepBlurSpread;
19 SerializedProperty bloomIntensity;
20 SerializedProperty bloomThresholdColor;
21 SerializedProperty bloomThreshold;
22 SerializedProperty bloomBlurIterations;
24 SerializedProperty hollywoodFlareBlurIterations;
26 SerializedProperty lensflareMode;
27 SerializedProperty hollyStretchWidth;
28 SerializedProperty lensflareIntensity;
29 SerializedProperty flareRotation;
30 SerializedProperty lensFlareSaturation;
31 SerializedProperty lensflareThreshold;
32 SerializedProperty flareColorA;
33 SerializedProperty flareColorB;
34 SerializedProperty flareColorC;
35 SerializedProperty flareColorD;
37 SerializedProperty lensFlareVignetteMask;
40 serObj =
new SerializedObject (target);
42 screenBlendMode = serObj.FindProperty(
"screenBlendMode");
43 hdr = serObj.FindProperty(
"hdr");
44 quality = serObj.FindProperty(
"quality");
46 sepBlurSpread = serObj.FindProperty(
"sepBlurSpread");
48 bloomIntensity = serObj.FindProperty(
"bloomIntensity");
49 bloomThreshold = serObj.FindProperty(
"bloomThreshold");
50 bloomThresholdColor = serObj.FindProperty(
"bloomThresholdColor");
51 bloomBlurIterations = serObj.FindProperty(
"bloomBlurIterations");
53 lensflareMode = serObj.FindProperty(
"lensflareMode");
54 hollywoodFlareBlurIterations = serObj.FindProperty(
"hollywoodFlareBlurIterations");
55 hollyStretchWidth = serObj.FindProperty(
"hollyStretchWidth");
56 lensflareIntensity = serObj.FindProperty(
"lensflareIntensity");
57 lensflareThreshold = serObj.FindProperty(
"lensflareThreshold");
58 lensFlareSaturation = serObj.FindProperty(
"lensFlareSaturation");
59 flareRotation = serObj.FindProperty(
"flareRotation");
60 flareColorA = serObj.FindProperty(
"flareColorA");
61 flareColorB = serObj.FindProperty(
"flareColorB");
62 flareColorC = serObj.FindProperty(
"flareColorC");
63 flareColorD = serObj.FindProperty(
"flareColorD");
64 lensFlareVignetteMask = serObj.FindProperty(
"lensFlareVignetteMask");
66 tweakMode = serObj.FindProperty(
"tweakMode");
70 public override void OnInspectorGUI () {
73 EditorGUILayout.LabelField(
"Glow and Lens Flares for bright screen pixels", EditorStyles.miniLabel);
75 EditorGUILayout.PropertyField (quality,
new GUIContent(
"Quality",
"High quality preserves high frequencies with bigger blurs and uses a better blending and down-/upsampling"));
77 EditorGUILayout.Separator ();
79 EditorGUILayout.PropertyField (tweakMode,
new GUIContent(
"Mode"));
80 EditorGUILayout.PropertyField (screenBlendMode,
new GUIContent(
"Blend"));
81 EditorGUILayout.PropertyField (hdr,
new GUIContent(
"HDR"));
83 EditorGUILayout.Separator ();
86 Camera cam = (target as
Bloom).GetComponent<Camera>();
88 if (screenBlendMode.enumValueIndex==0 && ((cam.hdr && hdr.enumValueIndex==0) || (hdr.enumValueIndex==1))) {
89 EditorGUILayout.HelpBox(
"Screen blend is not supported in HDR. Using 'Add' instead.", MessageType.Info);
93 EditorGUILayout.PropertyField (bloomIntensity,
new GUIContent(
"Intensity"));
94 bloomThreshold.floatValue = EditorGUILayout.Slider (
"Threshold", bloomThreshold.floatValue, -0.05f, 4.0f);
95 if (1 == tweakMode.intValue) {
96 EditorGUILayout.PropertyField(bloomThresholdColor,
new GUIContent(
" RGB Threshold"));
98 EditorGUILayout.Separator ();
100 bloomBlurIterations.intValue = EditorGUILayout.IntSlider (
"Blur Iterations", bloomBlurIterations.intValue, 1, 4);
101 sepBlurSpread.floatValue = EditorGUILayout.Slider (
" Sample Distance", sepBlurSpread.floatValue, 0.1f, 10.0f);
102 EditorGUILayout.Separator ();
104 if (1 == tweakMode.intValue) {
106 if (0 != tweakMode.intValue)
107 EditorGUILayout.PropertyField (lensflareMode,
new GUIContent(
"Lens Flares"));
109 lensflareMode.enumValueIndex = 0;
111 EditorGUILayout.PropertyField (lensflareIntensity,
new GUIContent(
" Local Intensity",
"0 disables lens flares entirely (optimization)"));
112 lensflareThreshold.floatValue = EditorGUILayout.Slider (
"Threshold", lensflareThreshold.floatValue, 0.0f, 4.0f);
114 if (Mathf.Abs(lensflareIntensity.floatValue) > Mathf.Epsilon) {
115 if (lensflareMode.intValue == 0) {
117 EditorGUILayout.BeginHorizontal ();
118 EditorGUILayout.PropertyField (flareColorA,
new GUIContent(
" 1st Color"));
119 EditorGUILayout.PropertyField (flareColorB,
new GUIContent(
" 2nd Color"));
120 EditorGUILayout.EndHorizontal ();
122 EditorGUILayout.BeginHorizontal ();
123 EditorGUILayout.PropertyField (flareColorC,
new GUIContent(
" 3rd Color"));
124 EditorGUILayout.PropertyField (flareColorD,
new GUIContent(
" 4th Color"));
125 EditorGUILayout.EndHorizontal ();
127 else if (lensflareMode.intValue == 1) {
129 EditorGUILayout.PropertyField (hollyStretchWidth,
new GUIContent(
" Stretch width"));
130 EditorGUILayout.PropertyField (flareRotation,
new GUIContent(
" Rotation"));
131 hollywoodFlareBlurIterations.intValue = EditorGUILayout.IntSlider (
" Blur Iterations", hollywoodFlareBlurIterations.intValue, 1, 4);
133 EditorGUILayout.PropertyField (lensFlareSaturation,
new GUIContent(
" Saturation"));
134 EditorGUILayout.PropertyField (flareColorA,
new GUIContent(
" Tint Color"));
136 else if (lensflareMode.intValue == 2) {
138 EditorGUILayout.PropertyField (hollyStretchWidth,
new GUIContent(
" Stretch width"));
139 hollywoodFlareBlurIterations.intValue = EditorGUILayout.IntSlider (
" Blur Iterations", hollywoodFlareBlurIterations.intValue, 1, 4);
141 EditorGUILayout.PropertyField (lensFlareSaturation,
new GUIContent(
" Saturation"));
143 EditorGUILayout.BeginHorizontal ();
144 EditorGUILayout.PropertyField (flareColorA,
new GUIContent(
" 1st Color"));
145 EditorGUILayout.PropertyField (flareColorB,
new GUIContent(
" 2nd Color"));
146 EditorGUILayout.EndHorizontal ();
148 EditorGUILayout.BeginHorizontal ();
149 EditorGUILayout.PropertyField (flareColorC,
new GUIContent(
" 3rd Color"));
150 EditorGUILayout.PropertyField (flareColorD,
new GUIContent(
" 4th Color"));
151 EditorGUILayout.EndHorizontal ();
154 EditorGUILayout.PropertyField(lensFlareVignetteMask,
new GUIContent(
" Mask",
"This mask is needed to prevent lens flare artifacts"));
159 serObj.ApplyModifiedProperties();