Line data Source code
1 : /* Copyright (C) 2023 Wildfire Games.
2 : * This file is part of 0 A.D.
3 : *
4 : * 0 A.D. is free software: you can redistribute it and/or modify
5 : * it under the terms of the GNU General Public License as published by
6 : * the Free Software Foundation, either version 2 of the License, or
7 : * (at your option) any later version.
8 : *
9 : * 0 A.D. 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 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 : */
17 :
18 : #ifndef INCLUDED_SILHOUETTERENDERER
19 : #define INCLUDED_SILHOUETTERENDERER
20 :
21 : #include "graphics/Overlay.h"
22 : #include "graphics/ShaderTechniquePtr.h"
23 : #include "maths/BoundingBoxAligned.h"
24 : #include "renderer/backend/IDeviceCommandContext.h"
25 : #include "renderer/backend/IShaderProgram.h"
26 :
27 : class CCamera;
28 : class CModel;
29 : class CPatch;
30 : class SceneCollector;
31 :
32 6 : class SilhouetteRenderer
33 : {
34 : public:
35 : SilhouetteRenderer();
36 :
37 : void AddOccluder(CPatch* patch);
38 : void AddOccluder(CModel* model);
39 : void AddCaster(CModel* model);
40 :
41 : void ComputeSubmissions(const CCamera& camera);
42 : void RenderSubmitOverlays(SceneCollector& collector);
43 : void RenderSubmitOccluders(SceneCollector& collector);
44 : void RenderSubmitCasters(SceneCollector& collector);
45 :
46 : void RenderDebugBounds(
47 : Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
48 : void RenderDebugOverlays(
49 : Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
50 :
51 : void EndFrame();
52 :
53 : private:
54 : bool m_DebugEnabled;
55 :
56 : std::vector<CPatch*> m_SubmittedPatchOccluders;
57 : std::vector<CModel*> m_SubmittedModelOccluders;
58 : std::vector<CModel*> m_SubmittedModelCasters;
59 :
60 : std::vector<CPatch*> m_VisiblePatchOccluders;
61 : std::vector<CModel*> m_VisibleModelOccluders;
62 : std::vector<CModel*> m_VisibleModelCasters;
63 :
64 0 : struct DebugBounds
65 : {
66 : CColor color;
67 : CBoundingBoxAligned bounds;
68 : };
69 :
70 0 : struct DebugRect
71 : {
72 : CColor color;
73 : float x0, y0, x1, y1;
74 : };
75 :
76 : std::vector<DebugBounds> m_DebugBounds;
77 : std::vector<DebugRect> m_DebugRects;
78 :
79 : std::vector<SOverlaySphere> m_DebugSpheres;
80 :
81 : CShaderTechniquePtr m_ShaderTech;
82 : Renderer::Backend::IVertexInputLayout* m_VertexInputLayout = nullptr;
83 : };
84 :
85 : #endif // INCLUDED_SILHOUETTERENDERER
|