EditorBloomComponent.cpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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/Bloom/EditorBloomComponent.h>
  10. namespace AZ
  11. {
  12. namespace Render
  13. {
  14. void EditorBloomComponent::Reflect(AZ::ReflectContext* context)
  15. {
  16. BaseClass::Reflect(context);
  17. if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  18. {
  19. serializeContext->Class<EditorBloomComponent, BaseClass>()
  20. ->Version(1);
  21. if (AZ::EditContext* editContext = serializeContext->GetEditContext())
  22. {
  23. editContext->Class<EditorBloomComponent>(
  24. "Bloom", "Controls the Bloom")
  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://www.o3de.org/docs/user-guide/components/reference/atom/bloom/") // [TODO ATOM-2672][PostFX] need create page for PostProcessing.
  32. ;
  33. editContext->Class<BloomComponentController>(
  34. "ExposureControlComponentController", "")
  35. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  36. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  37. ->DataElement(AZ::Edit::UIHandlers::Default, &BloomComponentController::m_configuration, "Configuration", "")
  38. ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
  39. ;
  40. editContext->Class<BloomComponentConfig>("BloomComponentConfig", "")
  41. ->DataElement(Edit::UIHandlers::CheckBox,
  42. &BloomComponentConfig::m_enabled,
  43. "Enable Bloom",
  44. "Enable Bloom.")
  45. ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  46. ->DataElement(AZ::Edit::UIHandlers::Default, &BloomComponentConfig::m_threshold, "Threshold", "How bright is the light source bloom applied to ")
  47. ->Attribute(AZ::Edit::Attributes::Min, 0.0)
  48. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  49. ->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
  50. ->DataElement(AZ::Edit::UIHandlers::Slider, &BloomComponentConfig::m_knee, "Knee", "Soft knee to smoothen edge of threshold")
  51. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  52. ->Attribute(AZ::Edit::Attributes::Max, 1.0f)
  53. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  54. ->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
  55. ->DataElement(AZ::Edit::UIHandlers::Slider, &BloomComponentConfig::m_intensity, "Intensity", "Brightness of bloom")
  56. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  57. ->Attribute(AZ::Edit::Attributes::Max, 10000.0f)
  58. ->Attribute(AZ::Edit::Attributes::SoftMax, 25.0f)
  59. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  60. ->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
  61. ->DataElement(AZ::Edit::UIHandlers::CheckBox, &BloomComponentConfig::m_enableBicubic, "Enable Bicubic", "Enable bicubic filter for upsampling")
  62. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  63. ->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
  64. // Kernel sizes
  65. ->ClassElement(AZ::Edit::ClassElements::Group, "Kernel Size")
  66. ->Attribute(AZ::Edit::Attributes::AutoExpand, false)
  67. ->DataElement(AZ::Edit::UIHandlers::Slider, &BloomComponentConfig::m_kernelSizeScale,
  68. "Kernel Size Scale", "Global scaling factor of kernel size")
  69. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  70. ->Attribute(AZ::Edit::Attributes::Max, 2.0f)
  71. ->Attribute(AZ::Edit::Attributes::ChangeNotify,
  72. Edit::PropertyRefreshLevels::ValuesOnly)
  73. ->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
  74. ->DataElement(AZ::Edit::UIHandlers::Slider, &BloomComponentConfig::m_kernelSizeStage0, "Kernel Size 0", "Kernel size for blur stage 0 in percent of screen width")
  75. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  76. ->Attribute(AZ::Edit::Attributes::Max, 1.0f)
  77. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  78. ->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
  79. ->DataElement(AZ::Edit::UIHandlers::Slider, &BloomComponentConfig::m_kernelSizeStage1, "Kernel Size 1", "Kernel size for blur stage 1 in percent of screen width")
  80. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  81. ->Attribute(AZ::Edit::Attributes::Max, 1.0f)
  82. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  83. ->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
  84. ->DataElement(AZ::Edit::UIHandlers::Slider, &BloomComponentConfig::m_kernelSizeStage2, "Kernel Size 2", "Kernel size for blur stage 2 in percent of screen width")
  85. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  86. ->Attribute(AZ::Edit::Attributes::Max, 1.0f)
  87. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  88. ->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
  89. ->DataElement(AZ::Edit::UIHandlers::Slider, &BloomComponentConfig::m_kernelSizeStage3, "Kernel Size 3", "Kernel size for blur stage 3 in percent of screen width")
  90. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  91. ->Attribute(AZ::Edit::Attributes::Max, 1.0f)
  92. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  93. ->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
  94. ->DataElement(AZ::Edit::UIHandlers::Slider, &BloomComponentConfig::m_kernelSizeStage4, "Kernel Size 4", "Kernel size for blur stage 4 in percent of screen width")
  95. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  96. ->Attribute(AZ::Edit::Attributes::Max, 1.0f)
  97. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  98. ->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
  99. // Tints
  100. ->ClassElement(AZ::Edit::ClassElements::Group, "Tint")
  101. ->Attribute(AZ::Edit::Attributes::AutoExpand, false)
  102. ->DataElement(AZ::Edit::UIHandlers::Color, &BloomComponentConfig::m_tintStage0, "Tint 0", "Tint for blur stage 0")
  103. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  104. ->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
  105. ->DataElement(AZ::Edit::UIHandlers::Color, &BloomComponentConfig::m_tintStage1, "Tint 1", "Tint for blur stage 1")
  106. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  107. ->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
  108. ->DataElement(AZ::Edit::UIHandlers::Color, &BloomComponentConfig::m_tintStage2, "Tint 2", "Tint for blur stage 2")
  109. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  110. ->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
  111. ->DataElement(AZ::Edit::UIHandlers::Color, &BloomComponentConfig::m_tintStage3, "Tint 3", "Tint for blur stage 3")
  112. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  113. ->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
  114. ->DataElement(AZ::Edit::UIHandlers::Color, &BloomComponentConfig::m_tintStage4, "Tint 4", "Tint for blur stage 4")
  115. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  116. ->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
  117. // Overrides
  118. ->ClassElement(AZ::Edit::ClassElements::Group, "Overrides")
  119. ->Attribute(AZ::Edit::Attributes::AutoExpand, false)
  120. // Auto-gen editor context settings for overrides
  121. #define EDITOR_CLASS BloomComponentConfig
  122. #include <Atom/Feature/ParamMacros/StartOverrideEditorContext.inl>
  123. #include <Atom/Feature/PostProcess/Bloom/BloomParams.inl>
  124. #include <Atom/Feature/ParamMacros/EndParams.inl>
  125. #undef EDITOR_CLASS
  126. ;
  127. }
  128. }
  129. if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
  130. {
  131. behaviorContext->Class<EditorBloomComponent>()->RequestBus("BloomRequestBus");
  132. behaviorContext->ConstantProperty("EditorBloomComponentTypeId", BehaviorConstant(Uuid(Bloom::EditorBloomComponentTypeId)))
  133. ->Attribute(AZ::Script::Attributes::Module, "render")
  134. ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
  135. }
  136. }
  137. EditorBloomComponent::EditorBloomComponent(const BloomComponentConfig& config)
  138. : BaseClass(config)
  139. {
  140. }
  141. u32 EditorBloomComponent::OnConfigurationChanged()
  142. {
  143. m_controller.OnConfigChanged();
  144. return Edit::PropertyRefreshLevels::AttributesAndValues;
  145. }
  146. }
  147. }