EditorChromaticAberrationComponent.cpp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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/ChromaticAberration/EditorChromaticAberrationComponent.h>
  9. #include <AzCore/RTTI/BehaviorContext.h>
  10. namespace AZ
  11. {
  12. namespace Render
  13. {
  14. void EditorChromaticAberrationComponent::Reflect(AZ::ReflectContext* context)
  15. {
  16. BaseClass::Reflect(context);
  17. if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  18. {
  19. serializeContext->Class<EditorChromaticAberrationComponent, BaseClass>()->Version(0);
  20. if (AZ::EditContext* editContext = serializeContext->GetEditContext())
  21. {
  22. editContext->Class<EditorChromaticAberrationComponent>("Chromatic Aberration", "Controls the Chromatic Aberration")
  23. ->ClassElement(Edit::ClassElements::EditorData, "")
  24. ->Attribute(Edit::Attributes::Category, "Graphics/PostFX")
  25. ->Attribute(
  26. AZ::Edit::Attributes::Icon, "Icons/Components/Component_Placeholder.svg") // [GFX TODO ATOM-2672][PostFX] need to create icons for PostProcessing.
  27. ->Attribute(
  28. AZ::Edit::Attributes::ViewportIcon,
  29. "Icons/Components/Viewport/Component_Placeholder.svg") // [GFX TODO ATOM-2672][PostFX] need to create icons for PostProcessing.
  30. ->Attribute(Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Game"))
  31. ->Attribute(Edit::Attributes::AutoExpand, true)
  32. ->Attribute(
  33. Edit::Attributes::HelpPageURL,
  34. "https://o3de.org/docs/user-guide/components/reference/atom/ChromaticAberration/") // [TODO ATOM-2672][PostFX] need create page for PostProcessing.
  35. ;
  36. editContext->Class<ChromaticAberrationComponentController>("ChromaticAberrationComponentController", "")
  37. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  38. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  39. ->DataElement(AZ::Edit::UIHandlers::Default, &ChromaticAberrationComponentController::m_configuration, "Configuration", "")
  40. ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly);
  41. editContext->Class<ChromaticAberrationComponentConfig>("ChromaticAberrationComponentConfig", "")
  42. ->DataElement(
  43. Edit::UIHandlers::CheckBox, &ChromaticAberrationComponentConfig::m_enabled, "Enable Chromatic Aberration", "Enable Chromatic Aberration.")
  44. ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  45. ->DataElement(AZ::Edit::UIHandlers::Slider, &ChromaticAberrationComponentConfig::m_strength, "Strength", "Strength of effect")
  46. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  47. ->Attribute(AZ::Edit::Attributes::Max, 1.0f)
  48. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  49. ->Attribute(Edit::Attributes::ReadOnly, &ChromaticAberrationComponentConfig::ArePropertiesReadOnly)
  50. ->DataElement(
  51. AZ::Edit::UIHandlers::Slider, &ChromaticAberrationComponentConfig::m_blend, "Blend", "Factor for additive blending with original image")
  52. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  53. ->Attribute(AZ::Edit::Attributes::Max, 1.0f)
  54. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  55. ->Attribute(Edit::Attributes::ReadOnly, &ChromaticAberrationComponentConfig::ArePropertiesReadOnly)
  56. // Overrides
  57. ->ClassElement(AZ::Edit::ClassElements::Group, "Overrides")
  58. ->Attribute(AZ::Edit::Attributes::AutoExpand, false)
  59. // Auto-gen editor context settings for overrides
  60. #define EDITOR_CLASS ChromaticAberrationComponentConfig
  61. #include <Atom/Feature/ParamMacros/StartOverrideEditorContext.inl>
  62. #include <Atom/Feature/PostProcess/ChromaticAberration/ChromaticAberrationParams.inl>
  63. #include <Atom/Feature/ParamMacros/EndParams.inl>
  64. #undef EDITOR_CLASS
  65. ;
  66. }
  67. }
  68. if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
  69. {
  70. behaviorContext->Class<EditorChromaticAberrationComponent>()->RequestBus("ChromaticAberrationRequestBus");
  71. behaviorContext
  72. ->ConstantProperty("EditorChromaticAberrationComponentTypeId", BehaviorConstant(Uuid(ChromaticAberration::EditorChromaticAberrationComponentTypeId)))
  73. ->Attribute(AZ::Script::Attributes::Module, "render")
  74. ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
  75. }
  76. }
  77. EditorChromaticAberrationComponent::EditorChromaticAberrationComponent(const ChromaticAberrationComponentConfig& config)
  78. : BaseClass(config)
  79. {
  80. }
  81. u32 EditorChromaticAberrationComponent::OnConfigurationChanged()
  82. {
  83. m_controller.OnConfigChanged();
  84. return Edit::PropertyRefreshLevels::AttributesAndValues;
  85. }
  86. } // namespace Render
  87. } // namespace AZ