BloomParentPass.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <AzCore/Console/IConsole.h>
  9. #include <Atom/RPI.Public/RenderPipeline.h>
  10. #include <Atom/RPI.Public/Scene.h>
  11. #include <Atom/RPI.Public/View.h>
  12. #include <PostProcess/PostProcessFeatureProcessor.h>
  13. #include <PostProcess/Bloom/BloomSettings.h>
  14. #include <PostProcessing/BloomParentPass.h>
  15. namespace AZ
  16. {
  17. namespace Render
  18. {
  19. AZ_CVAR(bool, r_enableBloom, true, nullptr, AZ::ConsoleFunctorFlags::Null, "Enable bloom effect support");
  20. RPI::Ptr<BloomParentPass> BloomParentPass::Create(const RPI::PassDescriptor& descriptor)
  21. {
  22. RPI::Ptr<BloomParentPass> pass = aznew BloomParentPass(descriptor);
  23. return pass;
  24. }
  25. BloomParentPass::BloomParentPass(const RPI::PassDescriptor& descriptor)
  26. : RPI::ParentPass(descriptor)
  27. { }
  28. bool BloomParentPass::IsEnabled() const
  29. {
  30. if (!r_enableBloom)
  31. {
  32. return false;
  33. }
  34. if (!ParentPass::IsEnabled())
  35. {
  36. return false;
  37. }
  38. const RPI::Scene* scene = GetScene();
  39. if (!scene)
  40. {
  41. return false;
  42. }
  43. PostProcessFeatureProcessor* fp = scene->GetFeatureProcessor<PostProcessFeatureProcessor>();
  44. const RPI::ViewPtr view = GetRenderPipeline()->GetFirstView(GetPipelineViewTag());
  45. if (!fp)
  46. {
  47. return false;
  48. }
  49. PostProcessSettings* postProcessSettings = fp->GetLevelSettingsFromView(view);
  50. if (!postProcessSettings)
  51. {
  52. return false;
  53. }
  54. const BloomSettings* bloomSettings = postProcessSettings->GetBloomSettings();
  55. return (bloomSettings != nullptr) && bloomSettings->GetEnabled();
  56. }
  57. } // namespace Render
  58. } // namespace AZ