MotionVectors.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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/Gr.h>
  7. #include <AnKi/Renderer/RendererObject.h>
  8. namespace anki
  9. {
  10. /// @addtogroup renderer
  11. /// @{
  12. /// Motion vector calculation.
  13. class MotionVectors : public RendererObject
  14. {
  15. public:
  16. MotionVectors(Renderer* renderer)
  17. : RendererObject(renderer)
  18. {
  19. registerDebugRenderTarget("MotionVectors");
  20. registerDebugRenderTarget("MotionVectorsRejection");
  21. }
  22. ~MotionVectors();
  23. ANKI_USE_RESULT Error init(const ConfigSet& config);
  24. void populateRenderGraph(RenderingContext& ctx);
  25. RenderTargetHandle getMotionVectorsRt() const
  26. {
  27. return m_runCtx.m_motionVectorsRtHandle;
  28. }
  29. RenderTargetHandle getRejectionFactorRt() const
  30. {
  31. return m_runCtx.m_rejectionFactorRtHandle;
  32. }
  33. void getDebugRenderTarget(CString rtName, RenderTargetHandle& handle,
  34. ShaderProgramPtr& optionalShaderProgram) const override
  35. {
  36. if(rtName == "MotionVectors")
  37. {
  38. handle = m_runCtx.m_motionVectorsRtHandle;
  39. }
  40. else
  41. {
  42. ANKI_ASSERT(rtName == "MotionVectorsRejection");
  43. handle = m_runCtx.m_rejectionFactorRtHandle;
  44. }
  45. }
  46. private:
  47. ShaderProgramResourcePtr m_prog;
  48. ShaderProgramPtr m_grProg;
  49. RenderTargetDescription m_motionVectorsRtDescr;
  50. RenderTargetDescription m_rejectionFactorRtDescr;
  51. class
  52. {
  53. public:
  54. RenderingContext* m_ctx = nullptr;
  55. RenderTargetHandle m_motionVectorsRtHandle;
  56. RenderTargetHandle m_rejectionFactorRtHandle;
  57. } m_runCtx;
  58. void run(RenderPassWorkContext& rgraphCtx);
  59. };
  60. /// @}
  61. } // end namespace anki