Radium Engine  1.5.0
ForwardRenderer.hpp
1 #pragma once
2 
3 #include <Engine/Rendering/Renderer.hpp>
4 
5 namespace globjects {
6 class Framebuffer;
7 }
8 
9 namespace Ra {
10 namespace Engine {
11 namespace Data {
12 class Texture;
13 }
14 namespace Rendering {
15 
23 class RA_ENGINE_API ForwardRenderer : public Renderer
24 {
25  public:
27  ~ForwardRenderer() override;
28 
29  std::string getRendererName() const override { return "Forward Renderer"; }
30  bool buildRenderTechnique( RenderObject* ro ) const override;
31 
32  protected:
33  void initializeInternal() override;
34  void resizeInternal() override;
35 
36  void updateStepInternal( const Data::ViewingParameters& renderData ) override;
37 
38  void postProcessInternal( const Data::ViewingParameters& renderData ) override;
39  void renderInternal( const Data::ViewingParameters& renderData ) override;
40  void debugInternal( const Data::ViewingParameters& renderData ) override;
41  void uiInternal( const Data::ViewingParameters& renderData ) override;
42 
43  private:
44  void initShaders();
45  void initBuffers();
46 
47  void updateShadowMaps();
48 
49  protected:
53  virtual void renderBackground( const Data::ViewingParameters& ) {}
54 
55  enum RendererTextures {
56  RendererTextures_Depth = 0,
57  RendererTextures_HDR,
58  RendererTextures_Normal,
59  RendererTextures_Diffuse,
60  RendererTextures_Specular,
61  RendererTextures_OITAccum,
62  RendererTextures_OITRevealage,
63  RendererTextures_Volume,
64  RendererTexture_Count
65  };
66 
67  // Default renderer logic here, no need to be accessed by overriding renderers.
68  std::unique_ptr<globjects::Framebuffer> m_fbo;
69  std::unique_ptr<globjects::Framebuffer> m_postprocessFbo;
70  std::unique_ptr<globjects::Framebuffer> m_oitFbo;
71  std::unique_ptr<globjects::Framebuffer> m_uiXrayFbo;
72  std::unique_ptr<globjects::Framebuffer> m_volumeFbo;
73 
74  std::vector<RenderObjectPtr> m_transparentRenderObjects;
75  size_t m_fancyTransparentCount { 0 };
76 
77  std::vector<RenderObjectPtr> m_volumetricRenderObjects;
78  size_t m_fancyVolumetricCount { 0 };
79 
80  size_t m_pingPongSize { 0 };
81 
82  std::array<std::unique_ptr<Data::Texture>, RendererTexture_Count> m_textures;
83 
84  static const size_t ShadowMapSize { 1024 };
85  std::vector<std::shared_ptr<Data::Texture>> m_shadowMaps;
86  std::vector<Core::Matrix4> m_lightMatrices;
87 
88  using WireMap = std::map<RenderObject*, std::shared_ptr<Data::Displayable>>;
89  WireMap m_wireframes;
90 };
91 
92 } // namespace Rendering
93 } // namespace Engine
94 } // namespace Ra
virtual void renderBackground(const Data::ViewingParameters &)
Draw the picture background. This method allows custom renderers to draw objects on the background....
std::string getRendererName() const override
Get the name of the renderer, e.g to be displayed in the UI.
Definition: Cage.cpp:3
the set of viewing parameters extracted from the camera and given to the renderer