diff --git a/Code/Editor/TrackView/AtomOutputFrameCapture.cpp b/Code/Editor/TrackView/AtomOutputFrameCapture.cpp index 94451e6914..5943e3c2d7 100644 --- a/Code/Editor/TrackView/AtomOutputFrameCapture.cpp +++ b/Code/Editor/TrackView/AtomOutputFrameCapture.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -47,18 +48,42 @@ namespace TrackView AZ::Name viewName = AZ::Name("MainCamera"); m_view = AZ::RPI::View::CreateView(viewName, AZ::RPI::View::UsageCamera); m_renderPipeline->SetDefaultView(m_view); + m_targetView = scene.GetDefaultRenderPipeline()->GetDefaultView(); + if (AZ::Render::PostProcessFeatureProcessor* fp = scene.GetFeatureProcessor()) + { + // This will be set again to mimic the active camera in UpdateView + fp->SetViewAlias(m_view, m_targetView); + } } void AtomOutputFrameCapture::DestroyPipeline(AZ::RPI::Scene& scene) { + if (AZ::Render::PostProcessFeatureProcessor* fp = scene.GetFeatureProcessor()) + { + // Remove view alias introduced in CreatePipeline and UpdateView + fp->RemoveViewAlias(m_view); + } scene.RemoveRenderPipeline(m_renderPipeline->GetId()); m_passHierarchy.clear(); m_renderPipeline.reset(); m_view.reset(); + m_targetView.reset(); } - void AtomOutputFrameCapture::UpdateView(const AZ::Matrix3x4& cameraTransform, const AZ::Matrix4x4& cameraProjection) + void AtomOutputFrameCapture::UpdateView(const AZ::Matrix3x4& cameraTransform, const AZ::Matrix4x4& cameraProjection, const AZ::RPI::ViewPtr targetView) { + if (targetView && targetView != m_targetView) + { + if (AZ::RPI::Scene* scene = SceneFromGameEntityContext()) + { + if (AZ::Render::PostProcessFeatureProcessor* fp = scene->GetFeatureProcessor()) + { + fp->SetViewAlias(m_view, targetView); + m_targetView = targetView; + } + } + } + m_view->SetCameraTransform(cameraTransform); m_view->SetViewToClipMatrix(cameraProjection); } diff --git a/Code/Editor/TrackView/AtomOutputFrameCapture.h b/Code/Editor/TrackView/AtomOutputFrameCapture.h index 2686a81c99..4719ab08e5 100644 --- a/Code/Editor/TrackView/AtomOutputFrameCapture.h +++ b/Code/Editor/TrackView/AtomOutputFrameCapture.h @@ -39,11 +39,12 @@ namespace TrackView CaptureFinishedCallback captureFinishedCallback); //! Update the internal view that is associated with the created pipeline. - void UpdateView(const AZ::Matrix3x4& cameraTransform, const AZ::Matrix4x4& cameraProjection); + void UpdateView(const AZ::Matrix3x4& cameraTransform, const AZ::Matrix4x4& cameraProjection, const AZ::RPI::ViewPtr targetView = nullptr); private: AZ::RPI::RenderPipelinePtr m_renderPipeline; //!< The internal render pipeline. AZ::RPI::ViewPtr m_view; //!< The view associated with the render pipeline. + AZ::RPI::ViewPtr m_targetView; //!< The view that this render pipeline will mimic. AZStd::vector m_passHierarchy; //!< Pass hierarchy (includes pipelineName and CopyToSwapChain). CaptureFinishedCallback m_captureFinishedCallback; //!< Stored callback called from OnCaptureFinished. diff --git a/Code/Editor/TrackView/SequenceBatchRenderDialog.cpp b/Code/Editor/TrackView/SequenceBatchRenderDialog.cpp index d7901e338a..a796a8ce37 100644 --- a/Code/Editor/TrackView/SequenceBatchRenderDialog.cpp +++ b/Code/Editor/TrackView/SequenceBatchRenderDialog.cpp @@ -16,6 +16,7 @@ #include #include +#include // Qt #include @@ -91,9 +92,12 @@ namespace static void UpdateAtomOutputFrameCaptureView(TrackView::AtomOutputFrameCapture& atomOutputFrameCapture, const int width, const int height) { const AZ::EntityId activeCameraEntityId = TrackView::ActiveCameraEntityId(); + AZ::RPI::ViewPtr view = nullptr; + AZ::RPI::ViewProviderBus::EventResult(view, activeCameraEntityId, &AZ::RPI::ViewProvider::GetView); atomOutputFrameCapture.UpdateView( TrackView::TransformFromEntityId(activeCameraEntityId), - TrackView::ProjectionFromCameraEntityId(activeCameraEntityId, static_cast(width), static_cast(height))); + TrackView::ProjectionFromCameraEntityId(activeCameraEntityId, aznumeric_cast(width), aznumeric_cast(height)), + view); } CSequenceBatchRenderDialog::CSequenceBatchRenderDialog(float fps, QWidget* pParent /* = nullptr */) diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcess/PostProcessFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcess/PostProcessFeatureProcessor.cpp index a9d8d5105f..c8e683e1d1 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcess/PostProcessFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcess/PostProcessFeatureProcessor.cpp @@ -37,6 +37,11 @@ namespace AZ m_currentTime = AZStd::chrono::system_clock::now(); } + void PostProcessFeatureProcessor::Deactivate() + { + m_viewAliasMap.clear(); + } + void PostProcessFeatureProcessor::UpdateTime() { AZStd::chrono::system_clock::time_point now = AZStd::chrono::system_clock::now(); @@ -45,6 +50,16 @@ namespace AZ m_deltaTime = deltaTime.count(); } + void PostProcessFeatureProcessor::SetViewAlias(const AZ::RPI::ViewPtr sourceView, const AZ::RPI::ViewPtr targetView) + { + m_viewAliasMap[sourceView.get()] = targetView.get(); + } + + void PostProcessFeatureProcessor::RemoveViewAlias(const AZ::RPI::ViewPtr sourceView) + { + m_viewAliasMap.erase(sourceView.get()); + } + void PostProcessFeatureProcessor::Simulate(const FeatureProcessor::SimulatePacket& packet) { AZ_PROFILE_SCOPE(RPI, "PostProcessFeatureProcessor: Simulate"); @@ -200,8 +215,12 @@ namespace AZ AZ::Render::PostProcessSettings* PostProcessFeatureProcessor::GetLevelSettingsFromView(AZ::RPI::ViewPtr view) { + // check for view aliases first + auto viewAliasiterator = m_viewAliasMap.find(view.get()); + + // Use the view alias if it exists + auto settingsIterator = m_blendedPerViewSettings.find(viewAliasiterator != m_viewAliasMap.end() ? viewAliasiterator->second : view.get()); // If no settings for the view is found, the global settings is returned. - auto settingsIterator = m_blendedPerViewSettings.find(view.get()); return settingsIterator != m_blendedPerViewSettings.end() ? &settingsIterator->second : m_globalAggregateLevelSettings.get(); diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcess/PostProcessFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Source/PostProcess/PostProcessFeatureProcessor.h index 2c1cc98449..10af993d9d 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcess/PostProcessFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcess/PostProcessFeatureProcessor.h @@ -34,6 +34,7 @@ namespace AZ //! FeatureProcessor overrides... void Activate() override; + void Deactivate() override; void Simulate(const FeatureProcessor::SimulatePacket& packet) override; //! PostProcessFeatureProcessorInterface... @@ -43,6 +44,9 @@ namespace AZ void OnPostProcessSettingsChanged() override; PostProcessSettings* GetLevelSettingsFromView(AZ::RPI::ViewPtr view); + void SetViewAlias(const AZ::RPI::ViewPtr sourceView, const AZ::RPI::ViewPtr targetView); + void RemoveViewAlias(const AZ::RPI::ViewPtr sourceView); + private: PostProcessFeatureProcessor(const PostProcessFeatureProcessor&) = delete; @@ -83,6 +87,8 @@ namespace AZ // Each camera/view will have its own PostProcessSettings AZStd::unordered_map m_blendedPerViewSettings; + // This is used for mimicking a postfx setting of a different view + AZStd::unordered_map m_viewAliasMap; }; } // namespace Render } // namespace AZ diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.cpp index 862892ad1b..5683241693 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.cpp @@ -81,7 +81,7 @@ namespace AZ if (scene) { PostProcessFeatureProcessor* fp = scene->GetFeatureProcessor(); - AZ::RPI::ViewPtr view = GetView(); + AZ::RPI::ViewPtr view = GetRenderPipeline()->GetDefaultView(); if (fp) { PostProcessSettings* postProcessSettings = fp->GetLevelSettingsFromView(view); @@ -110,7 +110,7 @@ namespace AZ PostProcessFeatureProcessor* fp = scene->GetFeatureProcessor(); if (fp) { - AZ::RPI::ViewPtr view = GetView(); + AZ::RPI::ViewPtr view = GetRenderPipeline()->GetDefaultView(); PostProcessSettings* postProcessSettings = fp->GetLevelSettingsFromView(view); if (postProcessSettings) {