From 52930c8539c32537d24cc271b82a10183604f3db Mon Sep 17 00:00:00 2001 From: Vsevolod Kremianskii Date: Mon, 15 Feb 2021 18:33:32 +0700 Subject: [PATCH] feat: Make shadow map resolution configurable --- src/program.cpp | 3 +++ src/render/types.h | 1 + src/scene/pipeline/world.cpp | 5 ++--- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/program.cpp b/src/program.cpp index f7ca8071..c2d0a42c 100644 --- a/src/program.cpp +++ b/src/program.cpp @@ -37,6 +37,7 @@ namespace reone { static const char kConfigFilename[] = "reone.cfg"; +static constexpr int kDefaultShadowResolution = 2048; static constexpr int kDefaultMusicVolume = 85; static constexpr int kDefaultVoiceVolume = 85; static constexpr int kDefaultSoundVolume = 85; @@ -69,6 +70,7 @@ void Program::initOptions() { ("width", po::value()->default_value(800), "window width") ("height", po::value()->default_value(600), "window height") ("fullscreen", po::value()->default_value(false), "enable fullscreen") + ("shadowres", po::value()->default_value(kDefaultShadowResolution), "shadow map resolution") ("musicvol", po::value()->default_value(kDefaultMusicVolume), "music volume in percents") ("voicevol", po::value()->default_value(kDefaultVoiceVolume), "voice volume in percents") ("soundvol", po::value()->default_value(kDefaultSoundVolume), "sound volume in percents") @@ -102,6 +104,7 @@ void Program::loadOptions() { _gameOpts.graphics.width = vars["width"].as(); _gameOpts.graphics.height = vars["height"].as(); _gameOpts.graphics.fullscreen = vars["fullscreen"].as(); + _gameOpts.graphics.shadowResolution = vars["shadowres"].as(); _gameOpts.audio.musicVolume = vars["musicvol"].as(); _gameOpts.audio.voiceVolume = vars["voicevol"].as(); _gameOpts.audio.soundVolume = vars["soundvol"].as(); diff --git a/src/render/types.h b/src/render/types.h index 68cb4422..dfa3d3bd 100644 --- a/src/render/types.h +++ b/src/render/types.h @@ -74,6 +74,7 @@ struct GraphicsOptions { int width { 0 }; int height { 0 }; bool fullscreen { false }; + int shadowResolution { 0 }; }; class IEventHandler { diff --git a/src/scene/pipeline/world.cpp b/src/scene/pipeline/world.cpp index 48bb0a55..3474ae83 100644 --- a/src/scene/pipeline/world.cpp +++ b/src/scene/pipeline/world.cpp @@ -42,7 +42,6 @@ namespace reone { namespace scene { -static constexpr int kShadowResolution = 2048; static constexpr float kShadowFarPlane = 10000.0f; static bool g_wireframesEnabled = false; @@ -115,7 +114,7 @@ void WorldRenderPipeline::init() { _shadowsDepth = make_unique("shadows_depth", getTextureProperties(TextureUsage::CubeMapDepthBuffer)); _shadowsDepth->init(); _shadowsDepth->bind(); - _shadowsDepth->clearPixels(kShadowResolution, kShadowResolution, PixelFormat::Depth); + _shadowsDepth->clearPixels(_opts.shadowResolution, _opts.shadowResolution, PixelFormat::Depth); _shadows.init(); _shadows.bind(); @@ -134,7 +133,7 @@ void WorldRenderPipeline::render() { void WorldRenderPipeline::drawShadows() { if (!_scene->isShadowLightPresent()) return; - withViewport(glm::ivec4(0, 0, kShadowResolution, kShadowResolution), [this]() { + withViewport(glm::ivec4(0, 0, _opts.shadowResolution, _opts.shadowResolution), [this]() { _shadows.bind(); glDrawBuffer(GL_NONE);