MotionVectors.h 1.6 KB

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