Ssao.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Copyright (C) 2009-2021, 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/Resource/ImageResource.h>
  8. #include <AnKi/Gr.h>
  9. namespace anki
  10. {
  11. /// @addtogroup renderer
  12. /// @{
  13. /// Screen space ambient occlusion pass
  14. class Ssao : public RendererObject
  15. {
  16. public:
  17. static const Format RT_PIXEL_FORMAT = Format::R8_UNORM;
  18. Ssao(Renderer* r)
  19. : RendererObject(r)
  20. {
  21. }
  22. ~Ssao();
  23. ANKI_USE_RESULT Error init(const ConfigSet& config);
  24. /// Populate the rendergraph.
  25. void populateRenderGraph(RenderingContext& ctx);
  26. RenderTargetHandle getRt() const
  27. {
  28. return m_runCtx.m_rts[1];
  29. }
  30. private:
  31. static const Bool m_useNormal = false;
  32. static const Bool m_useCompute = true;
  33. static const Bool m_useSoftBlur = true;
  34. static const Bool m_blurUseCompute = true;
  35. U32 m_width, m_height;
  36. class
  37. {
  38. public:
  39. ShaderProgramResourcePtr m_prog;
  40. ShaderProgramPtr m_grProg;
  41. ImageResourcePtr m_noiseImage;
  42. Array<U32, 2> m_workgroupSize = {};
  43. } m_main; ///< Main noisy pass.
  44. class
  45. {
  46. public:
  47. ShaderProgramResourcePtr m_prog;
  48. ShaderProgramPtr m_grProg;
  49. Array<U32, 2> m_workgroupSize = {};
  50. } m_blur; ///< Box blur.
  51. class
  52. {
  53. public:
  54. Array<RenderTargetHandle, 2> m_rts;
  55. const RenderingContext* m_ctx = nullptr;
  56. } m_runCtx; ///< Runtime context.
  57. Array<RenderTargetDescription, 2> m_rtDescrs;
  58. FramebufferDescription m_fbDescr;
  59. ANKI_USE_RESULT Error initMain(const ConfigSet& set);
  60. ANKI_USE_RESULT Error initBlur(const ConfigSet& set);
  61. void runMain(const RenderingContext& ctx, RenderPassWorkContext& rgraphCtx);
  62. void runBlur(RenderPassWorkContext& rgraphCtx);
  63. };
  64. /// @}
  65. } // end namespace anki