EditorDisplayMapperComponent.cpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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 <PostProcess/DisplayMapper/EditorDisplayMapperComponent.h>
  9. #include <Atom/Feature/ACES/AcesDisplayMapperFeatureProcessor.h>
  10. #include <AzCore/Asset/AssetSerializer.h>
  11. #include <AzCore/RTTI/BehaviorContext.h>
  12. namespace AZ
  13. {
  14. namespace Render
  15. {
  16. void EditorDisplayMapperComponent::Reflect(AZ::ReflectContext* context)
  17. {
  18. BaseClass::Reflect(context);
  19. if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  20. {
  21. serializeContext->Class<EditorDisplayMapperComponent, BaseClass>()
  22. ->Version(1);
  23. if (AZ::EditContext* editContext = serializeContext->GetEditContext())
  24. {
  25. editContext->Class<EditorDisplayMapperComponent>(
  26. "Display Mapper", "The display mapper applying on the look modification process.")
  27. ->ClassElement(Edit::ClassElements::EditorData, "")
  28. ->Attribute(Edit::Attributes::Category, "Graphics/PostFX")
  29. ->Attribute(AZ::Edit::Attributes::Icon, "Icons/Components/Component_Placeholder.svg") // [GFX TODO][ATOM-2672][PostFX] need to create icons for PostProcessing.
  30. ->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/Component_Placeholder.svg") // [GFX TODO][ATOM-2672][PostFX] need to create icons for PostProcessing.
  31. ->Attribute(Edit::Attributes::AppearsInAddComponentMenu, AZStd::vector<AZ::Crc32>({ AZ_CRC_CE("Level"), AZ_CRC_CE("Game") }))
  32. ->Attribute(Edit::Attributes::AutoExpand, true)
  33. ->Attribute(Edit::Attributes::HelpPageURL, "https://www.o3de.org/docs/user-guide/components/reference/atom/display-mapper/") // [GFX TODO][ATOM-2672][PostFX] need to create page for PostProcessing.
  34. ;
  35. editContext->Class<DisplayMapperComponentController>(
  36. "ToneMapperComponentControl", "")
  37. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  38. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  39. ->DataElement(AZ::Edit::UIHandlers::Default, &DisplayMapperComponentController::m_configuration, "Configuration", "")
  40. ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
  41. ;
  42. editContext->Class<AcesParameterOverrides>(
  43. "AcesParameterOverrides", "")
  44. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  45. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  46. // m_overrideDefaults
  47. ->DataElement(
  48. AZ::Edit::UIHandlers::CheckBox, &AcesParameterOverrides::m_overrideDefaults, "Override Defaults",
  49. "When enabled allows parameter overrides for ACES configuration")
  50. ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  51. // m_alterSurround
  52. ->DataElement(
  53. AZ::Edit::UIHandlers::CheckBox, &AcesParameterOverrides::m_alterSurround, "Alter Surround",
  54. "Apply gamma adjustment to compensate for dim surround")
  55. ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  56. // m_applyDesaturation
  57. ->DataElement(
  58. AZ::Edit::UIHandlers::CheckBox, &AcesParameterOverrides::m_applyDesaturation, "Alter Desaturation",
  59. "Apply desaturation to compensate for luminance difference")
  60. ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  61. // m_applyCATD60toD65
  62. ->DataElement(
  63. AZ::Edit::UIHandlers::CheckBox, &AcesParameterOverrides::m_applyCATD60toD65, "Alter CAT D60 to D65",
  64. "Apply Color appearance transform (CAT) from ACES white point to assumed observer adapted white point")
  65. ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  66. // m_cinemaLimitsBlack
  67. ->DataElement(
  68. Edit::UIHandlers::Slider, &AcesParameterOverrides::m_cinemaLimitsBlack,
  69. "Cinema Limit (black)",
  70. "Reference black luminance value")
  71. ->Attribute(AZ::Edit::Attributes::Min, 0.02f)
  72. ->Attribute(AZ::Edit::Attributes::Max, &AcesParameterOverrides::m_cinemaLimitsWhite)
  73. ->Attribute(AZ::Edit::Attributes::Step, 0.005f)
  74. ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  75. // m_cinemaLimitsWhite
  76. ->DataElement(
  77. Edit::UIHandlers::Slider, &AcesParameterOverrides::m_cinemaLimitsWhite,
  78. "Cinema Limit (white)",
  79. "Reference white luminance value")
  80. ->Attribute(AZ::Edit::Attributes::Min, &AcesParameterOverrides::m_cinemaLimitsBlack)
  81. ->Attribute(AZ::Edit::Attributes::Max, 4000.f)
  82. ->Attribute(AZ::Edit::Attributes::Step, 0.005f)
  83. ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  84. // m_minPoint
  85. ->DataElement(
  86. Edit::UIHandlers::Slider, &AcesParameterOverrides::m_minPoint, "Min Point (luminance)",
  87. "Linear extension below this")
  88. ->Attribute(AZ::Edit::Attributes::Min, 0.002f)
  89. ->Attribute(AZ::Edit::Attributes::Max, &AcesParameterOverrides::m_midPoint)
  90. ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::AttributesAndValues)
  91. // m_midPoint
  92. ->DataElement(Edit::UIHandlers::Slider, &AcesParameterOverrides::m_midPoint,
  93. "Mid Point (luminance)", "Middle gray")
  94. ->Attribute(AZ::Edit::Attributes::Min, &AcesParameterOverrides::m_minPoint)
  95. ->Attribute(AZ::Edit::Attributes::Max, &AcesParameterOverrides::m_maxPoint)
  96. ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::AttributesAndValues)
  97. // m_maxPoint
  98. ->DataElement(
  99. Edit::UIHandlers::Slider, &AcesParameterOverrides::m_maxPoint, "Max Point (luminance)",
  100. "Linear extension above this")
  101. ->Attribute(AZ::Edit::Attributes::Min, &AcesParameterOverrides::m_midPoint)
  102. ->Attribute(AZ::Edit::Attributes::Max, 4000.f)
  103. ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::AttributesAndValues)
  104. // m_surroundGamma
  105. ->DataElement(
  106. AZ::Edit::UIHandlers::Slider, &AcesParameterOverrides::m_surroundGamma, "Surround Gamma",
  107. "Gamma adjustment to be applied to compensate for the condition of the viewing environment")
  108. ->Attribute(AZ::Edit::Attributes::Min, 0.6f)
  109. ->Attribute(AZ::Edit::Attributes::Max, 1.2f)
  110. ->Attribute(AZ::Edit::Attributes::Step, 0.005f)
  111. ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  112. // m_gamma
  113. ->DataElement(
  114. AZ::Edit::UIHandlers::Slider, &AcesParameterOverrides::m_gamma, "Gamma",
  115. "Optional gamma value that is applied as basic gamma curve OETF")
  116. ->Attribute(AZ::Edit::Attributes::Min, 0.2f)
  117. ->Attribute(AZ::Edit::Attributes::Max, 4.0f)
  118. ->Attribute(AZ::Edit::Attributes::Step, 0.005f)
  119. ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  120. // Load preset group
  121. ->ClassElement(AZ::Edit::ClassElements::Group, "Load Preset")
  122. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  123. ->DataElement(
  124. Edit::UIHandlers::ComboBox, &AcesParameterOverrides::m_preset, "Preset Selection",
  125. "Allows specifying default preset for different ODT modes")
  126. ->EnumAttribute(OutputDeviceTransformType::OutputDeviceTransformType_48Nits, "48 Nits")
  127. ->EnumAttribute(OutputDeviceTransformType::OutputDeviceTransformType_1000Nits, "1000 Nits")
  128. ->EnumAttribute(OutputDeviceTransformType::OutputDeviceTransformType_2000Nits, "2000 Nits")
  129. ->EnumAttribute(OutputDeviceTransformType::OutputDeviceTransformType_4000Nits, "4000 Nits")
  130. ->UIElement(AZ::Edit::UIHandlers::Button, "Load", "Load default preset")
  131. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &AcesParameterOverrides::LoadPreset)
  132. ->Attribute(AZ::Edit::Attributes::ButtonText, "Load")
  133. ;
  134. editContext->Class<DisplayMapperComponentConfig>("ToneMapperComponentConfig", "")
  135. ->ClassElement(Edit::ClassElements::EditorData, "")
  136. ->DataElement(AZ::Edit::UIHandlers::ComboBox, &DisplayMapperComponentConfig::m_displayMapperOperation, "Type", "Display Mapper Type.")
  137. ->Attribute(AZ::Edit::Attributes::EnumValues, AZ::Edit::GetEnumConstantsFromTraits<DisplayMapperOperationType>())
  138. ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  139. ->DataElement(Edit::UIHandlers::CheckBox,
  140. &DisplayMapperComponentConfig::m_ldrColorGradingLutEnabled,
  141. "Enable LDR color grading LUT",
  142. "Enable LDR color grading LUT.")
  143. ->DataElement(AZ::Edit::UIHandlers::Default, &DisplayMapperComponentConfig::m_ldrColorGradingLut, "LDR color Grading LUT", "LDR color grading LUT")
  144. ->DataElement(AZ::Edit::UIHandlers::Default, &DisplayMapperComponentConfig::m_acesParameterOverrides, "ACES Parameters", "Parameter overrides for ACES.")
  145. ;
  146. }
  147. }
  148. if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
  149. {
  150. behaviorContext->Class<EditorDisplayMapperComponent>()->RequestBus("DisplayMapperComponentRequestBus");
  151. behaviorContext->ConstantProperty("EditorDisplayMapperComponentTypeId", BehaviorConstant(Uuid(EditorDisplayMapperComponentTypeId)))
  152. ->Attribute(AZ::Script::Attributes::Module, "render")
  153. ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
  154. }
  155. }
  156. EditorDisplayMapperComponent::EditorDisplayMapperComponent(const DisplayMapperComponentConfig& config)
  157. : BaseClass(config)
  158. {
  159. }
  160. u32 EditorDisplayMapperComponent::OnConfigurationChanged()
  161. {
  162. m_controller.OnConfigChanged();
  163. return Edit::PropertyRefreshLevels::AttributesAndValues;
  164. }
  165. }
  166. }