Fix track view bug where postfxs do not render correctly. (#5465)
* Fix track view bug where postfxs do not render correctly. Signed-off-by: hershey5045 <43485729+hershey5045@users.noreply.github.com> * Reduce scope and add comments. Signed-off-by: hershey5045 <43485729+hershey5045@users.noreply.github.com>
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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<AZ::RPI::View*, PostProcessSettings> m_blendedPerViewSettings;
|
||||
// This is used for mimicking a postfx setting of a different view
|
||||
AZStd::unordered_map<AZ::RPI::View*, AZ::RPI::View*> m_viewAliasMap;
|
||||
};
|
||||
} // namespace Render
|
||||
} // namespace AZ
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace AZ
|
||||
if (scene)
|
||||
{
|
||||
PostProcessFeatureProcessor* fp = scene->GetFeatureProcessor<PostProcessFeatureProcessor>();
|
||||
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<PostProcessFeatureProcessor>();
|
||||
if (fp)
|
||||
{
|
||||
AZ::RPI::ViewPtr view = GetView();
|
||||
AZ::RPI::ViewPtr view = GetRenderPipeline()->GetDefaultView();
|
||||
PostProcessSettings* postProcessSettings = fp->GetLevelSettingsFromView(view);
|
||||
if (postProcessSettings)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user