EditorFilmGrainComponent.cpp 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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/FilmGrain/EditorFilmGrainComponent.h>
  9. #include <AzCore/RTTI/BehaviorContext.h>
  10. namespace AZ
  11. {
  12. namespace Render
  13. {
  14. void EditorFilmGrainComponent::Reflect(AZ::ReflectContext* context)
  15. {
  16. BaseClass::Reflect(context);
  17. if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  18. {
  19. serializeContext->Class<EditorFilmGrainComponent, BaseClass>()->Version(0);
  20. if (AZ::EditContext* editContext = serializeContext->GetEditContext())
  21. {
  22. editContext->Class<EditorFilmGrainComponent>("Film Grain", "Controls the Film Grain")
  23. ->ClassElement(Edit::ClassElements::EditorData, "")
  24. ->Attribute(Edit::Attributes::Category, "Graphics/PostFX")
  25. ->Attribute(
  26. AZ::Edit::Attributes::Icon, "Icons/Components/Component_Placeholder.svg") // Create better icons for this effect
  27. ->Attribute(
  28. AZ::Edit::Attributes::ViewportIcon,
  29. "Icons/Components/Viewport/Component_Placeholder.svg") // Create better icons for this effect
  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/FilmGrain/") // Create documentation page for this effect
  35. ;
  36. editContext->Class<FilmGrainComponentController>("FilmGrainComponentController", "")
  37. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  38. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  39. ->DataElement(AZ::Edit::UIHandlers::Default, &FilmGrainComponentController::m_configuration, "Configuration", "")
  40. ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly);
  41. editContext->Class<FilmGrainComponentConfig>("FilmGrainComponentConfig", "")
  42. ->DataElement(
  43. Edit::UIHandlers::CheckBox, &FilmGrainComponentConfig::m_enabled, "Enable Film Grain", "Enable Film Grain.")
  44. ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  45. ->DataElement(AZ::Edit::UIHandlers::Slider, &FilmGrainComponentConfig::m_intensity, "Intensity", "Intensity 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, &FilmGrainComponentConfig::ArePropertiesReadOnly)
  50. ->DataElement(
  51. AZ::Edit::UIHandlers::Slider, &FilmGrainComponentConfig::m_luminanceDampening, "Luminance Dampening", "Factor for dampening effect in areas of both high and low luminance")
  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, &FilmGrainComponentConfig::ArePropertiesReadOnly)
  56. ->DataElement(
  57. AZ::Edit::UIHandlers::Slider, &FilmGrainComponentConfig::m_tilingScale, "Tiling Scale",
  58. "Factor for tiling the pregenerated noise")
  59. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  60. ->Attribute(AZ::Edit::Attributes::Max, 20.0f)
  61. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  62. ->Attribute(Edit::Attributes::ReadOnly, &FilmGrainComponentConfig::ArePropertiesReadOnly)
  63. // Overrides
  64. ->ClassElement(AZ::Edit::ClassElements::Group, "Overrides")
  65. ->Attribute(AZ::Edit::Attributes::AutoExpand, false)
  66. // Auto-gen editor context settings for overrides
  67. #define EDITOR_CLASS FilmGrainComponentConfig
  68. #include <Atom/Feature/ParamMacros/StartOverrideEditorContext.inl>
  69. #include <Atom/Feature/PostProcess/FilmGrain/FilmGrainParams.inl>
  70. #include <Atom/Feature/ParamMacros/EndParams.inl>
  71. #undef EDITOR_CLASS
  72. ;
  73. }
  74. }
  75. if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
  76. {
  77. behaviorContext->Class<EditorFilmGrainComponent>()->RequestBus("FilmGrainRequestBus");
  78. behaviorContext
  79. ->ConstantProperty("EditorFilmGrainComponentTypeId", BehaviorConstant(Uuid(FilmGrain::EditorFilmGrainComponentTypeId)))
  80. ->Attribute(AZ::Script::Attributes::Module, "render")
  81. ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
  82. }
  83. }
  84. EditorFilmGrainComponent::EditorFilmGrainComponent(const FilmGrainComponentConfig& config)
  85. : BaseClass(config)
  86. {
  87. }
  88. u32 EditorFilmGrainComponent::OnConfigurationChanged()
  89. {
  90. m_controller.OnConfigChanged();
  91. return Edit::PropertyRefreshLevels::AttributesAndValues;
  92. }
  93. } // namespace Render
  94. } // namespace AZ