ReflectionScreenSpaceCompositePass.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 "ReflectionScreenSpaceCompositePass.h"
  9. #include "ReflectionScreenSpaceBlurPass.h"
  10. #include <Atom/RPI.Public/Pass/PassSystemInterface.h>
  11. #include <Atom/RPI.Public/Pass/PassFilter.h>
  12. #include <Atom/RPI.Public/RenderPipeline.h>
  13. #include <Atom/RPI.Public/Scene.h>
  14. #include <Atom/Feature/SpecularReflections/SpecularReflectionsFeatureProcessorInterface.h>
  15. namespace AZ
  16. {
  17. namespace Render
  18. {
  19. RPI::Ptr<ReflectionScreenSpaceCompositePass> ReflectionScreenSpaceCompositePass::Create(const RPI::PassDescriptor& descriptor)
  20. {
  21. RPI::Ptr<ReflectionScreenSpaceCompositePass> pass = aznew ReflectionScreenSpaceCompositePass(descriptor);
  22. return AZStd::move(pass);
  23. }
  24. ReflectionScreenSpaceCompositePass::ReflectionScreenSpaceCompositePass(const RPI::PassDescriptor& descriptor)
  25. : RPI::FullscreenTrianglePass(descriptor)
  26. {
  27. }
  28. void ReflectionScreenSpaceCompositePass::CompileResources([[maybe_unused]] const RHI::FrameGraphCompileContext& context)
  29. {
  30. if (!m_shaderResourceGroup)
  31. {
  32. return;
  33. }
  34. RPI::Scene* scene = m_pipeline->GetScene();
  35. SpecularReflectionsFeatureProcessorInterface* specularReflectionsFeatureProcessor = scene->GetFeatureProcessor<SpecularReflectionsFeatureProcessorInterface>();
  36. AZ_Assert(specularReflectionsFeatureProcessor, "ReflectionScreenSpaceCompositePass requires the SpecularReflectionsFeatureProcessor");
  37. RPI::PassAttachment* outputAttachment = GetOutputBinding(0).GetAttachment().get();
  38. AZ_Assert(outputAttachment, "ReflectionScreenSpaceCompositePass: Output binding has no attachment!");
  39. RHI::Size outputImageSize = outputAttachment->m_descriptor.m_image.m_size;
  40. const SSROptions& ssrOptions = specularReflectionsFeatureProcessor->GetSSROptions();
  41. m_shaderResourceGroup->SetConstant(m_outputScaleNameIndex, ssrOptions.GetOutputScale());
  42. m_shaderResourceGroup->SetConstant(m_outputWidthNameIndex, outputImageSize.m_width);
  43. m_shaderResourceGroup->SetConstant(m_outputHeightNameIndex, outputImageSize.m_height);
  44. m_shaderResourceGroup->SetConstant(m_maxRoughnessNameIndex, ssrOptions.m_maxRoughness);
  45. FullscreenTrianglePass::CompileResources(context);
  46. }
  47. } // namespace RPI
  48. } // namespace AZ