feat: Make shadow map resolution configurable
This commit is contained in:
parent
7b5cf3a8cc
commit
52930c8539
3 changed files with 6 additions and 3 deletions
|
@ -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<int>()->default_value(800), "window width")
|
||||
("height", po::value<int>()->default_value(600), "window height")
|
||||
("fullscreen", po::value<bool>()->default_value(false), "enable fullscreen")
|
||||
("shadowres", po::value<int>()->default_value(kDefaultShadowResolution), "shadow map resolution")
|
||||
("musicvol", po::value<int>()->default_value(kDefaultMusicVolume), "music volume in percents")
|
||||
("voicevol", po::value<int>()->default_value(kDefaultVoiceVolume), "voice volume in percents")
|
||||
("soundvol", po::value<int>()->default_value(kDefaultSoundVolume), "sound volume in percents")
|
||||
|
@ -102,6 +104,7 @@ void Program::loadOptions() {
|
|||
_gameOpts.graphics.width = vars["width"].as<int>();
|
||||
_gameOpts.graphics.height = vars["height"].as<int>();
|
||||
_gameOpts.graphics.fullscreen = vars["fullscreen"].as<bool>();
|
||||
_gameOpts.graphics.shadowResolution = vars["shadowres"].as<int>();
|
||||
_gameOpts.audio.musicVolume = vars["musicvol"].as<int>();
|
||||
_gameOpts.audio.voiceVolume = vars["voicevol"].as<int>();
|
||||
_gameOpts.audio.soundVolume = vars["soundvol"].as<int>();
|
||||
|
|
|
@ -74,6 +74,7 @@ struct GraphicsOptions {
|
|||
int width { 0 };
|
||||
int height { 0 };
|
||||
bool fullscreen { false };
|
||||
int shadowResolution { 0 };
|
||||
};
|
||||
|
||||
class IEventHandler {
|
||||
|
|
|
@ -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<Texture>("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);
|
||||
|
|
Loading…
Reference in a new issue