Bloom.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Copyright (C) 2009-2022, 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. /// @addtogroup renderer
  11. /// @{
  12. /// Bloom passes.
  13. class Bloom : public RendererObject
  14. {
  15. public:
  16. Bloom(Renderer* r);
  17. ~Bloom();
  18. Error init()
  19. {
  20. const Error err = initInternal();
  21. if(err)
  22. {
  23. ANKI_R_LOGE("Failed to initialize bloom passes");
  24. }
  25. return err;
  26. }
  27. /// Populate the rendergraph.
  28. void populateRenderGraph(RenderingContext& ctx);
  29. RenderTargetHandle getRt() const
  30. {
  31. return m_runCtx.m_upscaleRt;
  32. }
  33. private:
  34. static constexpr Format RT_PIXEL_FORMAT = Format::A2B10G10R10_UNORM_PACK32;
  35. const Array<U32, 2> m_workgroupSize = {16, 16};
  36. FramebufferDescription m_fbDescr;
  37. class
  38. {
  39. public:
  40. ShaderProgramResourcePtr m_prog;
  41. ShaderProgramPtr m_grProg;
  42. U32 m_width = 0;
  43. U32 m_height = 0;
  44. RenderTargetDescription m_rtDescr;
  45. } m_exposure;
  46. class
  47. {
  48. public:
  49. ImageResourcePtr m_lensDirtImage;
  50. ShaderProgramResourcePtr m_prog;
  51. ShaderProgramPtr m_grProg;
  52. U32 m_width = 0;
  53. U32 m_height = 0;
  54. RenderTargetDescription m_rtDescr;
  55. } m_upscale;
  56. class
  57. {
  58. public:
  59. RenderTargetHandle m_exposureRt;
  60. RenderTargetHandle m_upscaleRt;
  61. } m_runCtx;
  62. Error initExposure();
  63. Error initUpscale();
  64. Error initInternal();
  65. void getDebugRenderTarget(CString rtName, RenderTargetHandle& handle,
  66. [[maybe_unused]] ShaderProgramPtr& optionalShaderProgram) const override;
  67. };
  68. /// @}
  69. } // end namespace anki