diff --git a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.cpp b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.cpp index c6035f2ba4..34fbfeb2d2 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 feac1b681c..7632595d0a 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; };