From ca606a5e0858dec0cccd85c393f85e61e45ab362 Mon Sep 17 00:00:00 2001 From: dmcdiar Date: Wed, 30 Jun 2021 18:35:25 -0700 Subject: [PATCH] Set IBL exposure value to 0.0 while baking ReflectionProbe cubemaps Signed-off-by: dmcdiar --- .../ReflectionProbe/ReflectionProbe.cpp | 35 ++++++++++++++----- .../Source/ReflectionProbe/ReflectionProbe.h | 2 ++ 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.cpp b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.cpp index 10e8f16b4c..95755fc509 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.cpp @@ -96,16 +96,29 @@ namespace AZ void ReflectionProbe::Simulate(uint32_t probeIndex) { - if (m_buildingCubeMap && m_environmentCubeMapPass->IsFinished()) + if (m_buildingCubeMap) { - // all faces of the cubemap have been rendered, invoke the callback - m_callback(m_environmentCubeMapPass->GetTextureData(), m_environmentCubeMapPass->GetTextureFormat()); - - // remove the pipeline - m_scene->RemoveRenderPipeline(m_environmentCubeMapPipelineId); - m_environmentCubeMapPass = nullptr; - - m_buildingCubeMap = false; + Data::Instance sceneSrg = m_scene->GetShaderResourceGroup(); + + if (m_environmentCubeMapPass->IsFinished()) + { + // all faces of the cubemap have been rendered, invoke the callback + m_callback(m_environmentCubeMapPass->GetTextureData(), m_environmentCubeMapPass->GetTextureFormat()); + + // remove the pipeline + m_scene->RemoveRenderPipeline(m_environmentCubeMapPipelineId); + m_environmentCubeMapPass = nullptr; + + // restore exposure + sceneSrg->SetConstant(m_iblExposureConstantIndex, m_previousExposure); + + m_buildingCubeMap = false; + } + else + { + // set exposure to 0.0 while baking the cubemap + sceneSrg->SetConstant(m_iblExposureConstantIndex, 0.0f); + } } // track if we need to update culling based on changes to the draw packets or Srg @@ -283,6 +296,10 @@ namespace AZ const RPI::Ptr& rootPass = environmentCubeMapPipeline->GetRootPass(); rootPass->AddChild(m_environmentCubeMapPass); + // store the current IBL exposure value + Data::Instance sceneSrg = m_scene->GetShaderResourceGroup(); + m_previousExposure = sceneSrg->GetConstant(m_iblExposureConstantIndex); + m_scene->AddRenderPipeline(environmentCubeMapPipeline); } diff --git a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.h b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.h index c354d39d53..48add33260 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.h +++ b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.h @@ -163,6 +163,8 @@ namespace AZ RPI::Ptr m_environmentCubeMapPass = nullptr; RPI::RenderPipelineId m_environmentCubeMapPipelineId; BuildCubeMapCallback m_callback; + RHI::ShaderInputNameIndex m_iblExposureConstantIndex = "m_iblExposure"; + float m_previousExposure = 0.0f; bool m_buildingCubeMap = false; };