You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
o3de/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/Bloom/EditorBloomComponent.cpp

176 lines
12 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <AzCore/RTTI/BehaviorContext.h>
#include <PostProcess/Bloom/EditorBloomComponent.h>
namespace AZ
{
namespace Render
{
void EditorBloomComponent::Reflect(AZ::ReflectContext* context)
{
BaseClass::Reflect(context);
if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<EditorBloomComponent, BaseClass>()
->Version(1);
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
{
editContext->Class<EditorBloomComponent>(
"Bloom", "Controls the Bloom")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute(Edit::Attributes::Category, "Atom")
->Attribute(AZ::Edit::Attributes::Icon, "Icons/Components/Component_Placeholder.svg") // [GFX TODO ATOM-2672][PostFX] need to create icons for PostProcessing.
->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/Component_Placeholder.svg") // [GFX TODO ATOM-2672][PostFX] need to create icons for PostProcessing.
->Attribute(Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c))
->Attribute(Edit::Attributes::AutoExpand, true)
->Attribute(Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/atom/bloom/") // [TODO ATOM-2672][PostFX] need create page for PostProcessing.
;
editContext->Class<BloomComponentController>(
"ExposureControlComponentController", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::Default, &BloomComponentController::m_configuration, "Configuration", "")
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
;
editContext->Class<BloomComponentConfig>("BloomComponentConfig", "")
->DataElement(Edit::UIHandlers::CheckBox,
&BloomComponentConfig::m_enabled,
"Enable Bloom",
"Enable Bloom.")
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->DataElement(AZ::Edit::UIHandlers::Default, &BloomComponentConfig::m_threshold, "Threshold", "How bright is the light source bloom applied to ")
->Attribute(AZ::Edit::Attributes::Min, 0.0)
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
->DataElement(AZ::Edit::UIHandlers::Slider, &BloomComponentConfig::m_knee, "Knee", "Soft knee to smoothen edge of threshold")
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::Max, 1.0f)
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
->DataElement(AZ::Edit::UIHandlers::Slider, &BloomComponentConfig::m_intensity, "Intensity", "Brightness of bloom")
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::Max, 10000.0f)
->Attribute(AZ::Edit::Attributes::SoftMax, 25.0f)
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
->DataElement(AZ::Edit::UIHandlers::CheckBox, &BloomComponentConfig::m_enableBicubic, "Enable Bicubic", "Enable bicubic filter for upsampling")
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
// Kernel sizes
->ClassElement(AZ::Edit::ClassElements::Group, "Kernel Size")
->Attribute(AZ::Edit::Attributes::AutoExpand, false)
->DataElement(AZ::Edit::UIHandlers::Slider, &BloomComponentConfig::m_kernelSizeScale,
"Kernel Size Scale", "Global scaling factor of kernel size")
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::Max, 2.0f)
->Attribute(AZ::Edit::Attributes::ChangeNotify,
Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
->DataElement(AZ::Edit::UIHandlers::Slider, &BloomComponentConfig::m_kernelSizeStage0, "Kernel Size 0", "Kernel size for blur stage 0 in percent of screen width")
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::Max, 1.0f)
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
->DataElement(AZ::Edit::UIHandlers::Slider, &BloomComponentConfig::m_kernelSizeStage1, "Kernel Size 1", "Kernel size for blur stage 1 in percent of screen width")
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::Max, 1.0f)
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
->DataElement(AZ::Edit::UIHandlers::Slider, &BloomComponentConfig::m_kernelSizeStage2, "Kernel Size 2", "Kernel size for blur stage 2 in percent of screen width")
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::Max, 1.0f)
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
->DataElement(AZ::Edit::UIHandlers::Slider, &BloomComponentConfig::m_kernelSizeStage3, "Kernel Size 3", "Kernel size for blur stage 3 in percent of screen width")
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::Max, 1.0f)
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
->DataElement(AZ::Edit::UIHandlers::Slider, &BloomComponentConfig::m_kernelSizeStage4, "Kernel Size 4", "Kernel size for blur stage 4 in percent of screen width")
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::Max, 1.0f)
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
// Tints
->ClassElement(AZ::Edit::ClassElements::Group, "Tint")
->Attribute(AZ::Edit::Attributes::AutoExpand, false)
->DataElement(AZ::Edit::UIHandlers::Color, &BloomComponentConfig::m_tintStage0, "Tint 0", "Tint for blur stage 0")
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
->DataElement(AZ::Edit::UIHandlers::Color, &BloomComponentConfig::m_tintStage1, "Tint 1", "Tint for blur stage 1")
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
->DataElement(AZ::Edit::UIHandlers::Color, &BloomComponentConfig::m_tintStage2, "Tint 2", "Tint for blur stage 2")
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
->DataElement(AZ::Edit::UIHandlers::Color, &BloomComponentConfig::m_tintStage3, "Tint 3", "Tint for blur stage 3")
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
->DataElement(AZ::Edit::UIHandlers::Color, &BloomComponentConfig::m_tintStage4, "Tint 4", "Tint for blur stage 4")
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &BloomComponentConfig::ArePropertiesReadOnly)
// Overrides
->ClassElement(AZ::Edit::ClassElements::Group, "Overrides")
->Attribute(AZ::Edit::Attributes::AutoExpand, false)
// Auto-gen editor context settings for overrides
#define EDITOR_CLASS BloomComponentConfig
#include <Atom/Feature/ParamMacros/StartOverrideEditorContext.inl>
#include <Atom/Feature/PostProcess/Bloom/BloomParams.inl>
#include <Atom/Feature/ParamMacros/EndParams.inl>
#undef EDITOR_CLASS
;
}
}
if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
behaviorContext->Class<EditorBloomComponent>()->RequestBus("BloomRequestBus");
behaviorContext->ConstantProperty("EditorBloomComponentTypeId", BehaviorConstant(Uuid(Bloom::EditorBloomComponentTypeId)))
->Attribute(AZ::Script::Attributes::Module, "render")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
}
}
EditorBloomComponent::EditorBloomComponent(const BloomComponentConfig& config)
: BaseClass(config)
{
}
u32 EditorBloomComponent::OnConfigurationChanged()
{
m_controller.OnConfigChanged();
return Edit::PropertyRefreshLevels::AttributesAndValues;
}
}
}