SuperTuxKart
Loading...
Searching...
No Matches
shader_based_renderer.hpp
1// SuperTuxKart - a fun racing game with go-kart
2// Copyright (C) 2015 SuperTuxKart-Team
3//
4// This program is free software; you can redistribute it and/or
5// modify it under the terms of the GNU General Public License
6// as published by the Free Software Foundation; either version 3
7// of the License, or (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18#ifndef HEADER_SHADER_BASED_RENDERER_HPP
19#define HEADER_SHADER_BASED_RENDERER_HPP
20
21#ifndef SERVER_ONLY
22
23#include "graphics/abstract_renderer.hpp"
24#include "graphics/draw_calls.hpp"
25#include "graphics/lighting_passes.hpp"
26#include "graphics/shadow_matrices.hpp"
27#include "utils/cpp2011.hpp"
28#include <map>
29#include <string>
30
31class AbstractGeometryPasses;
32class Camera;
33class GL3RenderTarget;
34class RenderTarget;
35class RTT;
36class Skybox;
38class PostProcessing;
39
40namespace irr
41{
42 namespace video
43 {
44 class IImage;
45 }
46}
47
49{
50private:
51 bool m_dump_rtt;
52 RTT *m_rtts;
53 Skybox *m_skybox;
54 SphericalHarmonics *m_spherical_harmonics;
55 DrawCalls m_draw_calls;
56 LightingPasses m_lighting_passes;
57 ShadowMatrices m_shadow_matrices;
58 std::unique_ptr<PostProcessing> m_post_processing;
59
60 void prepareForwardRenderer();
61
62 void uploadLightingData() const;
63
64 void computeMatrixesAndCameras(scene::ICameraSceneNode * const camnode,
65 unsigned int width, unsigned int height);
66
67 void resetShadowCamNodes(){m_shadow_matrices.resetShadowCamNodes();}
68
69 void renderSkybox(const scene::ICameraSceneNode *camera) const;
70
71
72 void prepareDrawCalls(scene::ICameraSceneNode *camnode);
73
74 void renderSSAO() const;
75
76 void renderGlow() const;
77
78 void renderScene(irr::scene::ICameraSceneNode * const camnode,
79 float dt, bool hasShadows, bool forceRTT);
80 void renderSceneDeferred(irr::scene::ICameraSceneNode * const camnode,
81 float dt, bool hasShadows, bool forceRTT);
82
83 void debugPhysics();
84 void renderPostProcessing(Camera * const camera, bool first_cam);
85 void preloadShaderFiles();
86 void renderShadows();
87
88public:
91
92 void onLoadWorld() OVERRIDE;
93 void onUnloadWorld() OVERRIDE;
94
95 void resetPostProcessing() OVERRIDE;
96 void giveBoost(unsigned int cam_index) OVERRIDE;
97
98 void addSkyBox(const std::vector<irr::video::IImage*> &texture,
99 const std::vector<irr::video::IImage*> &spherical_harmonics_textures);
100 void removeSkyBox() OVERRIDE;
101 const SHCoefficients* getSHCoefficients() const OVERRIDE;
102 GLuint getRenderTargetTexture(TypeRTT which) const OVERRIDE;
103 GLuint getDepthStencilTexture() const OVERRIDE;
104
105 void setAmbientLight(const irr::video::SColorf &light,
106 bool force_SH_computation = true) OVERRIDE;
107
108 void addSunLight(const irr::core::vector3df &pos) OVERRIDE;
109
110 void render(float dt, bool is_loading=false) OVERRIDE;
111
112 std::unique_ptr<RenderTarget> createRenderTarget(const irr::core::dimension2du &dimension,
113 const std::string &name) OVERRIDE;
114
115 void renderToTexture(GL3RenderTarget *render_target,
116 irr::scene::ICameraSceneNode* camera,
117 float dt);
118
119 void setRTT(RTT* rtts);
120
121 RTT* getRTTs() { return m_rtts; }
122 ShadowMatrices* getShadowMatrices() { return &m_shadow_matrices; }
123 PostProcessing* getPostProcessing() { return m_post_processing.get(); }
124 void dumpRTT() { m_dump_rtt = true; }
125 void createPostProcessing() OVERRIDE;
126
127};
128
129#endif // !SERVER_ONLY
130#endif // HEADER_SHADER_BASED_RENDERER_HPP
Virtual base class for the renderer.
Definition: abstract_renderer.hpp:60
This is the base class for all cameras.
Definition: camera.hpp:49
Definition: draw_calls.hpp:42
Definition: render_target.hpp:81
Definition: lighting_passes.hpp:43
Handles post processing, eg motion blur.
Definition: post_processing.hpp:42
Definition: rtts.hpp:101
Definition: render_target.hpp:42
Definition: shader_based_renderer.hpp:49
void uploadLightingData() const
Upload lighting info to the dedicated uniform buffer.
Definition: shader_based_renderer.cpp:78
std::unique_ptr< RenderTarget > createRenderTarget(const irr::core::dimension2du &dimension, const std::string &name) OVERRIDE
Create a RenderTarget (for rendering to a texture)
Definition: shader_based_renderer.cpp:834
Definition: shadow_matrices.hpp:40
Definition: skybox.hpp:38
Definition: spherical_harmonics.hpp:41
Definition: spherical_harmonics.hpp:33