Bloom.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <AnKi/Renderer/RendererObject.h>
  7. #include <AnKi/Gr.h>
  8. #include <AnKi/Resource/ImageResource.h>
  9. namespace anki {
  10. // Forward
  11. extern NumericCVar<F32> g_bloomThresholdCVar;
  12. /// @addtogroup renderer
  13. /// @{
  14. /// Bloom passes.
  15. class Bloom : public RendererObject
  16. {
  17. public:
  18. Bloom();
  19. ~Bloom();
  20. Error init()
  21. {
  22. const Error err = initInternal();
  23. if(err)
  24. {
  25. ANKI_R_LOGE("Failed to initialize bloom passes");
  26. }
  27. return err;
  28. }
  29. /// Populate the rendergraph.
  30. void populateRenderGraph(RenderingContext& ctx);
  31. RenderTargetHandle getRt() const
  32. {
  33. return m_runCtx.m_upscaleRt;
  34. }
  35. private:
  36. static constexpr Format kRtPixelFormat = Format::kA2B10G10R10_Unorm_Pack32;
  37. FramebufferDescription m_fbDescr;
  38. class
  39. {
  40. public:
  41. ShaderProgramResourcePtr m_prog;
  42. ShaderProgramPtr m_grProg;
  43. U32 m_width = 0;
  44. U32 m_height = 0;
  45. RenderTargetDescription m_rtDescr;
  46. } m_exposure;
  47. class
  48. {
  49. public:
  50. ImageResourcePtr m_lensDirtImage;
  51. ShaderProgramResourcePtr m_prog;
  52. ShaderProgramPtr m_grProg;
  53. U32 m_width = 0;
  54. U32 m_height = 0;
  55. RenderTargetDescription m_rtDescr;
  56. } m_upscale;
  57. class
  58. {
  59. public:
  60. RenderTargetHandle m_exposureRt;
  61. RenderTargetHandle m_upscaleRt;
  62. } m_runCtx;
  63. Error initExposure();
  64. Error initUpscale();
  65. Error initInternal();
  66. void getDebugRenderTarget(CString rtName, Array<RenderTargetHandle, kMaxDebugRenderTargets>& handles,
  67. [[maybe_unused]] ShaderProgramPtr& optionalShaderProgram) const override;
  68. };
  69. /// @}
  70. } // end namespace anki