LookModificationTransformPass.cpp 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 <Atom/RPI.Public/Pass/Specific/SwapChainPass.h>
  9. #include <PostProcessing/LookModificationTransformPass.h>
  10. #include <PostProcess/PostProcessFeatureProcessor.h>
  11. #include <PostProcessing/BlendColorGradingLutsPass.h>
  12. #include <PostProcessing/LookModificationCompositePass.h>
  13. namespace AZ
  14. {
  15. namespace Render
  16. {
  17. RPI::Ptr<LookModificationPass> LookModificationPass::Create(const RPI::PassDescriptor& descriptor)
  18. {
  19. RPI::Ptr<LookModificationPass> pass = aznew LookModificationPass(descriptor);
  20. return pass;
  21. }
  22. LookModificationPass::LookModificationPass(const RPI::PassDescriptor& descriptor)
  23. : RPI::ParentPass(descriptor)
  24. {
  25. AzFramework::NativeWindowHandle windowHandle = nullptr;
  26. AzFramework::WindowSystemRequestBus::BroadcastResult(
  27. windowHandle,
  28. &AzFramework::WindowSystemRequestBus::Events::GetDefaultWindowHandle);
  29. }
  30. void LookModificationPass::BuildInternal()
  31. {
  32. m_pipelineOutput = FindAttachmentBinding(Name("PipelineOutput"));
  33. ParentPass::BuildInternal();
  34. }
  35. void LookModificationPass::FrameBeginInternal([[maybe_unused]] FramePrepareParams params)
  36. {
  37. // Get swap chain format
  38. RHI::Format swapChainFormat = RHI::Format::Unknown;
  39. if (m_pipelineOutput && m_pipelineOutput->GetAttachment())
  40. {
  41. swapChainFormat = m_pipelineOutput->GetAttachment()->m_descriptor.m_image.m_format;
  42. }
  43. // Update the children passes
  44. RPI::Ptr<BlendColorGradingLutsPass> blendPass = FindChildPass<BlendColorGradingLutsPass>();
  45. if (blendPass)
  46. {
  47. auto commonShaperParams = blendPass->GetCommonShaperParams();
  48. if (commonShaperParams)
  49. {
  50. m_shaperParams = *commonShaperParams;
  51. }
  52. else
  53. {
  54. // Mix of shapers used, so shape them based on the output transform type.
  55. m_displayBufferFormat = swapChainFormat;
  56. m_outputDeviceTransformType = AcesDisplayMapperFeatureProcessor::GetOutputDeviceTransformType(m_displayBufferFormat);
  57. m_shaperParams = GetAcesShaperParameters(m_outputDeviceTransformType);
  58. }
  59. blendPass->SetShaperParameters(m_shaperParams);
  60. RPI::Ptr<LookModificationCompositePass> compositePass = FindChildPass<LookModificationCompositePass>();
  61. if (compositePass)
  62. {
  63. compositePass->SetShaperParameters(m_shaperParams);
  64. }
  65. }
  66. ParentPass::FrameBeginInternal(params);
  67. }
  68. } // namespace Render
  69. } // namespace AZ