-
Notifications
You must be signed in to change notification settings - Fork 3
/
LightCombiner.cpp
82 lines (59 loc) · 2.87 KB
/
LightCombiner.cpp
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
#include "LightCombiner.h"
namespace Open7Days {
namespace Rendering {
void LightCombiner::PrepareLightCombiner() {
LightCombinerShader = Shader("Shaders/LightCombiner");
LightCombinerShader.Bind();
LightCombinerShader.SetUniform("FirstPassDiffuse", 0);
LightCombinerShader.SetUniform("FirstPassSpecular", 1);
LightCombinerShader.SetUniform("IndirectSpecular", 2);
LightCombinerShader.SetUniform("Normal", 3);
LightCombinerShader.SetUniform("Albedo", 4);
LightCombinerShader.SetUniform("Sky", 5);
LightCombinerShader.SetUniform("Depth", 6);
LightCombinerShader.SetUniform("WaterDepth", 7);
LightCombinerShader.SetUniform("WaterNormal", 8);
LightCombinerShader.SetUniform("WaterNormalMap", 9);
LightCombinerShader.UnBind();
}
void LightCombiner::CombineLighting(Window& Window, Camera& Camera, DeferredRenderer& Deferred, FirstPassLighting& First, IndirectSpecularLighting& IndirectSpecular, WaterRenderer & Water, ShadowMapper& Shadows,TextureCubeMap& Sky) {
LightCombinerShader.Bind();
LightCombinerShader.SetUniform("ViewMatrix", Camera.View);
LightCombinerShader.SetUniform("ProjectionMatrix", Camera.Project);
LightCombinerShader.SetUniform("InverseView", glm::inverse(Camera.View));
LightCombinerShader.SetUniform("InverseProject", glm::inverse(Camera.Project));
LightCombinerShader.SetUniform("CameraPosition", Camera.Position);
LightCombinerShader.SetUniform("Time", Window.GetTimeOpened());
LightCombinerShader.SetUniform("LightDirection", glm::normalize(Shadows.Orientation));
First.FirstPassLightingBuffer.BindImage(0, 0);
First.FirstPassLightingBuffer.BindImage(1, 1);
IndirectSpecular.IndirectSpecularBuffer.BindImage(2);
Deferred.DeferredUnwrappedBuffer.BindImage(1, 3);
Deferred.DeferredUnwrappedBuffer.BindImage(0, 4);
glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_2D_ARRAY, Water.SkyTexture);
Deferred.DeferredRawBuffer.BindDepthImage(6);
Water.WaterBuffer.BindDepthImage(7);
Water.WaterBuffer.BindImage(8);
glActiveTexture(GL_TEXTURE9);
glBindTexture(GL_TEXTURE_2D_ARRAY, Water.WaterNormalTexture);
DrawPostProcessQuad();
LightCombinerShader.UnBind();
}
void LightCombiner::ReloadLightCombiner() {
LightCombinerShader.Reload("Shaders/LightCombiner");
LightCombinerShader.Bind();
LightCombinerShader.SetUniform("FirstPassDiffuse", 0);
LightCombinerShader.SetUniform("FirstPassSpecular", 1);
LightCombinerShader.SetUniform("IndirectSpecular", 2);
LightCombinerShader.SetUniform("Normal", 3);
LightCombinerShader.SetUniform("Albedo", 4);
LightCombinerShader.SetUniform("Sky", 5);
LightCombinerShader.SetUniform("Depth", 6);
LightCombinerShader.SetUniform("WaterDepth", 7);
LightCombinerShader.SetUniform("WaterNormal", 8);
LightCombinerShader.SetUniform("WaterNormalMap", 9);
LightCombinerShader.UnBind();
}
}
}