LookModificationCompositePass.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 <AzCore/std/containers/unordered_map.h>
  11. #include <AzFramework/Windowing/WindowBus.h>
  12. #include <Atom/RHI/CommandList.h>
  13. #include <Atom/RHI/DeviceDrawItem.h>
  14. #include <Atom/RHI/ScopeProducer.h>
  15. #include <Atom/RPI.Reflect/Shader/ShaderVariantKey.h>
  16. #include <Atom/RPI.Public/Pass/FullscreenTrianglePass.h>
  17. #include <Atom/RPI.Public/Shader/Shader.h>
  18. #include <Atom/RPI.Public/Shader/ShaderResourceGroup.h>
  19. #include <Atom/Feature/ACES/AcesDisplayMapperFeatureProcessor.h>
  20. #include <PostProcessing/PostProcessingShaderOptionBase.h>
  21. namespace AZ
  22. {
  23. namespace Render
  24. {
  25. static const char* const LookModificationTransformPassTemplateName{ "LookModificationTransformTemplate" };
  26. /**
  27. * The look modification composite pass. If color grading LUTs are enabled, this pass will apply the blended LUT.
  28. */
  29. class LookModificationCompositePass
  30. : public AZ::RPI::FullscreenTrianglePass
  31. , public PostProcessingShaderOptionBase
  32. {
  33. public:
  34. AZ_RTTI(LookModificationCompositePass, "{D7DF3E8A-B642-4D51-ABC2-ADB2B60FCE1D}", AZ::RPI::FullscreenTrianglePass);
  35. AZ_CLASS_ALLOCATOR(LookModificationCompositePass, SystemAllocator);
  36. enum class SampleQuality : uint8_t
  37. {
  38. Linear = 0,
  39. BSpline7Tap = 1,
  40. BSpline19Tap = 2,
  41. };
  42. virtual ~LookModificationCompositePass() = default;
  43. //! Creates a LookModificationPass
  44. static RPI::Ptr<LookModificationCompositePass> Create(const RPI::PassDescriptor& descriptor);
  45. //! Set whether exposure control is enabled
  46. void SetExposureControlEnabled(bool enabled);
  47. //! Set shaper parameters
  48. void SetShaperParameters(const ShaperParams& shaperParams);
  49. void SetSampleQuality(SampleQuality sampleQuality);
  50. protected:
  51. LookModificationCompositePass(const RPI::PassDescriptor& descriptor);
  52. //! Pass behavior overrides
  53. void InitializeInternal() override;
  54. void FrameBeginInternal(FramePrepareParams params) final;
  55. private:
  56. void InitializeShaderVariant();
  57. void UpdateCurrentShaderVariant();
  58. // Scope producer functions...
  59. void CompileResources(const RHI::FrameGraphCompileContext& context) override;
  60. void BuildCommandListInternal(const RHI::FrameGraphExecuteContext& context) override;
  61. void UpdateExposureFeatureState();
  62. void UpdateLookModificationFeatureState();
  63. void SetColorGradingLutEnabled(bool enabled);
  64. bool m_exposureControlEnabled = false;
  65. bool m_colorGradingLutEnabled = false;
  66. SampleQuality m_sampleQuality = SampleQuality::Linear;
  67. Render::DisplayMapperLut m_blendedColorGradingLut;
  68. Render::ShaperParams m_colorGradingShaperParams;
  69. const AZ::Name m_exposureShaderVariantOptionName{ "o_enableExposureControlFeature" };
  70. const AZ::Name m_colorGradingShaderVariantOptionName{ "o_enableColorGradingLut" };
  71. const AZ::Name m_lutSampleQualityShaderVariantOptionName{ "o_lutSampleQuality" };
  72. bool m_needToUpdateShaderVariant = true;
  73. RHI::ShaderInputNameIndex m_shaderColorGradingLutImageIndex = "m_gradingLut";
  74. RHI::ShaderInputNameIndex m_shaderColorGradingShaperTypeIndex = "m_shaperType";
  75. RHI::ShaderInputNameIndex m_shaderColorGradingShaperBiasIndex = "m_shaperBias";
  76. RHI::ShaderInputNameIndex m_shaderColorGradingShaperScaleIndex = "m_shaperScale";
  77. };
  78. } // namespace Render
  79. } // namespace AZ