Commit 97259a3e authored by Dario Seyb's avatar Dario Seyb

made quality settings actually do something

parent baebca68
This image diff could not be displayed because it is too large. You can view the blob instead.
This image diff could not be displayed because it is too large. You can view the blob instead.
"build\src\game\RelWithDebInfo\game.exe" "config/settings.json"
"build\src\game\MinSizeRel\game.exe" "config/settings.json"
......@@ -4,7 +4,7 @@
#include <ACGL/Math/Math.hh>
enum class QualitySetting {
Low,
Low = 0,
Medium,
High
};
......
......@@ -43,9 +43,16 @@ struct RenderPass {
class RendererSystem : public System {
private:
const float SHADOW_MAP_SCALE_FACTOR[3] = { 0.25f, 0.5f, 1.0f };
const ScreenSpaceSize G_BUFFER_SIZE[3] = { ScreenSpaceSize::HALF, ScreenSpaceSize::HALF, ScreenSpaceSize::FULL };
SettingsSystem *m_settings;
EventSystem *m_events;
WindowSystem *m_window;
QualitySetting m_quality;
std::vector<RenderPass> m_passes;
std::unordered_map<StringHash, uint32_t> m_passIds;
......@@ -100,6 +107,8 @@ private:
void render(RenderPass& pass, double interp, double totalTime);
public:
double m_lastGBufferRenderTime;
double m_lastGBufferRenderSetupTime;
......
......@@ -7,6 +7,7 @@
#include <engine/events/MouseEvent.hpp>
#include <engine/core/SimulateEvent.hpp>
#include <engine/core/WindowSystem.hpp>
#include <engine/core/SettingsSystem.hpp>
#include <engine/graphics/RendererSystem.hpp>
#include <engine/audio/AudioSystem.hpp>
#include <engine/ui/UISystem.hpp>
......@@ -21,6 +22,7 @@
class PlayerSystem : public System {
private:
SettingsSystem* m_settings;
EventSystem* m_events;
SceneGraphSystem *m_scene;
RendererSystem* m_renderer;
......
......@@ -36,9 +36,12 @@ float random(float start, float end) {
}
bool RendererSystem::startup() {
RESOLVE_DEPENDENCY(m_settings);
RESOLVE_DEPENDENCY(m_events);
RESOLVE_DEPENDENCY(m_window);
m_quality = m_settings->getQualitySetting();
m_events->subscribe<DrawEvent>(
[this](const DrawEvent &e) { frame(e.interp, e.totalTime); });
......@@ -50,11 +53,13 @@ bool RendererSystem::startup() {
auto windowSize = m_window->getSize();
glViewport(0, 0, windowSize.x, windowSize.y);
m_colorBuffer = createScreenspaceTexture(ScreenSpaceSize::FULL, GL_RGBA16F);
m_emissiveBuffer = createScreenspaceTexture(ScreenSpaceSize::FULL, GL_RGBA16F);
m_normalMotionBuffer = createScreenspaceTexture(ScreenSpaceSize::FULL, GL_RGBA16F);
m_depthBuffer = createScreenspaceTexture(ScreenSpaceSize::FULL, GL_DEPTH24_STENCIL8);
m_specularBuffer = createScreenspaceTexture(ScreenSpaceSize::FULL, GL_RGBA16F);
auto currentGBufferSize = G_BUFFER_SIZE[(int)m_quality];
m_colorBuffer = createScreenspaceTexture(currentGBufferSize, GL_RGBA16F);
m_emissiveBuffer = createScreenspaceTexture(currentGBufferSize, GL_RGBA16F);
m_normalMotionBuffer = createScreenspaceTexture(currentGBufferSize, GL_RGBA16F);
m_depthBuffer = createScreenspaceTexture(currentGBufferSize, GL_DEPTH24_STENCIL8);
m_specularBuffer = createScreenspaceTexture(currentGBufferSize, GL_RGBA16F);
m_gBufferObject = SharedFrameBufferObject(new FrameBufferObject());
m_gBufferObject->attachColorTexture("oColor", m_colorBuffer);
......@@ -65,11 +70,11 @@ bool RendererSystem::startup() {
m_gBufferObject->validate(); // always a good idea
m_primaryCompositingBuffer = SharedFrameBufferObject(new FrameBufferObject());
m_primaryCompositingBuffer->attachColorTexture("oColor", createScreenspaceTexture(ScreenSpaceSize::FULL, GL_RGBA32F));
m_primaryCompositingBuffer->attachColorTexture("oColor", createScreenspaceTexture(currentGBufferSize, GL_RGBA32F));
m_primaryCompositingBuffer->validate();
m_secondaryCompositingBuffer = SharedFrameBufferObject(new FrameBufferObject());
m_secondaryCompositingBuffer->attachColorTexture("oColor", createScreenspaceTexture(ScreenSpaceSize::FULL, GL_RGBA32F));
m_secondaryCompositingBuffer->attachColorTexture("oColor", createScreenspaceTexture(currentGBufferSize, GL_RGBA32F));
m_secondaryCompositingBuffer->validate();
m_ssaoTarget = SharedFrameBufferObject(new FrameBufferObject());
......@@ -78,7 +83,7 @@ bool RendererSystem::startup() {
m_postfxTargetBuffer = SharedFrameBufferObject(new FrameBufferObject());
m_postfxTargetBuffer->attachColorTexture("oColor", createScreenspaceTexture(ScreenSpaceSize::FULL, GL_RGBA32F));
m_postfxTargetBuffer->attachColorTexture("oColor", createScreenspaceTexture(currentGBufferSize, GL_RGBA32F));
m_postfxTargetBuffer->validate();
// Create two VABs to store transform feedback vertices. Size is a bit tricky because nobody knows how much
......@@ -157,9 +162,10 @@ bool RendererSystem::startup() {
m_dummyShadowMap->setCompareMode(GL_COMPARE_REF_TO_TEXTURE);
m_dummyShadowMap->setCompareFunc(GL_LEQUAL);
for (int i = 0; i < SHADOW_MAP_COUNT; i++) {
auto shadowFbo = SharedFrameBufferObject(new FrameBufferObject);
auto shadowMap = SharedTexture2D(new Texture2D(SHADOW_MAP_RESOLUTION, GL_DEPTH24_STENCIL8));
auto shadowMap = SharedTexture2D(new Texture2D(SHADOW_MAP_RESOLUTION * SHADOW_MAP_SCALE_FACTOR[(int)m_quality], GL_DEPTH24_STENCIL8));
shadowMap->setMinFilter(GL_LINEAR);
shadowMap->setMagFilter(GL_LINEAR);
......
......@@ -259,6 +259,7 @@ float fbm_3d(glm::vec3 p, int fOct, float freq, float weight = 0.5) {
bool PlayerSystem::startup() {
RESOLVE_DEPENDENCY(m_settings)
RESOLVE_DEPENDENCY(m_events);
RESOLVE_DEPENDENCY(m_scene);
RESOLVE_DEPENDENCY(m_renderer);
......@@ -292,10 +293,15 @@ bool PlayerSystem::startup() {
mmCam->mode = ProjectionMode::Orthographic;
camTransform->position = glm::vec3(0, 0, 0);
auto quality = m_settings->getQualitySetting();
m_renderer->addRenderPass(m_skyboxCamera, "Skybox"_sh);
m_renderer->addRenderPass(m_mainCamera, "Main"_sh);
m_renderer->addRenderPass(m_cockpitCamera, "Cockpit"_sh);
auto defaultScreenSpaceSize = quality == QualitySetting::High ? ScreenSpaceSize::FULL :
quality == QualitySetting::Medium ? ScreenSpaceSize::HALF :
ScreenSpaceSize::HALF;
m_renderer->addRenderPass(m_skyboxCamera, "Skybox"_sh, defaultScreenSpaceSize);
m_renderer->addRenderPass(m_mainCamera, "Main"_sh, defaultScreenSpaceSize);
m_renderer->addRenderPass(m_cockpitCamera, "Cockpit"_sh, defaultScreenSpaceSize);
m_renderer->addRenderPass(m_minimapCamera, "Minimap"_sh, ScreenSpaceSize::QUARTER);
m_renderer->setRenderPassOnlyTexture("Minimap"_sh, true);
......
......@@ -385,6 +385,7 @@ void AtmosphereTestScene::switchToMainScene() {
}
void AtmosphereTestScene::loadMainSceneResources() {
auto qualitySetting = m_settings->getQualitySetting();
{
auto vaoSkybox = VertexArrayObjectCreator("skybox.obj").create();
auto skyboxShader = ShaderProgramFileManager::the()->get(
......@@ -392,7 +393,10 @@ void AtmosphereTestScene::loadMainSceneResources() {
.attributeLocations(vaoSkybox->getAttributeLocations())
.fragmentDataLocations(m_renderer->getGBufferLocations()));
auto skyboxTexture = Texture2DFileManager::the()->get(Texture2DCreator("skybox.png"));
auto skyboxTexName = qualitySetting == QualitySetting::High ? "skybox_large.png" : qualitySetting == QualitySetting::Medium ? "skybox_medium.png" : "skybox.png";
auto skyboxTexture = Texture2DFileManager::the()->get(Texture2DCreator(skyboxTexName));
skyboxGeometry = {vaoSkybox};
skyboxMaterial = {glm::vec4{1, 1, 1, 1},
......
......@@ -30,18 +30,20 @@ static std::unique_ptr<Scene> createScene(std::string sceneType, Context* contex
int main(int argc, char *argv[]) {
std::string configFile = "config/settings.json";
#if _DEBUG
if (argc != 2) {
std::cout << "Usage: <config file>" << std::endl;
return -1;
}
#endif
// Set up the systems we want to use.
// They depends on each other so we need to add them to the context in the right order
// This also makes sure that dependencies are initialized before things that depend on them
// If you try to initialize a system before it's dependencies you'll get an error message in the console
Context context;
SettingsSystem settings(&context, "data/", "textures/", "geometry/", "shader/", "sound/", argv[1]);
SettingsSystem settings(&context, "data/", "textures/", "geometry/", "shader/", "sound/", configFile);
WindowSystem window(&context, 1280, 720, false);
EventSystem events(&context);
RendererSystem renderer(&context);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment