SubsurfaceScatteringPass.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 <PostProcessing/SubsurfaceScatteringPass.h>
  9. #include <Atom/RHI/CommandList.h>
  10. #include <Atom/RHI/Factory.h>
  11. #include <Atom/RHI/FrameScheduler.h>
  12. #include <Atom/RPI.Reflect/Pass/PassTemplate.h>
  13. #include <Atom/RPI.Public/Pass/PassUtils.h>
  14. #include <Atom/RPI.Public/Pass/PassAttachment.h>
  15. #include <Atom/RPI.Public/RPIUtils.h>
  16. #include <Atom/RPI.Public/RenderPipeline.h>
  17. #include <Atom/RPI.Public/View.h>
  18. #include <Atom/RPI.Public/RPISystemInterface.h>
  19. #include <Atom/RPI.Public/Shader/ShaderResourceGroup.h>
  20. namespace AZ
  21. {
  22. namespace RPI
  23. {
  24. Ptr<SubsurfaceScatteringPass> SubsurfaceScatteringPass::Create(const PassDescriptor& descriptor)
  25. {
  26. Ptr<SubsurfaceScatteringPass> pass = aznew SubsurfaceScatteringPass(descriptor);
  27. return pass;
  28. }
  29. SubsurfaceScatteringPass::SubsurfaceScatteringPass(const PassDescriptor& descriptor)
  30. : ComputePass(descriptor)
  31. { }
  32. void SubsurfaceScatteringPass::CompileResources(const RHI::FrameGraphCompileContext& context)
  33. {
  34. RHI::Size targetImageSize;
  35. if (m_fullscreenDispatch)
  36. {
  37. auto attachment = m_fullscreenSizeSourceBinding->GetAttachment();
  38. if (attachment)
  39. {
  40. auto imageDescriptor = context.GetImageDescriptor(attachment->GetAttachmentId());
  41. targetImageSize = imageDescriptor.m_size;
  42. }
  43. }
  44. // Update shader constant
  45. m_shaderResourceGroup->SetConstant(m_screenSizeInputIndex, AZ::Vector2(static_cast<float>(targetImageSize.m_width), static_cast<float>(targetImageSize.m_height)));
  46. ComputePass::CompileResources(context);
  47. }
  48. } // namespace RPI
  49. } // namespace AZ