-
Notifications
You must be signed in to change notification settings - Fork 47
/
LightingModeRenderer.h
82 lines (60 loc) · 2.44 KB
/
LightingModeRenderer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#pragma once
#include "irender.h"
#include "irenderview.h"
#include "SceneRenderer.h"
#include "igeometrystore.h"
#include "FrameBuffer.h"
#include "render/Rectangle.h"
#include "glprogram/ShadowMapProgram.h"
namespace render
{
class GLProgramFactory;
class LightInteractions;
class LightingModeRenderResult;
class LightingModeRenderer final :
public SceneRenderer
{
private:
GLProgramFactory& _programFactory;
IGeometryStore& _geometryStore;
// The set of registered render lights
const std::set<RendererLightPtr>& _lights;
// The set of registered render entities
const std::set<IRenderEntityPtr>& _entities;
std::vector<IGeometryStore::Slot> _untransformedObjectsWithoutAlphaTest;
FrameBuffer::Ptr _shadowMapFbo;
std::vector<Rectangle> _shadowMapAtlas;
ShadowMapProgram* _shadowMapProgram;
constexpr static std::size_t MaxShadowCastingLights = 6;
// Data that is valid during a single render pass only
std::vector<LightInteractions> _interactingLights;
std::shared_ptr<LightingModeRenderResult> _result;
std::vector<LightInteractions*> _nearestShadowLights;
public:
LightingModeRenderer(GLProgramFactory& programFactory,
IGeometryStore& store,
const std::set<RendererLightPtr>& lights,
const std::set<IRenderEntityPtr>& entities) :
_programFactory(programFactory),
_geometryStore(store),
_lights(lights),
_entities(entities),
_shadowMapProgram(nullptr)
{
_untransformedObjectsWithoutAlphaTest.reserve(10000);
_nearestShadowLights.reserve(MaxShadowCastingLights);
}
IRenderResult::Ptr render(RenderStateFlags globalFlagsMask, const IRenderView& view, std::size_t time) override;
private:
void determineLightInteractions(const IRenderView& view);
void drawLightInteractions(OpenGLState& current, RenderStateFlags globalFlagsMask,
const IRenderView& view, std::size_t renderTime);
void drawDepthFillPass(OpenGLState& current, RenderStateFlags globalFlagsMask,
const IRenderView& view, std::size_t renderTime);
void drawNonInteractionPasses(OpenGLState& current, RenderStateFlags globalFlagsMask,
const IRenderView& view, std::size_t time);
void drawShadowMaps(OpenGLState& current, std::size_t renderTime);
void ensureShadowMapSetup();
void addToShadowLights(LightInteractions& light, const Vector3& viewer);
};
}