River Jiang
2020-10-27 1f5eda1c9d22a3676298751c7282a5874f13bed0
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
using UnityEngine;
using UnityEngine.PostProcessing;
 
namespace UnityEditor.PostProcessing
{
    using Settings = ScreenSpaceReflectionModel.Settings;
 
    [PostProcessingModelEditor(typeof(ScreenSpaceReflectionModel))]
    public class ScreenSpaceReflectionModelEditor : PostProcessingModelEditor
    {
        struct IntensitySettings
        {
            public SerializedProperty reflectionMultiplier;
            public SerializedProperty fadeDistance;
            public SerializedProperty fresnelFade;
            public SerializedProperty fresnelFadePower;
        }
 
        struct ReflectionSettings
        {
            public SerializedProperty blendType;
            public SerializedProperty reflectionQuality;
            public SerializedProperty maxDistance;
            public SerializedProperty iterationCount;
            public SerializedProperty stepSize;
            public SerializedProperty widthModifier;
            public SerializedProperty reflectionBlur;
            public SerializedProperty reflectBackfaces;
        }
 
        struct ScreenEdgeMask
        {
            public SerializedProperty intensity;
        }
 
        IntensitySettings m_Intensity;
        ReflectionSettings m_Reflection;
        ScreenEdgeMask m_ScreenEdgeMask;
 
        public override void OnEnable()
        {
            m_Intensity = new IntensitySettings
            {
                reflectionMultiplier = FindSetting((Settings x) => x.intensity.reflectionMultiplier),
                fadeDistance = FindSetting((Settings x) => x.intensity.fadeDistance),
                fresnelFade = FindSetting((Settings x) => x.intensity.fresnelFade),
                fresnelFadePower = FindSetting((Settings x) => x.intensity.fresnelFadePower)
            };
 
            m_Reflection = new ReflectionSettings
            {
                blendType = FindSetting((Settings x) => x.reflection.blendType),
                reflectionQuality = FindSetting((Settings x) => x.reflection.reflectionQuality),
                maxDistance = FindSetting((Settings x) => x.reflection.maxDistance),
                iterationCount = FindSetting((Settings x) => x.reflection.iterationCount),
                stepSize = FindSetting((Settings x) => x.reflection.stepSize),
                widthModifier = FindSetting((Settings x) => x.reflection.widthModifier),
                reflectionBlur = FindSetting((Settings x) => x.reflection.reflectionBlur),
                reflectBackfaces = FindSetting((Settings x) => x.reflection.reflectBackfaces)
            };
 
            m_ScreenEdgeMask = new ScreenEdgeMask
            {
                intensity = FindSetting((Settings x) => x.screenEdgeMask.intensity)
            };
        }
 
        public override void OnInspectorGUI()
        {
            EditorGUILayout.HelpBox("This effect only works with the deferred rendering path.", MessageType.Info);
 
            EditorGUILayout.LabelField("Reflection", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;
            EditorGUILayout.PropertyField(m_Reflection.blendType);
            EditorGUILayout.PropertyField(m_Reflection.reflectionQuality);
            EditorGUILayout.PropertyField(m_Reflection.maxDistance);
            EditorGUILayout.PropertyField(m_Reflection.iterationCount);
            EditorGUILayout.PropertyField(m_Reflection.stepSize);
            EditorGUILayout.PropertyField(m_Reflection.widthModifier);
            EditorGUILayout.PropertyField(m_Reflection.reflectionBlur);
            EditorGUILayout.PropertyField(m_Reflection.reflectBackfaces);
            EditorGUI.indentLevel--;
 
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Intensity", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;
            EditorGUILayout.PropertyField(m_Intensity.reflectionMultiplier);
            EditorGUILayout.PropertyField(m_Intensity.fadeDistance);
            EditorGUILayout.PropertyField(m_Intensity.fresnelFade);
            EditorGUILayout.PropertyField(m_Intensity.fresnelFadePower);
            EditorGUI.indentLevel--;
 
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Screen Edge Mask", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;
            EditorGUILayout.PropertyField(m_ScreenEdgeMask.intensity);
            EditorGUI.indentLevel--;
        }
    }
}