From 515e363151185c1270838f8155cf08e198549ed5 Mon Sep 17 00:00:00 2001 From: tjmgd <92784061+tjmgd@users.noreply.github.com> Date: Wed, 22 Dec 2021 19:50:14 +0000 Subject: [PATCH] added pass class (#6244) Signed-off-by: T.J. McGrath-Daly --- .../Assets/Passes/DiffuseComposite.pass | 2 +- .../Code/Source/CommonSystemComponent.cpp | 2 + .../DiffuseCompositePass.cpp | 45 +++++++++++++++++++ .../DiffuseCompositePass.h | 36 +++++++++++++++ .../Code/atom_feature_common_files.cmake | 2 + 5 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseCompositePass.cpp create mode 100644 Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseCompositePass.h diff --git a/Gems/Atom/Feature/Common/Assets/Passes/DiffuseComposite.pass b/Gems/Atom/Feature/Common/Assets/Passes/DiffuseComposite.pass index 615ee8a162..3ad5c06c90 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/DiffuseComposite.pass +++ b/Gems/Atom/Feature/Common/Assets/Passes/DiffuseComposite.pass @@ -5,7 +5,7 @@ "ClassData": { "PassTemplate": { "Name": "DiffuseCompositePassTemplate", - "PassClass": "FullScreenTriangle", + "PassClass": "DiffuseCompositePass", "Slots": [ { "Name": "DownsampledIrradianceInput", diff --git a/Gems/Atom/Feature/Common/Code/Source/CommonSystemComponent.cpp b/Gems/Atom/Feature/Common/Code/Source/CommonSystemComponent.cpp index a06defff08..04098f5c20 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CommonSystemComponent.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CommonSystemComponent.cpp @@ -96,6 +96,7 @@ #include #include #include +#include #include #include #include @@ -278,6 +279,7 @@ namespace AZ passSystem->AddPassCreator(Name("DiffuseProbeGridClassificationPass"), &Render::DiffuseProbeGridClassificationPass::Create); passSystem->AddPassCreator(Name("DiffuseProbeGridDownsamplePass"), &Render::DiffuseProbeGridDownsamplePass::Create); passSystem->AddPassCreator(Name("DiffuseProbeGridRenderPass"), &Render::DiffuseProbeGridRenderPass::Create); + passSystem->AddPassCreator(Name("DiffuseCompositePass"), &Render::DiffuseCompositePass::Create); passSystem->AddPassCreator(Name("LuminanceHistogramGeneratorPass"), &LuminanceHistogramGeneratorPass::Create); diff --git a/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseCompositePass.cpp b/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseCompositePass.cpp new file mode 100644 index 0000000000..0b0dfda391 --- /dev/null +++ b/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseCompositePass.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#include +#include + +namespace AZ +{ + namespace Render + { + // --- Dedicated class for disabling --- + + RPI::Ptr DiffuseCompositePass::Create(const RPI::PassDescriptor& descriptor) + { + RPI::Ptr pass = aznew DiffuseCompositePass(descriptor); + return AZStd::move(pass); + } + + DiffuseCompositePass::DiffuseCompositePass(const RPI::PassDescriptor& descriptor) + : RPI::FullscreenTrianglePass(descriptor) + { } + + bool DiffuseCompositePass::IsEnabled() const + { + const RPI::Scene* scene = GetScene(); + if (!scene) + { + return false; + } + DiffuseProbeGridFeatureProcessor* diffuseProbeGridFeatureProcessor = + scene->GetFeatureProcessor(); + if (!diffuseProbeGridFeatureProcessor || diffuseProbeGridFeatureProcessor->GetVisibleRealTimeProbeGrids().empty()) + { + // no diffuse probe grids + return false; + } + return true; + } + } // namespace Render +} // namespace AZ diff --git a/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseCompositePass.h b/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseCompositePass.h new file mode 100644 index 0000000000..333c66ebea --- /dev/null +++ b/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseCompositePass.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ +#pragma once + +#include + +namespace AZ +{ + namespace Render + { + //! A class for DiffuseComposite to allow for disabling + class DiffuseCompositePass final + : public RPI::FullscreenTrianglePass + { + AZ_RPI_PASS(DiffuseCompositePass); + + public: + AZ_RTTI(DiffuseCompositePass, "{F3DBEBCB-66F8-465C-A06B-DFA76B9D4856}", AZ::RPI::FullscreenTrianglePass); + AZ_CLASS_ALLOCATOR(DiffuseCompositePass, SystemAllocator, 0); + + ~DiffuseCompositePass() = default; + static RPI::Ptr Create(const RPI::PassDescriptor& descriptor); + + bool IsEnabled() const override; + + private: + DiffuseCompositePass(const RPI::PassDescriptor& descriptor); + + }; + } // namespace Render +} // namespace AZ \ No newline at end of file diff --git a/Gems/Atom/Feature/Common/Code/atom_feature_common_files.cmake b/Gems/Atom/Feature/Common/Code/atom_feature_common_files.cmake index 375dbd9724..952085e136 100644 --- a/Gems/Atom/Feature/Common/Code/atom_feature_common_files.cmake +++ b/Gems/Atom/Feature/Common/Code/atom_feature_common_files.cmake @@ -134,6 +134,8 @@ set(FILES Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.h Source/DiffuseGlobalIllumination/DiffuseProbeGridRenderPass.cpp Source/DiffuseGlobalIllumination/DiffuseProbeGridRenderPass.h + Source/DiffuseGlobalIllumination/DiffuseCompositePass.cpp + Source/DiffuseGlobalIllumination/DiffuseCompositePass.h Source/DiffuseGlobalIllumination/DiffuseProbeGrid.cpp Source/DiffuseGlobalIllumination/DiffuseProbeGrid.h Source/DiffuseGlobalIllumination/DiffuseProbeGridTextureReadback.cpp