Bloom.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // Copyright (C) 2009-2016, Panagiotis Christopoulos Charitos.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <anki/renderer/RenderingPass.h>
  7. #include <anki/Gr.h>
  8. #include <anki/resource/TextureResource.h>
  9. #include <anki/resource/ShaderResource.h>
  10. #include <anki/core/Timestamp.h>
  11. namespace anki
  12. {
  13. class ShaderProgram;
  14. /// @addtogroup renderer
  15. /// @{
  16. /// Bloom pass.
  17. class Bloom : public RenderingPass
  18. {
  19. public:
  20. U32 getBlurringIterationsCount() const
  21. {
  22. return m_blurringIterationsCount;
  23. }
  24. void setBlurringIterationsCount(const U32 x)
  25. {
  26. m_blurringIterationsCount = x;
  27. }
  28. anki_internal:
  29. static const PixelFormat RT_PIXEL_FORMAT;
  30. Bloom(Renderer* r)
  31. : RenderingPass(r)
  32. {
  33. }
  34. ~Bloom();
  35. ANKI_USE_RESULT Error init(const ConfigSet& initializer);
  36. void run(CommandBufferPtr& jobs);
  37. TexturePtr& getRt()
  38. {
  39. return m_vblurRt;
  40. }
  41. U32 getWidth() const
  42. {
  43. return m_width;
  44. }
  45. U32 getHeight() const
  46. {
  47. return m_height;
  48. }
  49. private:
  50. U32 m_width, m_height;
  51. F32 m_threshold = 10.0; ///< How bright it is
  52. F32 m_scale = 1.0;
  53. U32 m_blurringIterationsCount = 2; ///< The blurring iterations
  54. F32 m_blurringDist = 1.0; ///< Distance in blurring
  55. FramebufferPtr m_hblurFb;
  56. FramebufferPtr m_vblurFb;
  57. ShaderResourcePtr m_toneFrag;
  58. ShaderResourcePtr m_hblurFrag;
  59. ShaderResourcePtr m_vblurFrag;
  60. PipelinePtr m_tonePpline;
  61. PipelinePtr m_hblurPpline;
  62. PipelinePtr m_vblurPpline;
  63. TexturePtr m_hblurRt; ///< pass0Fai with the horizontal blur FAI
  64. TexturePtr m_vblurRt; ///< The final FAI
  65. ResourceGroupPtr m_firstDescrGroup;
  66. ResourceGroupPtr m_hDescrGroup;
  67. ResourceGroupPtr m_vDescrGroup;
  68. ANKI_USE_RESULT Error initFb(FramebufferPtr& fb, TexturePtr& rt);
  69. ANKI_USE_RESULT Error initInternal(const ConfigSet& initializer);
  70. };
  71. /// @}
  72. } // end namespace anki