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.

86 lines
3.8 KiB

  1. using UnityEngine;
  2. using UnityEngine.PostProcessing;
  3. namespace UnityEditor.PostProcessing
  4. {
  5. using Settings = EyeAdaptationModel.Settings;
  6. [PostProcessingModelEditor(typeof(EyeAdaptationModel))]
  7. public class EyeAdaptationModelEditor : PostProcessingModelEditor
  8. {
  9. SerializedProperty m_LowPercent;
  10. SerializedProperty m_HighPercent;
  11. SerializedProperty m_MinLuminance;
  12. SerializedProperty m_MaxLuminance;
  13. SerializedProperty m_KeyValue;
  14. SerializedProperty m_DynamicKeyValue;
  15. SerializedProperty m_AdaptationType;
  16. SerializedProperty m_SpeedUp;
  17. SerializedProperty m_SpeedDown;
  18. SerializedProperty m_LogMin;
  19. SerializedProperty m_LogMax;
  20. public override void OnEnable()
  21. {
  22. m_LowPercent = FindSetting((Settings x) => x.lowPercent);
  23. m_HighPercent = FindSetting((Settings x) => x.highPercent);
  24. m_MinLuminance = FindSetting((Settings x) => x.minLuminance);
  25. m_MaxLuminance = FindSetting((Settings x) => x.maxLuminance);
  26. m_KeyValue = FindSetting((Settings x) => x.keyValue);
  27. m_DynamicKeyValue = FindSetting((Settings x) => x.dynamicKeyValue);
  28. m_AdaptationType = FindSetting((Settings x) => x.adaptationType);
  29. m_SpeedUp = FindSetting((Settings x) => x.speedUp);
  30. m_SpeedDown = FindSetting((Settings x) => x.speedDown);
  31. m_LogMin = FindSetting((Settings x) => x.logMin);
  32. m_LogMax = FindSetting((Settings x) => x.logMax);
  33. }
  34. public override void OnInspectorGUI()
  35. {
  36. if (!GraphicsUtils.supportsDX11)
  37. EditorGUILayout.HelpBox("This effect requires support for compute shaders. Enabling it won't do anything on unsupported platforms.", MessageType.Warning);
  38. EditorGUILayout.LabelField("Luminosity range", EditorStyles.boldLabel);
  39. EditorGUI.indentLevel++;
  40. EditorGUILayout.PropertyField(m_LogMin, EditorGUIHelper.GetContent("Minimum (EV)"));
  41. EditorGUILayout.PropertyField(m_LogMax, EditorGUIHelper.GetContent("Maximum (EV)"));
  42. EditorGUI.indentLevel--;
  43. EditorGUILayout.Space();
  44. EditorGUILayout.LabelField("Auto exposure", EditorStyles.boldLabel);
  45. EditorGUI.indentLevel++;
  46. float low = m_LowPercent.floatValue;
  47. float high = m_HighPercent.floatValue;
  48. EditorGUILayout.MinMaxSlider(EditorGUIHelper.GetContent("Histogram filtering|These values are the lower and upper percentages of the histogram that will be used to find a stable average luminance. Values outside of this range will be discarded and won't contribute to the average luminance."), ref low, ref high, 1f, 99f);
  49. m_LowPercent.floatValue = low;
  50. m_HighPercent.floatValue = high;
  51. EditorGUILayout.PropertyField(m_MinLuminance, EditorGUIHelper.GetContent("Minimum (EV)"));
  52. EditorGUILayout.PropertyField(m_MaxLuminance, EditorGUIHelper.GetContent("Maximum (EV)"));
  53. EditorGUILayout.PropertyField(m_DynamicKeyValue);
  54. if (!m_DynamicKeyValue.boolValue)
  55. EditorGUILayout.PropertyField(m_KeyValue);
  56. EditorGUI.indentLevel--;
  57. EditorGUILayout.Space();
  58. EditorGUILayout.LabelField("Adaptation", EditorStyles.boldLabel);
  59. EditorGUI.indentLevel++;
  60. EditorGUILayout.PropertyField(m_AdaptationType, EditorGUIHelper.GetContent("Type"));
  61. if (m_AdaptationType.intValue == (int)EyeAdaptationModel.EyeAdaptationType.Progressive)
  62. {
  63. EditorGUI.indentLevel++;
  64. EditorGUILayout.PropertyField(m_SpeedUp);
  65. EditorGUILayout.PropertyField(m_SpeedDown);
  66. EditorGUI.indentLevel--;
  67. }
  68. EditorGUI.indentLevel--;
  69. }
  70. }
  71. }