FullscreenShadowPass.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. #pragma once
  9. #include <AzCore/Memory/SystemAllocator.h>
  10. #include <Atom/RHI/CommandList.h>
  11. #include <Atom/RHI/DeviceDrawItem.h>
  12. #include <Atom/RHI/ScopeProducer.h>
  13. #include <Atom/RHI.Reflect/ShaderResourceGroupLayoutDescriptor.h>
  14. #include <Atom/RPI.Public/Pass/ComputePass.h>
  15. #include <Atom/RPI.Public/Pass/FullscreenTrianglePass.h>
  16. #include <Atom/RPI.Public/Shader/Shader.h>
  17. #include <Atom/RPI.Public/Shader/ShaderResourceGroup.h>
  18. #include <Atom/Feature/CoreLights/ShadowConstants.h>
  19. namespace AZ
  20. {
  21. namespace Render
  22. {
  23. class FullscreenShadowPass final
  24. : public RPI::FullscreenTrianglePass
  25. {
  26. AZ_RPI_PASS(FullscreenShadowPass);
  27. using Base = RPI::FullscreenTrianglePass;
  28. public:
  29. AZ_RTTI(AZ::Render::FullscreenShadowPass, "{A7D3076A-DD01-4B79-AF34-4BB72DAD35E2}", RPI::FullscreenTrianglePass);
  30. AZ_CLASS_ALLOCATOR(FullscreenShadowPass, SystemAllocator);
  31. virtual ~FullscreenShadowPass() = default;
  32. static RPI::Ptr<FullscreenShadowPass> Create(const RPI::PassDescriptor& descriptor);
  33. void SetBlendBetweenCascadesEnable(bool enable)
  34. {
  35. m_blendBetweenCascadesEnable = enable;
  36. }
  37. void SetFilterMethod(AZ::Render::ShadowFilterMethod method)
  38. {
  39. m_filterMethod = method;
  40. }
  41. void SetFilteringSampleCountMode(AZ::Render::ShadowFilterSampleCount filteringSampleCount)
  42. {
  43. m_filteringSampleCountMode = filteringSampleCount;
  44. }
  45. void SetReceiverShadowPlaneBiasEnable(bool enable)
  46. {
  47. m_receiverShadowPlaneBiasEnable = enable;
  48. }
  49. // Set directional light's raw index which is used for accessing the directional light in the shader
  50. void SetLightRawIndex(int lightRawIndex)
  51. {
  52. m_lightIndex = lightRawIndex;
  53. }
  54. private:
  55. bool m_blendBetweenCascadesEnable = false;
  56. bool m_receiverShadowPlaneBiasEnable = false;
  57. ShadowFilterMethod m_filterMethod = ShadowFilterMethod::None;
  58. ShadowFilterSampleCount m_filteringSampleCountMode = ShadowFilterSampleCount::PcfTap16;
  59. FullscreenShadowPass(const RPI::PassDescriptor& descriptor);
  60. // Pass behavior overrides...
  61. void InitializeInternal() override;
  62. // Scope producer functions...
  63. void CompileResources(const RHI::FrameGraphCompileContext& context) override;
  64. AZ::RHI::Size GetDepthBufferDimensions();
  65. uint16_t GetDepthBufferMSAACount();
  66. void SetConstantData();
  67. AZ::RHI::ShaderInputNameIndex m_constantDataIndex = "m_constantData";
  68. int m_lightIndex = 0;
  69. AZ::Name m_depthInputName;
  70. AZ::Name m_outputName;
  71. };
  72. } // namespace Render
  73. } // namespace AZ