Added exposure controls to the ReflectionProbe component

Signed-off-by: dmcdiar <dmcdiar@amazon.com>
This commit is contained in:
dmcdiar
2021-11-08 16:11:30 -07:00
parent 1d106c0c8d
commit fe005c9c50
16 changed files with 99 additions and 9 deletions
@@ -40,6 +40,7 @@ namespace AZ
->Field("bakedCubeMapQualityLevel", &EditorReflectionProbeComponent::m_bakedCubeMapQualityLevel)
->Field("bakedCubeMapRelativePath", &EditorReflectionProbeComponent::m_bakedCubeMapRelativePath)
->Field("authoredCubeMapAsset", &EditorReflectionProbeComponent::m_authoredCubeMapAsset)
->Field("bakeExposure", &EditorReflectionProbeComponent::m_bakeExposure)
;
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
@@ -62,6 +63,13 @@ namespace AZ
->Attribute(AZ::Edit::Attributes::ButtonText, "Bake Reflection Probe")
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorReflectionProbeComponent::BakeReflectionProbe)
->Attribute(AZ::Edit::Attributes::Visibility, &EditorReflectionProbeComponent::GetBakedCubemapVisibilitySetting)
->DataElement(AZ::Edit::UIHandlers::Slider, &EditorReflectionProbeComponent::m_bakeExposure, "Bake Exposure", "Exposure to use when baking the cubemap")
->Attribute(AZ::Edit::Attributes::SoftMin, -5.0f)
->Attribute(AZ::Edit::Attributes::SoftMax, 5.0f)
->Attribute(AZ::Edit::Attributes::Min, -20.0f)
->Attribute(AZ::Edit::Attributes::Max, 20.0f)
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorReflectionProbeComponent::OnBakeExposureChanged)
->Attribute(AZ::Edit::Attributes::Visibility, &EditorReflectionProbeComponent::GetBakedCubemapVisibilitySetting)
->ClassElement(AZ::Edit::ClassElements::Group, "Cubemap")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::Default, &EditorReflectionProbeComponent::m_useBakedCubemap, "Use Baked Cubemap", "Selects between a cubemap that captures the environment at location in the scene or a preauthored cubemap")
@@ -111,6 +119,11 @@ namespace AZ
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->DataElement(AZ::Edit::UIHandlers::CheckBox, &ReflectionProbeComponentConfig::m_showVisualization, "Show Visualization", "Show the reflection probe visualization sphere")
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->DataElement(AZ::Edit::UIHandlers::Slider, &ReflectionProbeComponentConfig::m_renderExposure, "Exposure", "Exposure to use when rendering meshes with the cubemap")
->Attribute(AZ::Edit::Attributes::SoftMin, -5.0f)
->Attribute(AZ::Edit::Attributes::SoftMax, 5.0f)
->Attribute(AZ::Edit::Attributes::Min, -20.0f)
->Attribute(AZ::Edit::Attributes::Max, 20.0f)
;
}
}
@@ -275,6 +288,13 @@ namespace AZ
return AZ::Edit::PropertyRefreshLevels::None;
}
AZ::u32 EditorReflectionProbeComponent::OnBakeExposureChanged()
{
m_controller.SetBakeExposure(m_bakeExposure);
return AZ::Edit::PropertyRefreshLevels::None;
}
AZ::u32 EditorReflectionProbeComponent::GetBakedCubemapVisibilitySetting()
{
// controls specific to baked cubemaps call this to determine their visibility
@@ -55,6 +55,7 @@ namespace AZ
// change notifications
AZ::u32 OnUseBakedCubemapChanged();
AZ::u32 OnAuthoredCubemapChanged();
AZ::u32 OnBakeExposureChanged();
// retrieves visibility for baked or authored cubemap controls
AZ::u32 GetBakedCubemapVisibilitySetting();
@@ -77,6 +78,7 @@ namespace AZ
AZStd::string m_bakedCubeMapRelativePath;
Data::Asset<RPI::StreamingImageAsset> m_bakedCubeMapAsset;
Data::Asset<RPI::StreamingImageAsset> m_authoredCubeMapAsset;
float m_bakeExposure = 0.0f;
// flag indicating if a cubemap bake is currently in progress
AZStd::atomic_bool m_bakeInProgress = false;
@@ -35,7 +35,7 @@ namespace AZ
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
{
serializeContext->Class<ReflectionProbeComponentConfig>()
->Version(0)
->Version(1)
->Field("OuterHeight", &ReflectionProbeComponentConfig::m_outerHeight)
->Field("OuterLength", &ReflectionProbeComponentConfig::m_outerLength)
->Field("OuterWidth", &ReflectionProbeComponentConfig::m_outerWidth)
@@ -49,7 +49,9 @@ namespace AZ
->Field("AuthoredCubeMapAsset", &ReflectionProbeComponentConfig::m_authoredCubeMapAsset)
->Field("EntityId", &ReflectionProbeComponentConfig::m_entityId)
->Field("UseParallaxCorrection", &ReflectionProbeComponentConfig::m_useParallaxCorrection)
->Field("ShowVisualization", &ReflectionProbeComponentConfig::m_showVisualization);
->Field("ShowVisualization", &ReflectionProbeComponentConfig::m_showVisualization)
->Field("RenderExposure", &ReflectionProbeComponentConfig::m_renderExposure)
->Field("BakeExposure", &ReflectionProbeComponentConfig::m_bakeExposure);
}
}
@@ -157,6 +159,9 @@ namespace AZ
cubeMapAsset.QueueLoad();
Data::AssetBus::MultiHandler::BusConnect(cubeMapAsset.GetId());
}
// set cubemap render exposure
m_featureProcessor->SetRenderExposure(m_handle, m_configuration.m_renderExposure);
}
void ReflectionProbeComponentController::Deactivate()
@@ -284,6 +289,16 @@ namespace AZ
m_configuration.m_innerHeight = AZStd::min(m_configuration.m_innerHeight, m_configuration.m_outerHeight);
}
void ReflectionProbeComponentController::SetBakeExposure(float bakeExposure)
{
if (!m_featureProcessor)
{
return;
}
m_featureProcessor->SetBakeExposure(m_handle, bakeExposure);
}
void ReflectionProbeComponentController::BakeReflectionProbe(BuildCubeMapCallback callback, const AZStd::string& relativePath)
{
if (!m_featureProcessor)
@@ -68,6 +68,9 @@ namespace AZ
Data::Asset<RPI::StreamingImageAsset> m_bakedCubeMapAsset;
Data::Asset<RPI::StreamingImageAsset> m_authoredCubeMapAsset;
AZ::u64 m_entityId{ EntityId::InvalidEntityId };
float m_renderExposure = 0.0f;
float m_bakeExposure = 0.0f;
};
class ReflectionProbeComponentController final
@@ -99,6 +102,9 @@ namespace AZ
// returns the outer extent Aabb for this reflection
AZ::Aabb GetAabb() const;
// set the exposure to use when baking the cubemap
void SetBakeExposure(float bakeExposure);
// initiate the reflection probe bake, invokes callback when complete
void BakeReflectionProbe(BuildCubeMapCallback callback, const AZStd::string& relativePath);