Separate DoF and motion blur from the main graphics preset

This commit is contained in:
Alayan
2019-10-24 15:56:42 +02:00
parent c7df5114e7
commit 102498f130
6 changed files with 168 additions and 67 deletions

View File

@@ -45,6 +45,18 @@
<spacer width="5" height="1%"/>
<div width="100%" height="fit" layout="horizontal-row">
<spacer width="20" height="100%" />
<div layout="vertical-row" width="8f" height="fit">
<gauge id="blur_level" min_value="0" max_value="2" width="100%" align="center" />
</div>
<div layout="vertical-row" proportion="1" height="100%">
<label height="100%" I18N="In the video settings" text="Blur Effects Level" align="left"/>
</div>
</div>
<spacer width="5" height="1%"/>
<!-- ************ VSYNC ************ -->
<div width="100%" height="fit" layout="horizontal-row" id="outer_box" >
<spacer width="20" height="100%" />

View File

@@ -89,6 +89,7 @@ void BubbleWidget::replaceText()
m_expanded_size.LowerRightCorner.Y += additionalNeededSize/2 + 10;
// reduce text to fit in the available space if it's too long
// FIXME : this loop is ugly
while (text_height > m_shrinked_size.getHeight() && message.size() > 10)
{
message = message.subString(0, message.size() - 10) + "...";
@@ -127,13 +128,9 @@ void BubbleWidget::updateSize()
m_element->setRelativePosition(currsize);
if (m_zoom > 0.5f)
{
getIrrlichtElement<IGUIStaticText>()->setText(getText().c_str());
}
else
{
getIrrlichtElement<IGUIStaticText>()->setText(m_shrinked_text.c_str());
}
}
// ----------------------------------------------------------------------------

View File

@@ -178,6 +178,7 @@ GUIEngine::EventPropagation CustomVideoSettingsDialog::processEvent(const std::s
ModalDialog::dismiss();
OptionsScreenVideo::getInstance()->updateGfxSlider();
OptionsScreenVideo::getInstance()->updateBlurSlider();
return GUIEngine::EVENT_BLOCK;
}
else if (eventSource == "dynamiclight")

View File

@@ -46,60 +46,75 @@
using namespace GUIEngine;
// ----------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------
void OptionsScreenVideo::initPresets()
{
m_presets.push_back
m_presets.push_back // Level 1
({
false /* light */, 0 /* shadow */, false /* bloom */, false /* motionblur */,
false /* lightshaft */, false /* glow */, false /* mlaa */, false /* ssao */,
false /* light scatter */, false /* animatedCharacters */, 1 /* particles */,
0 /* image_quality */, false /* depth of field */, true /* degraded IBL */
false /* light */, 0 /* shadow */, false /* bloom */, false /* lightshaft */,
false /* glow */, false /* mlaa */, false /* ssao */, false /* light scatter */,
false /* animatedCharacters */, 1 /* particles */, 0 /* image_quality */,
true /* degraded IBL */
});
m_presets.push_back
m_presets.push_back // Level 2
({
false /* light */, 0 /* shadow */, false /* bloom */, false /* motionblur */,
false /* lightshaft */, false /* glow */, false /* mlaa */, false /* ssao */,
false /* light scatter */, true /* animatedCharacters */, 2 /* particles */,
0 /* image_quality */, false /* depth of field */, true /* degraded IBL */
false /* light */, 0 /* shadow */, false /* bloom */, false /* lightshaft */,
false /* glow */, false /* mlaa */, false /* ssao */, false /* light scatter */,
true /* animatedCharacters */, 2 /* particles */, 0 /* image_quality */,
true /* degraded IBL */
});
m_presets.push_back
m_presets.push_back // Level 3
({
true /* light */, 0 /* shadow */, false /* bloom */, false /* motionblur */,
false /* lightshaft */, false /* glow */, false /* mlaa */, false /* ssao */,
false /* light scatter */, true /* animatedCharacters */, 2 /* particles */,
1 /* image_quality */, false /* depth of field */, true /* degraded IBL */
true /* light */, 0 /* shadow */, false /* bloom */, false /* lightshaft */,
false /* glow */, false /* mlaa */, false /* ssao */, false /* light scatter */,
true /* animatedCharacters */, 2 /* particles */, 1 /* image_quality */,
true /* degraded IBL */
});
m_presets.push_back
m_presets.push_back // Level 4
({
true /* light */, 0 /* shadow */, false /* bloom */, true /* motionblur */,
true /* lightshaft */, true /* glow */, true /* mlaa */, false /* ssao */,
true /* light scatter */, true /* animatedCharacters */, 2 /* particles */,
1 /* image_quality */, false /* depth of field */, false /* degraded IBL */
true /* light */, 0 /* shadow */, false /* bloom */, true /* lightshaft */,
true /* glow */, true /* mlaa */, false /* ssao */, true /* light scatter */,
true /* animatedCharacters */, 2 /* particles */, 1 /* image_quality */,
false /* degraded IBL */
});
m_presets.push_back
m_presets.push_back // Level 5
({
true /* light */, 512 /* shadow */, true /* bloom */, true /* motionblur */,
true /* lightshaft */, true /* glow */, true /* mlaa */, false /* ssao */,
true /* light scatter */, true /* animatedCharacters */, 2 /* particles */,
2 /* image_quality */, true /* depth of field */, false /* degraded IBL */
true /* light */, 512 /* shadow */, true /* bloom */, true /* lightshaft */,
true /* glow */, true /* mlaa */, false /* ssao */, true /* light scatter */,
true /* animatedCharacters */, 2 /* particles */, 2 /* image_quality */,
false /* degraded IBL */
});
m_presets.push_back
m_presets.push_back // Level 6
({
true /* light */, 1024 /* shadow */, true /* bloom */, true /* motionblur */,
true /* lightshaft */, true /* glow */, true /* mlaa */, true /* ssao */,
true /* light scatter */, true /* animatedCharacters */, 2 /* particles */,
2 /* image_quality */, true /* depth of field */, false /* degraded IBL */
true /* light */, 1024 /* shadow */, true /* bloom */, true /* lightshaft */,
true /* glow */, true /* mlaa */, true /* ssao */, true /* light scatter */,
true /* animatedCharacters */, 2 /* particles */, 2 /* image_quality */,
false /* degraded IBL */
});
m_blur_presets.push_back
({
false /* motionblur */, false /* depth of field */
});
m_blur_presets.push_back
({
true /* motionblur */, false /* depth of field */
});
m_blur_presets.push_back
({
true /* motionblur */, true /* depth of field */
});
} // initPresets
// ----------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------
int OptionsScreenVideo::getImageQuality()
{
if (UserConfigParams::m_anisotropic == 2 &&
@@ -117,7 +132,7 @@ int OptionsScreenVideo::getImageQuality()
return 1;
} // getImageQuality
// ----------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------
void OptionsScreenVideo::setImageQuality(int quality)
{
switch (quality)
@@ -142,7 +157,7 @@ void OptionsScreenVideo::setImageQuality(int quality)
}
} // setImageQuality
// ----------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------
OptionsScreenVideo::OptionsScreenVideo() : Screen("options_video.stkgui"),
m_prev_adv_pipline(false),
@@ -152,21 +167,28 @@ OptionsScreenVideo::OptionsScreenVideo() : Screen("options_video.stkgui"),
initPresets();
} // OptionsScreenVideo
// ----------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------
void OptionsScreenVideo::loadedFromFile()
{
m_inited = false;
assert(m_presets.size() == 6);
assert(m_blur_presets.size() == 3);
GUIEngine::SpinnerWidget* gfx =
getWidget<GUIEngine::SpinnerWidget>("gfx_level");
gfx->m_properties[GUIEngine::PROP_MAX_VALUE] =
StringUtils::toString(m_presets.size());
GUIEngine::SpinnerWidget* blur =
getWidget<GUIEngine::SpinnerWidget>("blur_level");
blur->m_properties[GUIEngine::PROP_MAX_VALUE] =
StringUtils::toString(m_blur_presets.size() - 1);
blur->m_properties[GUIEngine::PROP_MIN_VALUE] =
StringUtils::toString(0);
} // loadedFromFile
// ----------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------
void OptionsScreenVideo::init()
{
@@ -350,6 +372,7 @@ void OptionsScreenVideo::init()
// --- set gfx settings values
updateGfxSlider();
updateBlurSlider();
// ---- forbid changing resolution or animation settings from in-game
// (we need to disable them last because some items can't be edited when
@@ -374,7 +397,7 @@ void OptionsScreenVideo::init()
} // init
// ----------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------
void OptionsScreenVideo::updateResolutionsList()
{
@@ -401,7 +424,7 @@ void OptionsScreenVideo::updateResolutionsList()
}
}
// ----------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------
void OptionsScreenVideo::onScrollResolutionsList(void* data)
{
@@ -409,12 +432,11 @@ void OptionsScreenVideo::onScrollResolutionsList(void* data)
screen->updateResolutionsList();
}
// ----------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------
void OptionsScreenVideo::updateGfxSlider()
{
GUIEngine::SpinnerWidget* gfx =
getWidget<GUIEngine::SpinnerWidget>("gfx_level");
GUIEngine::SpinnerWidget* gfx = getWidget<GUIEngine::SpinnerWidget>("gfx_level");
assert( gfx != NULL );
bool found = false;
@@ -428,11 +450,9 @@ void OptionsScreenVideo::updateGfxSlider()
m_presets[l].lights == UserConfigParams::m_dynamic_lights &&
m_presets[l].lightshaft == UserConfigParams::m_light_shaft &&
m_presets[l].mlaa == UserConfigParams::m_mlaa &&
m_presets[l].motionblur == UserConfigParams::m_motionblur &&
m_presets[l].shadows == UserConfigParams::m_shadows_resolution &&
m_presets[l].ssao == UserConfigParams::m_ssao &&
m_presets[l].light_scatter == UserConfigParams::m_light_scatter &&
m_presets[l].dof == UserConfigParams::m_dof &&
m_presets[l].degraded_ibl == UserConfigParams::m_degraded_IBL)
{
gfx->setValue(l + 1);
@@ -445,17 +465,48 @@ void OptionsScreenVideo::updateGfxSlider()
{
//I18N: custom video settings
gfx->setCustomText( _("Custom") );
// Enable the blur slider if the modern renderer is used
getWidget<GUIEngine::SpinnerWidget>("blur_level")->
setActive(UserConfigParams::m_dynamic_lights);
}
updateTooltip();
}
} // updateGfxSlider
// ----------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------
void OptionsScreenVideo::updateBlurSlider()
{
GUIEngine::SpinnerWidget* blur = getWidget<GUIEngine::SpinnerWidget>("blur_level");
assert( blur != NULL );
bool found = false;
for (unsigned int l = 0; l < m_blur_presets.size(); l++)
{
if (m_blur_presets[l].motionblur == UserConfigParams::m_motionblur &&
m_blur_presets[l].dof == UserConfigParams::m_dof)
{
blur->setValue(l);
found = true;
break;
}
}
if (!found)
{
//I18N: custom video settings
blur->setCustomText( _("Custom") );
}
updateBlurTooltip();
} // updateBlurSlider
// --------------------------------------------------------------------------------------------
void OptionsScreenVideo::updateTooltip()
{
GUIEngine::SpinnerWidget* gfx =
getWidget<GUIEngine::SpinnerWidget>("gfx_level");
GUIEngine::SpinnerWidget* gfx = getWidget<GUIEngine::SpinnerWidget>("gfx_level");
assert( gfx != NULL );
core::stringw tooltip;
@@ -495,9 +546,6 @@ void OptionsScreenVideo::updateTooltip()
tooltip = tooltip + L"\n" + _("Light scattering: %s",
UserConfigParams::m_light_scatter ? enabled : disabled);
//I18N: in graphical options
tooltip = tooltip + L"\n" + _("Motion blur: %s",
UserConfigParams::m_motionblur ? enabled : disabled);
//I18N: in graphical options
tooltip = tooltip + L"\n" + _("Anti-aliasing: %s",
UserConfigParams::m_mlaa ? enabled : disabled);
//I18N: in graphical options
@@ -521,10 +569,6 @@ void OptionsScreenVideo::updateTooltip()
tooltip = tooltip + L"\n" + _("Light shaft (God rays): %s",
UserConfigParams::m_light_shaft ? enabled : disabled);
//I18N: in graphical options
tooltip = tooltip + L"\n" + _("Depth of field: %s",
UserConfigParams::m_dof ? enabled : disabled);
//I18N: in graphical options
int quality = getImageQuality();
tooltip = tooltip + L"\n" + _("Rendered image quality: %s",
@@ -533,7 +577,30 @@ void OptionsScreenVideo::updateTooltip()
gfx->setTooltip(tooltip);
} // updateTooltip
// ----------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------
void OptionsScreenVideo::updateBlurTooltip()
{
GUIEngine::SpinnerWidget* blur = getWidget<GUIEngine::SpinnerWidget>("blur_level");
assert( blur != NULL );
core::stringw tooltip;
const core::stringw enabled = _("Enabled");
const core::stringw disabled = _("Disabled");
//I18N: in graphical options
tooltip = tooltip + _("Motion blur: %s",
UserConfigParams::m_motionblur ? enabled : disabled);
//I18N: in graphical options
tooltip = tooltip + L"\n" + _("Depth of field: %s",
UserConfigParams::m_dof ? enabled : disabled);
blur->setTooltip(tooltip);
} // updateBlurTooltip
// --------------------------------------------------------------------------------------------
void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
const int playerID)
@@ -606,6 +673,9 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
const int level = gfx_level->getValue() - 1;
// Enable the blur spinner only if the new renderer is on
getWidget<GUIEngine::SpinnerWidget>("blur_level")->setActive(level >= 2);
UserConfigParams::m_animated_characters = m_presets[level].animatedCharacters;
UserConfigParams::m_particles_effects = m_presets[level].particles;
setImageQuality(m_presets[level].image_quality);
@@ -614,15 +684,29 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
UserConfigParams::m_dynamic_lights = m_presets[level].lights;
UserConfigParams::m_light_shaft = m_presets[level].lightshaft;
UserConfigParams::m_mlaa = m_presets[level].mlaa;
UserConfigParams::m_motionblur = m_presets[level].motionblur;
UserConfigParams::m_shadows_resolution = m_presets[level].shadows;
UserConfigParams::m_ssao = m_presets[level].ssao;
UserConfigParams::m_light_scatter = m_presets[level].light_scatter;
UserConfigParams::m_dof = m_presets[level].dof;
UserConfigParams::m_degraded_IBL = m_presets[level].degraded_ibl;
updateGfxSlider();
}
else if (name == "blur_level")
{
GUIEngine::SpinnerWidget* blur_level =
getWidget<GUIEngine::SpinnerWidget>("blur_level");
assert( blur_level != NULL );
const int level = blur_level->getValue();
if (UserConfigParams::m_dynamic_lights)
{
UserConfigParams::m_motionblur = m_blur_presets[level].motionblur;
UserConfigParams::m_dof = m_blur_presets[level].dof;
}
updateBlurSlider();
}
else if (name == "vsync")
{
GUIEngine::SpinnerWidget* vsync = getWidget<GUIEngine::SpinnerWidget>("vsync");
@@ -645,7 +729,7 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
}
} // eventCallback
// ----------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------
void OptionsScreenVideo::tearDown()
{
@@ -665,11 +749,11 @@ void OptionsScreenVideo::tearDown()
#endif
} // tearDown
// ----------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------
void OptionsScreenVideo::unloaded()
{
m_inited = false;
} // unloaded
// ----------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------

View File

@@ -30,7 +30,6 @@ struct GFXPreset
bool lights;
int shadows;
bool bloom;
bool motionblur;
bool lightshaft;
bool glow;
bool mlaa;
@@ -39,9 +38,14 @@ struct GFXPreset
bool animatedCharacters;
int particles;
int image_quality;
bool degraded_ibl;
};
struct BlurPreset
{
bool motionblur;
/** Depth of field */
bool dof;
bool degraded_ibl;
};
struct Resolution
@@ -85,9 +89,11 @@ private:
OptionsScreenVideo();
bool m_inited;
std::vector<GFXPreset> m_presets;
std::vector<BlurPreset> m_blur_presets;
std::vector<Resolution> m_resolutions;
void updateTooltip();
void updateBlurTooltip();
void updateResolutionsList();
void initPresets();
static void onScrollResolutionsList(void* data);
@@ -111,6 +117,7 @@ public:
virtual void unloaded() OVERRIDE;
void updateGfxSlider();
void updateBlurSlider();
static int getImageQuality();
static void setImageQuality(int quality);
};

View File

@@ -1247,7 +1247,7 @@ namespace StringUtils
} // breakText
/* This function checks if a char is suitable to break lines.
* Currently a copy of the function found at irrlicht/include/utfwrapping.h */
* Based on the function found at irrlicht/include/utfwrapping.h */
bool breakable (wchar_t c)
{
if ((c > 12287 && c < 40960) || //Common CJK words