Bloom.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Copyright (C) 2009-present, 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. namespace anki {
  8. /// @addtogroup renderer
  9. /// @{
  10. ANKI_CVAR2(NumericCVar<F32>, Render, Bloom, Threshold, 2.5f, 0.0f, 256.0f, "Bloom threshold")
  11. ANKI_CVAR2(NumericCVar<F32>, Render, Bloom, Scale, 2.5f, 0.0f, 256.0f, "Bloom scale")
  12. ANKI_CVAR2(NumericCVar<U32>, Render, Bloom, PyramidLowLimit, 32, 8, 1024, "Downscale the boom pyramid up to that size")
  13. ANKI_CVAR2(NumericCVar<U32>, Render, Bloom, UpscaleDivisor, 4, 1, 1024, "Defines the resolution of the final bloom result")
  14. /// Contains multiple post-process passes that operate on the HDR output.
  15. class Bloom : public RendererObject
  16. {
  17. public:
  18. Bloom()
  19. {
  20. registerDebugRenderTarget("Bloom");
  21. }
  22. Error init();
  23. void importRenderTargets(RenderingContext& ctx);
  24. void populateRenderGraph(RenderingContext& ctx);
  25. RenderTargetHandle getPyramidRt() const
  26. {
  27. return m_runCtx.m_pyramidRt;
  28. }
  29. UVec2 getPyramidTextureSize() const
  30. {
  31. return UVec2(m_pyramidTex->getWidth(), m_pyramidTex->getHeight());
  32. }
  33. U32 getPyramidTextureMipmapCount() const
  34. {
  35. return m_pyramidTex->getMipmapCount();
  36. }
  37. RenderTargetHandle getBloomRt() const
  38. {
  39. return m_runCtx.m_finalRt;
  40. }
  41. void getDebugRenderTarget([[maybe_unused]] CString rtName, Array<RenderTargetHandle, U32(DebugRenderTargetRegister::kCount)>& handles,
  42. [[maybe_unused]] DebugRenderTargetDrawStyle& drawStyle) const override
  43. {
  44. handles[0] = m_runCtx.m_finalRt;
  45. drawStyle = DebugRenderTargetDrawStyle::kTonemap;
  46. }
  47. private:
  48. ShaderProgramResourcePtr m_prog;
  49. ShaderProgramPtr m_downscaleGrProg;
  50. ShaderProgramPtr m_exposureGrProg;
  51. ShaderProgramPtr m_upscaleGrProg;
  52. TexturePtr m_pyramidTex;
  53. RenderTargetDesc m_exposureRtDesc;
  54. RenderTargetDesc m_finalRtDesc;
  55. ImageResourcePtr m_lensDirtImg;
  56. class
  57. {
  58. public:
  59. RenderTargetHandle m_pyramidRt;
  60. RenderTargetHandle m_finalRt;
  61. } m_runCtx;
  62. };
  63. /// @}
  64. } // end namespace anki