|
@@ -18,7 +18,7 @@ void Engine::renderTick(float lag, const Game& game) {
|
|
camera.update(lag);
|
|
camera.update(lag);
|
|
updateWorldProjection();
|
|
updateWorldProjection();
|
|
updateWorldView();
|
|
updateWorldView();
|
|
-
|
|
+
|
|
renderShadow(lag, game);
|
|
renderShadow(lag, game);
|
|
renderWorld(lag, game);
|
|
renderWorld(lag, game);
|
|
if(renderSettings.useSSAO) {
|
|
if(renderSettings.useSSAO) {
|
|
@@ -32,14 +32,9 @@ void Engine::renderShadow(float lag, const Game& game) {
|
|
fb.shadow.bind();
|
|
fb.shadow.bind();
|
|
glEnable(GL_DEPTH_TEST);
|
|
glEnable(GL_DEPTH_TEST);
|
|
shaders.shadow.use();
|
|
shaders.shadow.use();
|
|
- worldShadowProjView = worldShadowProj;
|
|
+ worldShadowProjView.set(worldShadowProj).mul(worldShadowView);
|
|
- worldShadowProjView.mul(worldShadowView);
|
|
|
|
shaders.shadow.setMatrix("projView", worldShadowProjView.getValues());
|
|
shaders.shadow.setMatrix("projView", worldShadowProjView.getValues());
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
game.renderWorld(lag, model, shaders.shadow);
|
|
game.renderWorld(lag, model, shaders.shadow);
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void Engine::renderWorld(float lag, const Game& game) {
|
|
void Engine::renderWorld(float lag, const Game& game) {
|
|
@@ -48,9 +43,7 @@ void Engine::renderWorld(float lag, const Game& game) {
|
|
shaders.world.use();
|
|
shaders.world.use();
|
|
|
|
|
|
Matrix rWorldShadowProjView;
|
|
Matrix rWorldShadowProjView;
|
|
- rWorldShadowProjView.translate(0.5f, 0.5f, 0.5f);
|
|
+ rWorldShadowProjView.translate(0.5f, 0.5f, 0.5f).scale(0.5f).mul(worldShadowProjView);
|
|
- rWorldShadowProjView.scale(0.5f, 0.5f, 0.5f);
|
|
|
|
- rWorldShadowProjView.mul(worldShadowProjView);
|
|
|
|
|
|
|
|
shaders.world.setMatrix("projViewShadow", rWorldShadowProjView.getValues());
|
|
shaders.world.setMatrix("projViewShadow", rWorldShadowProjView.getValues());
|
|
shaders.world.setMatrix("proj", worldProj.getValues());
|
|
shaders.world.setMatrix("proj", worldProj.getValues());
|
|
@@ -67,9 +60,7 @@ void Engine::renderSSAO() {
|
|
shaders.ssao.use();
|
|
shaders.ssao.use();
|
|
|
|
|
|
Matrix rProj;
|
|
Matrix rProj;
|
|
- rProj.translate(0.5f, 0.5f, 0.5f);
|
|
+ rProj.translate(0.5f, 0.5f, 0.5f).scale(0.5f).mul(worldProj);
|
|
- rProj.scale(0.5f, 0.5f, 0.5f);
|
|
|
|
- rProj.mul(worldProj);
|
|
|
|
|
|
|
|
shaders.ssao.setMatrix("proj", rProj.getValues());
|
|
shaders.ssao.setMatrix("proj", rProj.getValues());
|
|
shaders.ssao.setInt("width", size.width);
|
|
shaders.ssao.setInt("width", size.width);
|
|
@@ -81,7 +72,7 @@ void Engine::renderSSAO() {
|
|
ssaoNoise.bind(4);
|
|
ssaoNoise.bind(4);
|
|
fb.ssao.bind();
|
|
fb.ssao.bind();
|
|
rectangle.draw();
|
|
rectangle.draw();
|
|
-
|
|
+
|
|
shaders.ssaoBlur.use();
|
|
shaders.ssaoBlur.use();
|
|
fb.ssao.bindRedTexture(0);
|
|
fb.ssao.bindRedTexture(0);
|
|
fb.ssaoBlur.bind();
|
|
fb.ssaoBlur.bind();
|
|
@@ -106,8 +97,7 @@ void Engine::renderTextOverlay(float lag, const Game& game) {
|
|
|
|
|
|
Matrix m;
|
|
Matrix m;
|
|
shaders.text.setMatrix("proj", m.getValues());
|
|
shaders.text.setMatrix("proj", m.getValues());
|
|
- m.translate(-1.0f, 1.0f, 0.0f);
|
|
+ m.translate(-1.0f, 1.0f, 0.0f).scale(2.0f / size.width, -2.0f / size.height, 1.0f);
|
|
- m.scale(2.0f / size.width, -2.0f / size.height, 1.0f);
|
|
|
|
shaders.text.setMatrix("view", m.getValues());
|
|
shaders.text.setMatrix("view", m.getValues());
|
|
model.clear();
|
|
model.clear();
|
|
model.get().scale(2.0f, 2.0f, 2.0f);
|
|
model.get().scale(2.0f, 2.0f, 2.0f);
|
|
@@ -141,39 +131,31 @@ void Engine::updateWorldProjection() {
|
|
farCenter.addMul(camera.getBack(), -closeFarClip);
|
|
farCenter.addMul(camera.getBack(), -closeFarClip);
|
|
|
|
|
|
Vector farTopLeft = farCenter;
|
|
Vector farTopLeft = farCenter;
|
|
- farTopLeft.addMul(camera.getRight(), -farWidth);
|
|
+ farTopLeft.addMul(camera.getRight(), -farWidth).addMul(camera.getUp(), farHigh);
|
|
- farTopLeft.addMul(camera.getUp(), farHigh);
|
|
|
|
|
|
|
|
Vector farBottomLeft = farCenter;
|
|
Vector farBottomLeft = farCenter;
|
|
- farBottomLeft.addMul(camera.getRight(), -farWidth);
|
|
+ farBottomLeft.addMul(camera.getRight(), -farWidth).addMul(camera.getUp(), -farHigh);
|
|
- farBottomLeft.addMul(camera.getUp(), -farHigh);
|
|
|
|
|
|
|
|
Vector farTopRight = farCenter;
|
|
Vector farTopRight = farCenter;
|
|
- farTopRight.addMul(camera.getRight(), farWidth);
|
|
+ farTopRight.addMul(camera.getRight(), farWidth).addMul(camera.getUp(), farHigh);
|
|
- farTopRight.addMul(camera.getUp(), farHigh);
|
|
|
|
|
|
|
|
Vector farBottomRight = farCenter;
|
|
Vector farBottomRight = farCenter;
|
|
- farBottomRight.addMul(camera.getRight(), farWidth);
|
|
+ farBottomRight.addMul(camera.getRight(), farWidth).addMul(camera.getUp(), -farHigh);
|
|
- farBottomRight.addMul(camera.getUp(), -farHigh);
|
|
|
|
|
|
|
|
Vector nearCenter = camera.getPosition();
|
|
Vector nearCenter = camera.getPosition();
|
|
nearCenter.addMul(camera.getBack(), -nearClip);
|
|
nearCenter.addMul(camera.getBack(), -nearClip);
|
|
|
|
|
|
Vector nearTopLeft = nearCenter;
|
|
Vector nearTopLeft = nearCenter;
|
|
- nearTopLeft.addMul(camera.getRight(), -nearWidth);
|
|
+ nearTopLeft.addMul(camera.getRight(), -nearWidth).addMul(camera.getUp(), nearHigh);
|
|
- nearTopLeft.addMul(camera.getUp(), nearHigh);
|
|
|
|
|
|
|
|
Vector nearBottomLeft = nearCenter;
|
|
Vector nearBottomLeft = nearCenter;
|
|
- nearBottomLeft.addMul(camera.getRight(), -nearWidth);
|
|
+ nearBottomLeft.addMul(camera.getRight(), -nearWidth).addMul(camera.getUp(), -nearHigh);
|
|
- nearBottomLeft.addMul(camera.getUp(), -nearHigh);
|
|
|
|
|
|
|
|
Vector nearTopRight = nearCenter;
|
|
Vector nearTopRight = nearCenter;
|
|
- nearTopRight.addMul(camera.getRight(), nearWidth);
|
|
+ nearTopRight.addMul(camera.getRight(), nearWidth).addMul(camera.getUp(), nearHigh);
|
|
- nearTopRight.addMul(camera.getUp(), nearHigh);
|
|
|
|
|
|
|
|
Vector nearBottomRight = nearCenter;
|
|
Vector nearBottomRight = nearCenter;
|
|
- nearBottomRight.addMul(camera.getRight(), nearWidth);
|
|
+ nearBottomRight.addMul(camera.getRight(), nearWidth).addMul(camera.getUp(), -nearHigh);
|
|
- nearBottomRight.addMul(camera.getUp(), -nearHigh);
|
|
|
|
|
|
|
|
Vector light(-0.280166, -0.573576, -0.769751);
|
|
Vector light(-0.280166, -0.573576, -0.769751);
|
|
Vector lightLeft = light;
|
|
Vector lightLeft = light;
|
|
@@ -181,7 +163,6 @@ void Engine::updateWorldProjection() {
|
|
Vector lightUp = lightLeft;
|
|
Vector lightUp = lightLeft;
|
|
lightUp.cross(light);
|
|
lightUp.cross(light);
|
|
|
|
|
|
-
|
|
|
|
Plane plane;
|
|
Plane plane;
|
|
plane.set(Vector(), light, lightUp);
|
|
plane.set(Vector(), light, lightUp);
|
|
float f[8];
|
|
float f[8];
|
|
@@ -204,7 +185,6 @@ void Engine::updateWorldProjection() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
float lightWidth = max - min;
|
|
float lightWidth = max - min;
|
|
-
|
|
|
|
|
|
|
|
plane.set(Vector(), light, lightLeft);
|
|
plane.set(Vector(), light, lightLeft);
|
|
f[0] = plane.getSignedDistance(farTopLeft);
|
|
f[0] = plane.getSignedDistance(farTopLeft);
|
|
@@ -227,7 +207,6 @@ void Engine::updateWorldProjection() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
float lightHeight = max - min;
|
|
float lightHeight = max - min;
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
renderSettings.testOrthoCenter = nearCenter;
|
|
renderSettings.testOrthoCenter = nearCenter;
|