|
@@ -50,6 +50,7 @@ static float farClip = 1000.0f;
|
|
static InternGameClient client;
|
|
static InternGameClient client;
|
|
static Keys keys;
|
|
static Keys keys;
|
|
static MouseButtons mButtons;
|
|
static MouseButtons mButtons;
|
|
|
|
+static bool useSSAO = false;
|
|
|
|
|
|
struct Shaders
|
|
struct Shaders
|
|
{
|
|
{
|
|
@@ -124,27 +125,27 @@ struct Shaders
|
|
|
|
|
|
struct Framebuffers
|
|
struct Framebuffers
|
|
{
|
|
{
|
|
- Framebuffers(u32 w, u32 h) : worldBuffer(w, h, Framebuffer::POSITION |
|
|
+ Framebuffers(u32 w, u32 h) : world(w, h, Framebuffer::POSITION |
|
|
Framebuffer::NORMAL | Framebuffer::COLOR | Framebuffer::DEPTH24_STENCIL8),
|
|
Framebuffer::NORMAL | Framebuffer::COLOR | Framebuffer::DEPTH24_STENCIL8),
|
|
- ssaoBuffer(w, h, Framebuffer::RED), ssaoBlurBuffer(w, h, Framebuffer::RED)
|
|
+ ssao(w, h, Framebuffer::RED), ssaoBlur(w, h, Framebuffer::RED)
|
|
{
|
|
{
|
|
}
|
|
}
|
|
|
|
|
|
void resize(u32 w, u32 h) const
|
|
void resize(u32 w, u32 h) const
|
|
{
|
|
{
|
|
- worldBuffer.resize(w, h);
|
|
+ world.resize(w, h);
|
|
- ssaoBuffer.resize(w, h);
|
|
+ ssao.resize(w, h);
|
|
- ssaoBlurBuffer.resize(w, h);
|
|
+ ssaoBlur.resize(w, h);
|
|
}
|
|
}
|
|
|
|
|
|
bool isValid() const
|
|
bool isValid() const
|
|
{
|
|
{
|
|
- return worldBuffer.isValid() && ssaoBuffer.isValid() && ssaoBlurBuffer.isValid();
|
|
+ return world.isValid() && ssao.isValid() && ssaoBlur.isValid();
|
|
}
|
|
}
|
|
|
|
|
|
- Framebuffer worldBuffer;
|
|
+ Framebuffer world;
|
|
- Framebuffer ssaoBuffer;
|
|
+ Framebuffer ssao;
|
|
- Framebuffer ssaoBlurBuffer;
|
|
+ Framebuffer ssaoBlur;
|
|
};
|
|
};
|
|
|
|
|
|
struct InternGame
|
|
struct InternGame
|
|
@@ -267,12 +268,16 @@ static void tick(InternGame& game)
|
|
keys.tick();
|
|
keys.tick();
|
|
mButtons.tick();
|
|
mButtons.tick();
|
|
game.game.tick(keys, mButtons, game.cam);
|
|
game.game.tick(keys, mButtons, game.cam);
|
|
|
|
+ if(keys.test.getDownTime() == 1)
|
|
|
|
+ {
|
|
|
|
+ useSSAO = !useSSAO;
|
|
|
|
+ }
|
|
mButtons.postTick();
|
|
mButtons.postTick();
|
|
}
|
|
}
|
|
|
|
|
|
static void renderWorld(float lag, Shaders& shaders, InternGame& game, Framebuffers& fb)
|
|
static void renderWorld(float lag, Shaders& shaders, InternGame& game, Framebuffers& fb)
|
|
{
|
|
{
|
|
- fb.worldBuffer.bind();
|
|
+ fb.world.bind();
|
|
glEnable(GL_DEPTH_TEST);
|
|
glEnable(GL_DEPTH_TEST);
|
|
shaders.world.use();
|
|
shaders.world.use();
|
|
shaders.world.setMatrix("proj", shaders.worldProj);
|
|
shaders.world.setMatrix("proj", shaders.worldProj);
|
|
@@ -290,18 +295,18 @@ static void renderSSAO(Shaders& shaders, InternGame& game, Framebuffers& fb)
|
|
shaders.ssao.setMatrix("proj", shaders.worldProj);
|
|
shaders.ssao.setMatrix("proj", shaders.worldProj);
|
|
shaders.ssao.setInt("width", width);
|
|
shaders.ssao.setInt("width", width);
|
|
shaders.ssao.setInt("height", height);
|
|
shaders.ssao.setInt("height", height);
|
|
- fb.worldBuffer.bindPositionTexture(0);
|
|
+ fb.world.bindPositionTexture(0);
|
|
- fb.worldBuffer.bindNormalTexture(1);
|
|
+ fb.world.bindNormalTexture(1);
|
|
- fb.worldBuffer.bindColorTexture(2);
|
|
+ fb.world.bindColorTexture(2);
|
|
- fb.worldBuffer.bindDepthTexture(3);
|
|
+ fb.world.bindDepthTexture(3);
|
|
game.ssaoNoise.bind(4);
|
|
game.ssaoNoise.bind(4);
|
|
- fb.ssaoBuffer.bind();
|
|
+ fb.ssao.bind();
|
|
game.rectangle.draw();
|
|
game.rectangle.draw();
|
|
|
|
|
|
shaders.ssaoBlur.use();
|
|
shaders.ssaoBlur.use();
|
|
- fb.ssaoBuffer.bindRedTexture(0);
|
|
+ fb.ssao.bindRedTexture(0);
|
|
- fb.worldBuffer.bindColorTexture(1);
|
|
+ fb.world.bindColorTexture(1);
|
|
- fb.ssaoBlurBuffer.bind();
|
|
+ fb.ssaoBlur.bind();
|
|
game.rectangle.draw();
|
|
game.rectangle.draw();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -309,19 +314,14 @@ static void renderPostWorld(Shaders& shaders, InternGame& game, Framebuffers& fb
|
|
{
|
|
{
|
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
|
- fb.worldBuffer.bindColorTexture(0);
|
|
|
|
- fb.ssaoBlurBuffer.bindRedTexture(1);
|
|
|
|
shaders.postWorld.use();
|
|
shaders.postWorld.use();
|
|
-
|
|
+ fb.world.bindColorTexture(0);
|
|
- glDisable(GL_DEPTH_TEST);
|
|
+ fb.ssaoBlur.bindRedTexture(1);
|
|
- glEnable(GL_BLEND);
|
|
+ shaders.postWorld.setInt("useSSAO", useSSAO);
|
|
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
- glBlendEquation(GL_FUNC_ADD);
|
|
|
|
game.rectangle.draw();
|
|
game.rectangle.draw();
|
|
- glDisable(GL_BLEND);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+static void renderTextOverlay(float lag, Shaders& shaders, InternGame& game)
|
|
{
|
|
{
|
|
glDisable(GL_DEPTH_TEST);
|
|
glDisable(GL_DEPTH_TEST);
|
|
shaders.text.use();
|
|
shaders.text.use();
|
|
@@ -340,7 +340,7 @@ static void renderPostWorld(Shaders& shaders, InternGame& game, Framebuffers& fb
|
|
glBlendEquation(GL_FUNC_ADD);
|
|
glBlendEquation(GL_FUNC_ADD);
|
|
game.game.renderTextOverlay(lag, game.model, shaders.text, game.fontRenderer);
|
|
game.game.renderTextOverlay(lag, game.model, shaders.text, game.fontRenderer);
|
|
glDisable(GL_BLEND);
|
|
glDisable(GL_BLEND);
|
|
-}*/
|
|
+}
|
|
|
|
|
|
static void renderTick(float lag, Shaders& shaders, InternGame& game, Framebuffers& fb)
|
|
static void renderTick(float lag, Shaders& shaders, InternGame& game, Framebuffers& fb)
|
|
{
|
|
{
|
|
@@ -353,8 +353,12 @@ static void renderTick(float lag, Shaders& shaders, InternGame& game, Framebuffe
|
|
shaders.updateWorldView(lag, game.cam);
|
|
shaders.updateWorldView(lag, game.cam);
|
|
|
|
|
|
renderWorld(lag, shaders, game, fb);
|
|
renderWorld(lag, shaders, game, fb);
|
|
- renderSSAO(shaders, game, fb);
|
|
+ if(useSSAO)
|
|
|
|
+ {
|
|
|
|
+ renderSSAO(shaders, game, fb);
|
|
|
|
+ }
|
|
renderPostWorld(shaders, game, fb);
|
|
renderPostWorld(shaders, game, fb);
|
|
|
|
+ renderTextOverlay(lag, shaders, game);
|
|
}
|
|
}
|
|
|
|
|
|
static void loop()
|
|
static void loop()
|