Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,43 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <DiffuseProbeGrid/DiffuseProbeGridComponent.h>
namespace AZ
{
namespace Render
{
DiffuseProbeGridComponent::DiffuseProbeGridComponent(const DiffuseProbeGridComponentConfig& config)
: BaseClass(config)
{
}
void DiffuseProbeGridComponent::Reflect(AZ::ReflectContext* context)
{
BaseClass::Reflect(context);
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<DiffuseProbeGridComponent, BaseClass>()
->Version(0)
;
}
if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
behaviorContext->ConstantProperty("DiffuseProbeGridComponentTypeId", BehaviorConstant(Uuid(DiffuseProbeGridComponentTypeId)))
->Attribute(AZ::Script::Attributes::Module, "render")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common);
}
}
} // namespace Render
} // namespace AZ
@@ -0,0 +1,37 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <DiffuseProbeGrid/DiffuseProbeGridComponentController.h>
#include <DiffuseProbeGrid/DiffuseProbeGridComponentConstants.h>
#include <AzFramework/Components/ComponentAdapter.h>
namespace AZ
{
namespace Render
{
class DiffuseProbeGridComponent final
: public AzFramework::Components::ComponentAdapter<DiffuseProbeGridComponentController, DiffuseProbeGridComponentConfig>
{
public:
using BaseClass = AzFramework::Components::ComponentAdapter<DiffuseProbeGridComponentController, DiffuseProbeGridComponentConfig>;
AZ_COMPONENT(AZ::Render::DiffuseProbeGridComponent, DiffuseProbeGridComponentTypeId, BaseClass);
DiffuseProbeGridComponent() = default;
DiffuseProbeGridComponent(const DiffuseProbeGridComponentConfig& config);
static void Reflect(AZ::ReflectContext* context);
};
} // namespace Render
} // namespace AZ
@@ -0,0 +1,27 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
namespace AZ
{
namespace Render
{
static constexpr const char* const DiffuseProbeGridComponentTypeId = "{9B900A04-192F-4F5E-AE31-762605D8159A}";
static constexpr const char* const EditorDiffuseProbeGridComponentTypeId = "{F80086E1-ECE7-4E8C-B727-A750D10F7D83}";
static constexpr float DefaultDiffuseProbeGridSpacing = 4.0f;
static constexpr float DefaultDiffuseProbeGridExtents = 20.0f;
static constexpr float DefaultDiffuseProbeGridAmbientMultiplier = 1.0f;
static constexpr float DefaultDiffuseProbeGridViewBias = 0.2f;
static constexpr float DefaultDiffuseProbeGridNormalBias = 0.1f;
} // namespace Render
} // namespace AZ
@@ -0,0 +1,230 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <DiffuseProbeGrid/DiffuseProbeGridComponentController.h>
#include <DiffuseProbeGrid/DiffuseProbeGridComponentConstants.h>
#include <Atom/RPI.Public/Model/Model.h>
#include <Atom/RPI.Public/Image/StreamingImage.h>
#include <Atom/RPI.Public/Scene.h>
#include <AzCore/Asset/AssetManager.h>
#include <AzCore/Asset/AssetManagerBus.h>
#include <AzCore/Debug/EventTrace.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzFramework/Entity/EntityContextBus.h>
#include <AzFramework/Entity/EntityContext.h>
#include <AzFramework/Scene/Scene.h>
#include <AzFramework/Scene/SceneSystemBus.h>
#include <AzCore/RTTI/BehaviorContext.h>
namespace AZ
{
namespace Render
{
void DiffuseProbeGridComponentConfig::Reflect(ReflectContext* context)
{
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
{
serializeContext->Class<DiffuseProbeGridComponentConfig>()
->Version(0)
->Field("ProbeSpacing", &DiffuseProbeGridComponentConfig::m_probeSpacing)
->Field("Extents", &DiffuseProbeGridComponentConfig::m_extents)
->Field("AmbientMultiplier", &DiffuseProbeGridComponentConfig::m_ambientMultiplier)
->Field("ViewBias", &DiffuseProbeGridComponentConfig::m_viewBias)
->Field("NormalBias", &DiffuseProbeGridComponentConfig::m_normalBias)
;
}
}
void DiffuseProbeGridComponentController::Reflect(ReflectContext* context)
{
DiffuseProbeGridComponentConfig::Reflect(context);
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
{
serializeContext->Class<DiffuseProbeGridComponentController>()
->Version(0)
->Field("Configuration", &DiffuseProbeGridComponentController::m_configuration);
}
}
void DiffuseProbeGridComponentController::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
dependent.push_back(AZ_CRC("TransformService", 0x8ee22c50));
}
void DiffuseProbeGridComponentController::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC("DiffuseProbeGridService", 0x63d32042));
}
void DiffuseProbeGridComponentController::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
incompatible.push_back(AZ_CRC("DiffuseProbeGridService", 0x63d32042));
}
void DiffuseProbeGridComponentController::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
required.push_back(AZ_CRC("BoxShapeService", 0x946a0032));
required.push_back(AZ_CRC("TransformService"));
}
DiffuseProbeGridComponentController::DiffuseProbeGridComponentController(const DiffuseProbeGridComponentConfig& config)
: m_configuration(config)
{
}
void DiffuseProbeGridComponentController::Activate(AZ::EntityId entityId)
{
m_entityId = entityId;
TransformNotificationBus::Handler::BusConnect(m_entityId);
m_featureProcessor = RPI::Scene::GetFeatureProcessorForEntity<DiffuseProbeGridFeatureProcessorInterface>(entityId);
AZ_Assert(m_featureProcessor, "DiffuseProbeGridComponentController was unable to find a DiffuseProbeGridFeatureProcessor on the EntityContext provided.");
m_transformInterface = TransformBus::FindFirstHandler(entityId);
AZ_Assert(m_transformInterface, "Unable to attach to a TransformBus handler");
if (!m_transformInterface)
{
return;
}
LmbrCentral::ShapeComponentNotificationsBus::Handler::BusConnect(m_entityId);
m_shapeBus = LmbrCentral::ShapeComponentRequestsBus::FindFirstHandler(m_entityId);
AZ_Assert(m_shapeBus, "DiffuseProbeGridComponentController was unable to find ShapeComponentNotificationsBus");
m_boxShapeInterface = LmbrCentral::BoxShapeComponentRequestsBus::FindFirstHandler(m_entityId);
AZ_Assert(m_boxShapeInterface, "DiffuseProbeGridComponentController was unable to find box shape component");
// add this diffuse probe grid to the feature processor
const AZ::Transform& transform = m_transformInterface->GetWorldTM();
m_handle = m_featureProcessor->AddProbeGrid(transform, m_configuration.m_extents, m_configuration.m_probeSpacing);
m_featureProcessor->SetAmbientMultiplier(m_handle, m_configuration.m_ambientMultiplier);
m_featureProcessor->SetViewBias(m_handle, m_configuration.m_viewBias);
m_featureProcessor->SetNormalBias(m_handle, m_configuration.m_normalBias);
// set box shape component dimensions from the configuration
// this will invoke the OnShapeChanged() handler and set the outer extents on the feature processor
m_boxShapeInterface->SetBoxDimensions(m_configuration.m_extents);
}
void DiffuseProbeGridComponentController::Deactivate()
{
if (m_featureProcessor)
{
m_featureProcessor->RemoveProbeGrid(m_handle);
}
LmbrCentral::ShapeComponentNotificationsBus::Handler::BusDisconnect();
Data::AssetBus::MultiHandler::BusDisconnect();
TransformNotificationBus::Handler::BusDisconnect();
m_transformInterface = nullptr;
m_featureProcessor = nullptr;
m_shapeBus = nullptr;
m_boxShapeInterface = nullptr;
}
void DiffuseProbeGridComponentController::SetConfiguration(const DiffuseProbeGridComponentConfig& config)
{
m_configuration = config;
}
const DiffuseProbeGridComponentConfig& DiffuseProbeGridComponentController::GetConfiguration() const
{
return m_configuration;
}
void DiffuseProbeGridComponentController::OnTransformChanged([[maybe_unused]] const AZ::Transform& local, const AZ::Transform& world)
{
if (!m_featureProcessor)
{
return;
}
m_featureProcessor->SetTransform(m_handle, world);
}
void DiffuseProbeGridComponentController::OnShapeChanged(ShapeChangeReasons changeReason)
{
if (!m_featureProcessor)
{
return;
}
if (m_inShapeChangeHandler)
{
return;
}
m_inShapeChangeHandler = true;
AZ_Assert(m_featureProcessor->IsValidProbeGridHandle(m_handle), "OnShapeChanged handler called before probe was registered with feature processor");
if (changeReason == ShapeChangeReasons::ShapeChanged)
{
AZ::Vector3 dimensions = m_boxShapeInterface->GetBoxDimensions();
if (m_featureProcessor->ValidateExtents(m_handle, dimensions))
{
m_featureProcessor->SetExtents(m_handle, dimensions);
m_configuration.m_extents = dimensions;
}
else
{
// restore old dimensions
m_boxShapeInterface->SetBoxDimensions(m_configuration.m_extents);
}
}
m_inShapeChangeHandler = false;
}
AZ::Aabb DiffuseProbeGridComponentController::GetAabb() const
{
return m_shapeBus ? m_shapeBus->GetEncompassingAabb() : AZ::Aabb::CreateNull();
}
bool DiffuseProbeGridComponentController::ValidateProbeSpacing(const AZ::Vector3& newSpacing)
{
return m_featureProcessor->ValidateProbeSpacing(m_handle, newSpacing);
}
void DiffuseProbeGridComponentController::SetProbeSpacing(const AZ::Vector3& probeSpacing)
{
m_configuration.m_probeSpacing = probeSpacing;
m_featureProcessor->SetProbeSpacing(m_handle, m_configuration.m_probeSpacing);
}
void DiffuseProbeGridComponentController::SetAmbientMultiplier(float ambientMultiplier)
{
m_configuration.m_ambientMultiplier = ambientMultiplier;
m_featureProcessor->SetAmbientMultiplier(m_handle, m_configuration.m_ambientMultiplier);
}
void DiffuseProbeGridComponentController::SetViewBias(float viewBias)
{
m_configuration.m_viewBias = viewBias;
m_featureProcessor->SetViewBias(m_handle, m_configuration.m_viewBias);
}
void DiffuseProbeGridComponentController::SetNormalBias(float normalBias)
{
m_configuration.m_normalBias = normalBias;
m_featureProcessor->SetNormalBias(m_handle, m_configuration.m_normalBias);
}
} // namespace Render
} // namespace AZ
@@ -0,0 +1,103 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Asset/AssetCommon.h>
#include <AzCore/Component/Component.h>
#include <AzCore/Component/TransformBus.h>
#include <Atom/Feature/DiffuseProbeGrid/DiffuseProbeGridFeatureProcessorInterface.h>
#include <Atom/RPI.Public/Model/Model.h>
#include <LmbrCentral/Shape/BoxShapeComponentBus.h>
#include <DiffuseProbeGrid/DiffuseProbeGridComponentConstants.h>
namespace AZ
{
namespace Render
{
class DiffuseProbeGridComponentConfig final
: public AZ::ComponentConfig
{
public:
AZ_RTTI(AZ::Render::DiffuseProbeGridComponentConfig, "{BF190F2A-D7F7-453B-9D42-5CE940180DCE}", ComponentConfig);
AZ_CLASS_ALLOCATOR(DiffuseProbeGridComponentConfig, SystemAllocator, 0);
static void Reflect(AZ::ReflectContext* context);
DiffuseProbeGridComponentConfig() = default;
Vector3 m_extents = AZ::Vector3(DefaultDiffuseProbeGridExtents);
Vector3 m_probeSpacing = AZ::Vector3(DefaultDiffuseProbeGridSpacing);
float m_ambientMultiplier = DefaultDiffuseProbeGridAmbientMultiplier;
float m_viewBias = DefaultDiffuseProbeGridViewBias;
float m_normalBias = DefaultDiffuseProbeGridNormalBias;
};
class DiffuseProbeGridComponentController final
: public Data::AssetBus::MultiHandler
, private TransformNotificationBus::Handler
, private LmbrCentral::ShapeComponentNotificationsBus::Handler
{
public:
friend class EditorDiffuseProbeGridComponent;
AZ_CLASS_ALLOCATOR(DiffuseProbeGridComponentController, AZ::SystemAllocator, 0);
AZ_RTTI(AZ::Render::DiffuseProbeGridComponentController, "{108588E8-355E-4A19-94AC-955E64A37CE2}");
static void Reflect(AZ::ReflectContext* context);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
DiffuseProbeGridComponentController() = default;
DiffuseProbeGridComponentController(const DiffuseProbeGridComponentConfig& config);
void Activate(AZ::EntityId entityId);
void Deactivate();
void SetConfiguration(const DiffuseProbeGridComponentConfig& config);
const DiffuseProbeGridComponentConfig& GetConfiguration() const;
// returns the Aabb for this grid
AZ::Aabb GetAabb() const;
private:
AZ_DISABLE_COPY(DiffuseProbeGridComponentController);
// TransformNotificationBus overrides
void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
// ShapeComponentNotificationsBus overrides
void OnShapeChanged(ShapeChangeReasons changeReason) override;
// Property handlers
bool ValidateProbeSpacing(const AZ::Vector3& newSpacing);
void SetProbeSpacing(const AZ::Vector3& probeSpacing);
void SetAmbientMultiplier(float ambientMultiplier);
void SetViewBias(float viewBias);
void SetNormalBias(float normalBias);
// box shape component, used for defining the outer extents of the probe area
LmbrCentral::BoxShapeComponentRequests* m_boxShapeInterface = nullptr;
LmbrCentral::ShapeComponentRequests* m_shapeBus = nullptr;
// handle for this probe in the feature processor
DiffuseProbeGridHandle m_handle;
DiffuseProbeGridFeatureProcessorInterface* m_featureProcessor = nullptr;
TransformInterface* m_transformInterface = nullptr;
AZ::EntityId m_entityId;
DiffuseProbeGridComponentConfig m_configuration;
bool m_inShapeChangeHandler = false;
};
} // namespace Render
} // namespace AZ
@@ -0,0 +1,207 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <DiffuseProbeGrid/EditorDiffuseProbeGridComponent.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
#include <AzCore/Component/Entity.h>
namespace AZ
{
namespace Render
{
void EditorDiffuseProbeGridComponent::Reflect(AZ::ReflectContext* context)
{
BaseClass::Reflect(context);
if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<EditorDiffuseProbeGridComponent, BaseClass>()
->Version(1, ConvertToEditorRenderComponentAdapter<1>)
->Field("probeSpacingX", &EditorDiffuseProbeGridComponent::m_probeSpacingX)
->Field("probeSpacingY", &EditorDiffuseProbeGridComponent::m_probeSpacingY)
->Field("probeSpacingZ", &EditorDiffuseProbeGridComponent::m_probeSpacingZ)
->Field("ambientMultiplier", &EditorDiffuseProbeGridComponent::m_ambientMultiplier)
->Field("viewBias", &EditorDiffuseProbeGridComponent::m_viewBias)
->Field("normalBias", &EditorDiffuseProbeGridComponent::m_normalBias)
;
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
{
editContext->Class<EditorDiffuseProbeGridComponent>(
"Diffuse Probe Grid", "The DiffuseProbeGrid component generates a grid of diffuse light probes for global illumination")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "Atom")
->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/Component_Placeholder.svg")
->Attribute(AZ::Edit::Attributes::ViewportIcon, "editor/icons/components/viewport/component_placeholder.png")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c))
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->Attribute(AZ::Edit::Attributes::PrimaryAssetType, AZ::AzTypeInfo<RPI::ModelAsset>::Uuid())
->ClassElement(AZ::Edit::ClassElements::Group, "Probe Spacing")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::Default, &EditorDiffuseProbeGridComponent::m_probeSpacingX, "X", "Probe spacing on the X-axis")
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::ChangeValidate, &EditorDiffuseProbeGridComponent::OnProbeSpacingValidateX)
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDiffuseProbeGridComponent::OnProbeSpacingChanged)
->DataElement(AZ::Edit::UIHandlers::Default, &EditorDiffuseProbeGridComponent::m_probeSpacingY, "Y", "Probe spacing on the Y-axis")
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::ChangeValidate, &EditorDiffuseProbeGridComponent::OnProbeSpacingValidateY)
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDiffuseProbeGridComponent::OnProbeSpacingChanged)
->DataElement(AZ::Edit::UIHandlers::Default, &EditorDiffuseProbeGridComponent::m_probeSpacingZ, "Z", "Probe spacing on the Z-axis")
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::ChangeValidate, &EditorDiffuseProbeGridComponent::OnProbeSpacingValidateZ)
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDiffuseProbeGridComponent::OnProbeSpacingChanged)
->ClassElement(AZ::Edit::ClassElements::Group, "Grid Settings")
->DataElement(AZ::Edit::UIHandlers::Slider, &EditorDiffuseProbeGridComponent::m_ambientMultiplier, "Ambient Multiplier", "Multiplier for the irradiance intensity")
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDiffuseProbeGridComponent::OnAmbientMultiplierChanged)
->Attribute(Edit::Attributes::Decimals, 0)
->Attribute(Edit::Attributes::Step, 1.0f)
->Attribute(Edit::Attributes::Min, 0.0f)
->Attribute(Edit::Attributes::Max, 10.0f)
->DataElement(AZ::Edit::UIHandlers::Slider, &EditorDiffuseProbeGridComponent::m_viewBias, "View Bias", "View bias adjustment")
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDiffuseProbeGridComponent::OnViewBiasChanged)
->Attribute(Edit::Attributes::Decimals, 2)
->Attribute(Edit::Attributes::Step, 0.1f)
->Attribute(Edit::Attributes::Min, 0.0f)
->Attribute(Edit::Attributes::Max, 1.0f)
->DataElement(AZ::Edit::UIHandlers::Slider, &EditorDiffuseProbeGridComponent::m_normalBias, "Normal Bias", "Normal bias adjustment")
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDiffuseProbeGridComponent::OnNormalBiasChanged)
->Attribute(Edit::Attributes::Decimals, 2)
->Attribute(Edit::Attributes::Step, 0.1f)
->Attribute(Edit::Attributes::Min, 0.0f)
->Attribute(Edit::Attributes::Max, 1.0f)
;
editContext->Class<DiffuseProbeGridComponentController>(
"DiffuseProbeGridComponentController", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::Default, &DiffuseProbeGridComponentController::m_configuration, "Configuration", "")
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
;
editContext->Class<DiffuseProbeGridComponentConfig>(
"DiffuseProbeGridComponentConfig", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
;
}
}
if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
behaviorContext->ConstantProperty("EditorDiffuseProbeGridComponentTypeId", BehaviorConstant(Uuid(EditorDiffuseProbeGridComponentTypeId)))
->Attribute(AZ::Script::Attributes::Module, "render")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
}
}
EditorDiffuseProbeGridComponent::EditorDiffuseProbeGridComponent()
{
}
EditorDiffuseProbeGridComponent::EditorDiffuseProbeGridComponent(const DiffuseProbeGridComponentConfig& config)
: BaseClass(config)
{
}
void EditorDiffuseProbeGridComponent::Activate()
{
BaseClass::Activate();
AzFramework::EntityDebugDisplayEventBus::Handler::BusConnect(GetEntityId());
AzToolsFramework::EditorComponentSelectionRequestsBus::Handler::BusConnect(GetEntityId());
}
void EditorDiffuseProbeGridComponent::Deactivate()
{
AzToolsFramework::EditorComponentSelectionRequestsBus::Handler::BusDisconnect();
AzFramework::EntityDebugDisplayEventBus::Handler::BusDisconnect();
BaseClass::Deactivate();
}
AZ::Aabb EditorDiffuseProbeGridComponent::GetEditorSelectionBoundsViewport([[maybe_unused]] const AzFramework::ViewportInfo& viewportInfo)
{
return m_controller.GetAabb();
}
bool EditorDiffuseProbeGridComponent::SupportsEditorRayIntersect()
{
return false;
}
AZ::Outcome<void, AZStd::string> EditorDiffuseProbeGridComponent::OnProbeSpacingValidateX(void* newValue, [[maybe_unused]] const AZ::Uuid& valueType)
{
float newProbeSpacingX = *(reinterpret_cast<float*>(newValue));
Vector3 newSpacing(newProbeSpacingX, m_probeSpacingY, m_probeSpacingZ);
if (!m_controller.ValidateProbeSpacing(newSpacing))
{
return AZ::Failure(AZStd::string("Probe spacing exceeds max allowable grid size with current extents"));
}
return AZ::Success();
}
AZ::Outcome<void, AZStd::string> EditorDiffuseProbeGridComponent::OnProbeSpacingValidateY(void* newValue, [[maybe_unused]] const AZ::Uuid& valueType)
{
float newProbeSpacingY = *(reinterpret_cast<float*>(newValue));
Vector3 newSpacing(m_probeSpacingX, newProbeSpacingY, m_probeSpacingZ);
if (!m_controller.ValidateProbeSpacing(newSpacing))
{
return AZ::Failure(AZStd::string("Probe spacing exceeds max allowable grid size with current extents"));
}
return AZ::Success();
}
AZ::Outcome<void, AZStd::string> EditorDiffuseProbeGridComponent::OnProbeSpacingValidateZ(void* newValue, [[maybe_unused]] const AZ::Uuid& valueType)
{
float newProbeSpacingZ = *(reinterpret_cast<float*>(newValue));
Vector3 newSpacing(m_probeSpacingX, m_probeSpacingY, newProbeSpacingZ);
if (!m_controller.ValidateProbeSpacing(newSpacing))
{
return AZ::Failure(AZStd::string("Probe spacing exceeds max allowable grid size with current extents"));
}
return AZ::Success();
}
AZ::u32 EditorDiffuseProbeGridComponent::OnProbeSpacingChanged()
{
AZ::Vector3 probeSpacing(m_probeSpacingX, m_probeSpacingY, m_probeSpacingZ);
m_controller.SetProbeSpacing(probeSpacing);
return AZ::Edit::PropertyRefreshLevels::None;
}
AZ::u32 EditorDiffuseProbeGridComponent::OnAmbientMultiplierChanged()
{
m_controller.SetAmbientMultiplier(m_ambientMultiplier);
return AZ::Edit::PropertyRefreshLevels::None;
}
AZ::u32 EditorDiffuseProbeGridComponent::OnViewBiasChanged()
{
m_controller.SetViewBias(m_viewBias);
return AZ::Edit::PropertyRefreshLevels::None;
}
AZ::u32 EditorDiffuseProbeGridComponent::OnNormalBiasChanged()
{
m_controller.SetNormalBias(m_normalBias);
return AZ::Edit::PropertyRefreshLevels::None;
}
} // namespace Render
} // namespace AZ
@@ -0,0 +1,66 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
#include <AzToolsFramework/API/ComponentEntitySelectionBus.h>
#include <DiffuseProbeGrid/DiffuseProbeGridComponent.h>
#include <DiffuseProbeGrid/DiffuseProbeGridComponentConstants.h>
#include <Atom/Feature/Utils/EditorRenderComponentAdapter.h>
namespace AZ
{
namespace Render
{
class EditorDiffuseProbeGridComponent final
: public EditorRenderComponentAdapter<DiffuseProbeGridComponentController, DiffuseProbeGridComponent, DiffuseProbeGridComponentConfig>
, private AzToolsFramework::EditorComponentSelectionRequestsBus::Handler
, private AzFramework::EntityDebugDisplayEventBus::Handler
{
public:
using BaseClass = EditorRenderComponentAdapter<DiffuseProbeGridComponentController, DiffuseProbeGridComponent, DiffuseProbeGridComponentConfig>;
AZ_EDITOR_COMPONENT(AZ::Render::EditorDiffuseProbeGridComponent, EditorDiffuseProbeGridComponentTypeId, BaseClass);
static void Reflect(AZ::ReflectContext* context);
EditorDiffuseProbeGridComponent();
EditorDiffuseProbeGridComponent(const DiffuseProbeGridComponentConfig& config);
// AZ::Component overrides
void Activate() override;
void Deactivate() override;
private:
// EditorComponentSelectionRequestsBus overrides
AZ::Aabb GetEditorSelectionBoundsViewport(const AzFramework::ViewportInfo& viewportInfo) override;
bool SupportsEditorRayIntersect() override;
// property change notifications
AZ::Outcome<void, AZStd::string> OnProbeSpacingValidateX(void* newValue, const AZ::Uuid& valueType);
AZ::Outcome<void, AZStd::string> OnProbeSpacingValidateY(void* newValue, const AZ::Uuid& valueType);
AZ::Outcome<void, AZStd::string> OnProbeSpacingValidateZ(void* newValue, const AZ::Uuid& valueType);
AZ::u32 OnProbeSpacingChanged();
AZ::u32 OnAmbientMultiplierChanged();
AZ::u32 OnViewBiasChanged();
AZ::u32 OnNormalBiasChanged();
// properties
float m_probeSpacingX = DefaultDiffuseProbeGridSpacing;
float m_probeSpacingY = DefaultDiffuseProbeGridSpacing;
float m_probeSpacingZ = DefaultDiffuseProbeGridSpacing;
float m_ambientMultiplier = DefaultDiffuseProbeGridAmbientMultiplier;
float m_viewBias = DefaultDiffuseProbeGridViewBias;
float m_normalBias = DefaultDiffuseProbeGridNormalBias;
};
} // namespace Render
} // namespace AZ