EditorPostFxLayerComponent.cpp 5.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project
  3. *
  4. * SPDX-License-Identifier: Apache-2.0 OR MIT
  5. *
  6. */
  7. #include <PostProcess/EditorPostFxLayerComponent.h>
  8. #include <AzCore/RTTI/BehaviorContext.h>
  9. namespace AZ
  10. {
  11. namespace Render
  12. {
  13. void EditorPostFxLayerComponent::Reflect(AZ::ReflectContext* context)
  14. {
  15. BaseClass::Reflect(context);
  16. if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  17. {
  18. serializeContext->Class<EditorPostFxLayerComponent, BaseClass>()
  19. ->Version(4);
  20. if (AZ::EditContext* editContext = serializeContext->GetEditContext())
  21. {
  22. editContext->Class<EditorPostFxLayerComponent>(
  23. "PostFX Layer", "This component enables the entity to specify post process settings")
  24. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  25. ->Attribute(AZ::Edit::Attributes::Category, "Atom")
  26. ->Attribute(AZ::Edit::Attributes::Icon, "Icons/Components/Component_Placeholder.svg")
  27. ->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/Component_Placeholder.png")
  28. ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c))
  29. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  30. ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/atom/")
  31. ;
  32. editContext->Class<PostFxLayerComponentController>(
  33. "PostFxLayerComponentController", "")
  34. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  35. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  36. ->DataElement(AZ::Edit::UIHandlers::Default, &PostFxLayerComponentController::m_configuration, "Configuration", "")
  37. ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
  38. ;
  39. editContext->Class<PostFxLayerComponentConfig>(
  40. "PostFxLayerComponentController", "")
  41. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  42. ->DataElement(Edit::UIHandlers::ComboBox, &PostFxLayerComponentConfig::m_layerCategoryValue, "Layer Category", "The frequency at which the settings will be applied")
  43. ->Attribute(AZ::Edit::Attributes::EnumValues, &PostFxLayerComponentConfig::BuildLayerCategories)
  44. ->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::AttributesAndValues)
  45. ->DataElement(Edit::UIHandlers::Default, &PostFxLayerComponentConfig::m_priority, "Priority", "The priority this will take over other settings with the same frequency. Lower priority values take precedence.")
  46. ->Attribute(AZ::Edit::Attributes::NameLabelOverride, &PostFxLayerComponentConfig::GetPriorityLabel)
  47. ->Attribute(AZ::Edit::Attributes::Min, 0)
  48. ->Attribute(AZ::Edit::Attributes::Max, 20)
  49. ->DataElement(AZ::Edit::UIHandlers::Slider, &PostFxLayerComponentConfig::m_overrideFactor, "Weight", "How much these settings override previous settings")
  50. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  51. ->Attribute(AZ::Edit::Attributes::Max, 1.0f)
  52. ->DataElement(AZ::Edit::UIHandlers::Default, &PostFxLayerComponentConfig::m_cameraTags, "Select Camera Tags Only", "Limit the PostFx Layer to specific camera entities with the specified tag.")
  53. ->DataElement(AZ::Edit::UIHandlers::Default, &PostFxLayerComponentConfig::m_exclusionTags, "Excluded Camera Tags", "Camera entities containing these tags will not be included.")
  54. ;
  55. }
  56. }
  57. if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
  58. {
  59. behaviorContext->Class<EditorPostFxLayerComponent>()->RequestBus("PostFxLayerRequestBus");
  60. behaviorContext->ConstantProperty("EditorPostFxLayerComponentTypeId", BehaviorConstant(Uuid(EditorPostFxLayerComponentTypeId)))
  61. ->Attribute(AZ::Script::Attributes::Module, "render")
  62. ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
  63. }
  64. }
  65. EditorPostFxLayerComponent::EditorPostFxLayerComponent(const PostFxLayerComponentConfig& config)
  66. : BaseClass(config)
  67. {
  68. }
  69. u32 EditorPostFxLayerComponent::OnConfigurationChanged()
  70. {
  71. m_controller.OnConfigChanged();
  72. m_controller.RebuildCameraEntitiesList();
  73. return Edit::PropertyRefreshLevels::AttributesAndValues;
  74. }
  75. }
  76. }