You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
4.3 KiB

  1. using UnityEngine;
  2. using UnityEngine.PostProcessing;
  3. namespace UnityEditor.PostProcessing
  4. {
  5. using Settings = ScreenSpaceReflectionModel.Settings;
  6. [PostProcessingModelEditor(typeof(ScreenSpaceReflectionModel))]
  7. public class ScreenSpaceReflectionModelEditor : PostProcessingModelEditor
  8. {
  9. struct IntensitySettings
  10. {
  11. public SerializedProperty reflectionMultiplier;
  12. public SerializedProperty fadeDistance;
  13. public SerializedProperty fresnelFade;
  14. public SerializedProperty fresnelFadePower;
  15. }
  16. struct ReflectionSettings
  17. {
  18. public SerializedProperty blendType;
  19. public SerializedProperty reflectionQuality;
  20. public SerializedProperty maxDistance;
  21. public SerializedProperty iterationCount;
  22. public SerializedProperty stepSize;
  23. public SerializedProperty widthModifier;
  24. public SerializedProperty reflectionBlur;
  25. public SerializedProperty reflectBackfaces;
  26. }
  27. struct ScreenEdgeMask
  28. {
  29. public SerializedProperty intensity;
  30. }
  31. IntensitySettings m_Intensity;
  32. ReflectionSettings m_Reflection;
  33. ScreenEdgeMask m_ScreenEdgeMask;
  34. public override void OnEnable()
  35. {
  36. m_Intensity = new IntensitySettings
  37. {
  38. reflectionMultiplier = FindSetting((Settings x) => x.intensity.reflectionMultiplier),
  39. fadeDistance = FindSetting((Settings x) => x.intensity.fadeDistance),
  40. fresnelFade = FindSetting((Settings x) => x.intensity.fresnelFade),
  41. fresnelFadePower = FindSetting((Settings x) => x.intensity.fresnelFadePower)
  42. };
  43. m_Reflection = new ReflectionSettings
  44. {
  45. blendType = FindSetting((Settings x) => x.reflection.blendType),
  46. reflectionQuality = FindSetting((Settings x) => x.reflection.reflectionQuality),
  47. maxDistance = FindSetting((Settings x) => x.reflection.maxDistance),
  48. iterationCount = FindSetting((Settings x) => x.reflection.iterationCount),
  49. stepSize = FindSetting((Settings x) => x.reflection.stepSize),
  50. widthModifier = FindSetting((Settings x) => x.reflection.widthModifier),
  51. reflectionBlur = FindSetting((Settings x) => x.reflection.reflectionBlur),
  52. reflectBackfaces = FindSetting((Settings x) => x.reflection.reflectBackfaces)
  53. };
  54. m_ScreenEdgeMask = new ScreenEdgeMask
  55. {
  56. intensity = FindSetting((Settings x) => x.screenEdgeMask.intensity)
  57. };
  58. }
  59. public override void OnInspectorGUI()
  60. {
  61. EditorGUILayout.HelpBox("This effect only works with the deferred rendering path.", MessageType.Info);
  62. EditorGUILayout.LabelField("Reflection", EditorStyles.boldLabel);
  63. EditorGUI.indentLevel++;
  64. EditorGUILayout.PropertyField(m_Reflection.blendType);
  65. EditorGUILayout.PropertyField(m_Reflection.reflectionQuality);
  66. EditorGUILayout.PropertyField(m_Reflection.maxDistance);
  67. EditorGUILayout.PropertyField(m_Reflection.iterationCount);
  68. EditorGUILayout.PropertyField(m_Reflection.stepSize);
  69. EditorGUILayout.PropertyField(m_Reflection.widthModifier);
  70. EditorGUILayout.PropertyField(m_Reflection.reflectionBlur);
  71. EditorGUILayout.PropertyField(m_Reflection.reflectBackfaces);
  72. EditorGUI.indentLevel--;
  73. EditorGUILayout.Space();
  74. EditorGUILayout.LabelField("Intensity", EditorStyles.boldLabel);
  75. EditorGUI.indentLevel++;
  76. EditorGUILayout.PropertyField(m_Intensity.reflectionMultiplier);
  77. EditorGUILayout.PropertyField(m_Intensity.fadeDistance);
  78. EditorGUILayout.PropertyField(m_Intensity.fresnelFade);
  79. EditorGUILayout.PropertyField(m_Intensity.fresnelFadePower);
  80. EditorGUI.indentLevel--;
  81. EditorGUILayout.Space();
  82. EditorGUILayout.LabelField("Screen Edge Mask", EditorStyles.boldLabel);
  83. EditorGUI.indentLevel++;
  84. EditorGUILayout.PropertyField(m_ScreenEdgeMask.intensity);
  85. EditorGUI.indentLevel--;
  86. }
  87. }
  88. }