EditorExposureControlComponent.cpp 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <AzCore/RTTI/BehaviorContext.h>
  9. #include <PostProcess/ExposureControl/EditorExposureControlComponent.h>
  10. namespace AZ
  11. {
  12. namespace Render
  13. {
  14. void EditorExposureControlComponent::Reflect(AZ::ReflectContext* context)
  15. {
  16. BaseClass::Reflect(context);
  17. if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  18. {
  19. serializeContext->Class<EditorExposureControlComponent, BaseClass>()
  20. ->Version(1);
  21. if (AZ::EditContext* editContext = serializeContext->GetEditContext())
  22. {
  23. editContext->Class<EditorExposureControlComponent>(
  24. "Exposure Control", "Exposure component control exposure value for rendered scene.")
  25. ->ClassElement(Edit::ClassElements::EditorData, "")
  26. ->Attribute(Edit::Attributes::Category, "Graphics/PostFX")
  27. ->Attribute(AZ::Edit::Attributes::Icon, "Icons/Components/Component_Placeholder.svg") // [GFX TODO ATOM-2672][PostFX] need to create icons for PostProcessing.
  28. ->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/Component_Placeholder.svg") // [GFX TODO ATOM-2672][PostFX] need to create icons for PostProcessing.
  29. ->Attribute(Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Game"))
  30. ->Attribute(Edit::Attributes::AutoExpand, true)
  31. ->Attribute(Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/atom/exposure-control/") // [TODO ATOM-2672][PostFX] need create page for PostProcessing.
  32. ;
  33. editContext->Class<ExposureControlComponentController>(
  34. "ExposureControlComponentController", "")
  35. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  36. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  37. ->DataElement(AZ::Edit::UIHandlers::Default, &ExposureControlComponentController::m_configuration, "Configuration", "")
  38. ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
  39. ;
  40. editContext->Class<ExposureControlComponentConfig>("ExposureControlComponentConfig", "")
  41. ->DataElement(Edit::UIHandlers::CheckBox,
  42. &ExposureControlComponentConfig::m_enabled,
  43. "Enable",
  44. "Enable exposure control.")
  45. ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  46. ->ClassElement(Edit::ClassElements::EditorData, "")
  47. ->DataElement(Edit::UIHandlers::ComboBox,
  48. &ExposureControlComponentConfig::m_exposureControlType,
  49. "Control Type",
  50. "How to control a exposure value.")
  51. ->EnumAttribute(AZ::Render::ExposureControl::ExposureControlType::ManualOnly, "Manual Only")
  52. ->EnumAttribute(AZ::Render::ExposureControl::ExposureControlType::EyeAdaptation, "Eye Adaptation")
  53. ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  54. ->Attribute(Edit::Attributes::ReadOnly, &ExposureControlComponentConfig::ArePropertiesReadOnly)
  55. ->DataElement(AZ::Edit::UIHandlers::Slider, &ExposureControlComponentConfig::m_manualCompensationValue, "Manual Compensation", "Manual exposure compensation value.")
  56. ->Attribute(AZ::Edit::Attributes::Min, -16.0f)
  57. ->Attribute(AZ::Edit::Attributes::Max, 16.0f)
  58. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  59. ->Attribute(Edit::Attributes::ReadOnly, &ExposureControlComponentConfig::ArePropertiesReadOnly)
  60. ->ClassElement(AZ::Edit::ClassElements::Group, "Eye Adaptation")
  61. ->Attribute(Edit::Attributes::Visibility, &ExposureControlComponentConfig::IsEyeAdaptation)
  62. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  63. ->DataElement(AZ::Edit::UIHandlers::Slider, &ExposureControlComponentConfig::m_autoExposureMin, "Minimum Exposure", "Minimum exposure value for the auto exposure.")
  64. ->Attribute(AZ::Edit::Attributes::Min, -16.0f)
  65. ->Attribute(AZ::Edit::Attributes::Max, 16.0f)
  66. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  67. ->Attribute(Edit::Attributes::ReadOnly, &ExposureControlComponentConfig::ArePropertiesReadOnly)
  68. ->DataElement(AZ::Edit::UIHandlers::Slider, &ExposureControlComponentConfig::m_autoExposureMax, "Maximum Exposure", "Maximum exposure value for the auto exposure.")
  69. ->Attribute(AZ::Edit::Attributes::Min, -16.0f)
  70. ->Attribute(AZ::Edit::Attributes::Max, 16.0f)
  71. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  72. ->Attribute(Edit::Attributes::ReadOnly, &ExposureControlComponentConfig::ArePropertiesReadOnly)
  73. ->DataElement(AZ::Edit::UIHandlers::Slider, &ExposureControlComponentConfig::m_autoExposureSpeedUp, "Speed Up", "The speed at which auto exposure adapts to bright scenes.")
  74. ->Attribute(AZ::Edit::Attributes::Min, 0.01)
  75. ->Attribute(AZ::Edit::Attributes::Max, 10.0f)
  76. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  77. ->Attribute(Edit::Attributes::ReadOnly, &ExposureControlComponentConfig::ArePropertiesReadOnly)
  78. ->DataElement(AZ::Edit::UIHandlers::Slider, &ExposureControlComponentConfig::m_autoExposureSpeedDown, "Speed Down", "The speed at which auto exposure adapts to dark scenes.")
  79. ->Attribute(AZ::Edit::Attributes::Min, 0.01)
  80. ->Attribute(AZ::Edit::Attributes::Max, 10.0f)
  81. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  82. ->Attribute(Edit::Attributes::ReadOnly, &ExposureControlComponentConfig::ArePropertiesReadOnly)
  83. ->DataElement(Edit::UIHandlers::CheckBox, &ExposureControlComponentConfig::m_heatmapEnabled, "Enable Heatmap", "Areas below minimum exposure will be highlighted in blue. Areas above in red.")
  84. // Overrides
  85. ->ClassElement(AZ::Edit::ClassElements::Group, "Overrides")
  86. ->Attribute(AZ::Edit::Attributes::AutoExpand, false)
  87. // Auto-gen editor context settings for overrides
  88. #define EDITOR_CLASS ExposureControlComponentConfig
  89. #include <Atom/Feature/ParamMacros/StartOverrideEditorContext.inl>
  90. #include <Atom/Feature/PostProcess/ExposureControl/ExposureControlParams.inl>
  91. #include <Atom/Feature/ParamMacros/EndParams.inl>
  92. #undef EDITOR_CLASS
  93. ;
  94. }
  95. }
  96. if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
  97. {
  98. behaviorContext->Class<EditorExposureControlComponent>()->RequestBus("ExposureControlRequestBus");
  99. behaviorContext->ConstantProperty("EditorExposureControlComponentTypeId", BehaviorConstant(Uuid(EditorExposureControlComponentTypeId)))
  100. ->Attribute(AZ::Script::Attributes::Module, "render")
  101. ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
  102. }
  103. }
  104. EditorExposureControlComponent::EditorExposureControlComponent(const ExposureControlComponentConfig& config)
  105. : BaseClass(config)
  106. {
  107. }
  108. u32 EditorExposureControlComponent::OnConfigurationChanged()
  109. {
  110. m_controller.OnConfigChanged();
  111. return Edit::PropertyRefreshLevels::AttributesAndValues;
  112. }
  113. }
  114. }