FullscreenShadowPass.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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/DrawItem.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 SetReceiverShadowPlaneBiasEnable(bool enable)
  42. {
  43. m_receiverShadowPlaneBiasEnable = enable;
  44. }
  45. // Set directional light's raw index which is used for accessing the directional light in the shader
  46. void SetLightRawIndex(int lightRawIndex)
  47. {
  48. m_lightIndex = lightRawIndex;
  49. }
  50. private:
  51. bool m_blendBetweenCascadesEnable = false;
  52. bool m_receiverShadowPlaneBiasEnable = false;
  53. ShadowFilterMethod m_filterMethod = ShadowFilterMethod::None;
  54. FullscreenShadowPass(const RPI::PassDescriptor& descriptor);
  55. // Pass behavior overrides...
  56. void InitializeInternal() override;
  57. // Scope producer functions...
  58. void CompileResources(const RHI::FrameGraphCompileContext& context) override;
  59. AZ::RHI::Size GetDepthBufferDimensions();
  60. uint16_t GetDepthBufferMSAACount();
  61. void SetConstantData();
  62. AZ::RHI::ShaderInputNameIndex m_constantDataIndex = "m_constantData";
  63. int m_lightIndex = 0;
  64. AZ::Name m_depthInputName;
  65. AZ::Name m_outputName;
  66. };
  67. } // namespace Render
  68. } // namespace AZ