forked from mirror/openmw-tes3mp
settings tab "shadows"
This commit is contained in:
parent
485adc8bdc
commit
e0a99f104b
7 changed files with 180 additions and 58 deletions
|
@ -112,6 +112,13 @@ namespace MWGui
|
|||
getWidget(mReflectActorsButton, "ReflectActorsButton");
|
||||
getWidget(mReflectTerrainButton, "ReflectTerrainButton");
|
||||
getWidget(mShadersButton, "ShadersButton");
|
||||
getWidget(mShadowsEnabledButton, "ShadowsEnabledButton");
|
||||
getWidget(mShadowsLargeDistance, "ShadowsLargeDistance");
|
||||
getWidget(mShadowsTextureSize, "ShadowsTextureSize");
|
||||
getWidget(mActorShadows, "ActorShadows");
|
||||
getWidget(mStaticsShadows, "StaticsShadows");
|
||||
getWidget(mMiscShadows, "MiscShadows");
|
||||
getWidget(mShadowsDebug, "ShadowsDebug");
|
||||
|
||||
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onOkButtonClicked);
|
||||
mShadersButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onShadersToggled);
|
||||
|
@ -130,6 +137,14 @@ namespace MWGui
|
|||
mResolutionList->eventListChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onResolutionSelected);
|
||||
mAnisotropySlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||
|
||||
mShadowsEnabledButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mShadowsLargeDistance->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mShadowsTextureSize->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onShadowTextureSize);
|
||||
mActorShadows->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mStaticsShadows->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mMiscShadows->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mShadowsDebug->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
|
||||
mMasterVolumeSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||
mVoiceVolumeSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||
mEffectsVolumeSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||
|
@ -182,7 +197,6 @@ namespace MWGui
|
|||
std::string tf = Settings::Manager::getString("texture filtering", "General");
|
||||
mTextureFilteringButton->setCaption(textureFilteringToStr(tf));
|
||||
mAnisotropyLabel->setCaption("Anisotropy (" + boost::lexical_cast<std::string>(Settings::Manager::getInt("anisotropy", "General")) + ")");
|
||||
mAnisotropyBox->setVisible(tf == "anisotropic");
|
||||
|
||||
float val = (Settings::Manager::getFloat("max viewing distance", "Viewing distance")-sViewDistMin)/(sViewDistMax-sViewDistMin);
|
||||
int viewdist = (mViewDistanceSlider->getScrollRange()-1) * val;
|
||||
|
@ -199,6 +213,14 @@ namespace MWGui
|
|||
mReflectActorsButton->setCaptionWithReplacing(Settings::Manager::getBool("reflect actors", "Water") ? "#{sOn}" : "#{sOff}");
|
||||
mReflectTerrainButton->setCaptionWithReplacing(Settings::Manager::getBool("reflect terrain", "Water") ? "#{sOn}" : "#{sOff}");
|
||||
|
||||
mShadowsTextureSize->setCaption (Settings::Manager::getString ("texture size", "Shadows"));
|
||||
mShadowsLargeDistance->setCaptionWithReplacing(Settings::Manager::getBool("split", "Shadows") ? "#{sOn}" : "#{sOff}");
|
||||
mShadowsEnabledButton->setCaptionWithReplacing(Settings::Manager::getBool("enabled", "Shadows") ? "#{sOn}" : "#{sOff}");
|
||||
mActorShadows->setCaptionWithReplacing(Settings::Manager::getBool("actor shadows", "Shadows") ? "#{sOn}" : "#{sOff}");
|
||||
mStaticsShadows->setCaptionWithReplacing(Settings::Manager::getBool("statics shadows", "Shadows") ? "#{sOn}" : "#{sOff}");
|
||||
mMiscShadows->setCaptionWithReplacing(Settings::Manager::getBool("misc shadows", "Shadows") ? "#{sOn}" : "#{sOff}");
|
||||
mShadowsDebug->setCaptionWithReplacing(Settings::Manager::getBool("debug", "Shadows") ? "#{sOn}" : "#{sOff}");
|
||||
|
||||
std::string shaders;
|
||||
if (!Settings::Manager::getBool("shaders", "Objects"))
|
||||
shaders = "off";
|
||||
|
@ -256,6 +278,25 @@ namespace MWGui
|
|||
mResolutionList->setIndexSelected(MyGUI::ITEM_NONE);
|
||||
}
|
||||
|
||||
void SettingsWindow::onShadowTextureSize(MyGUI::Widget* _sender)
|
||||
{
|
||||
std::string size = mShadowsTextureSize->getCaption();
|
||||
|
||||
if (size == "512")
|
||||
size = "1024";
|
||||
else if (size == "1024")
|
||||
size = "2048";
|
||||
else if (size == "2048")
|
||||
size = "4096";
|
||||
else
|
||||
size = "512";
|
||||
|
||||
mShadowsTextureSize->setCaption(size);
|
||||
|
||||
Settings::Manager::setString("texture size", "Shadows", size);
|
||||
apply();
|
||||
}
|
||||
|
||||
void SettingsWindow::onButtonToggled(MyGUI::Widget* _sender)
|
||||
{
|
||||
std::string on = mWindowManager.getGameSettingString("sOn", "On");
|
||||
|
@ -299,10 +340,6 @@ namespace MWGui
|
|||
Settings::Manager::setBool("fullscreen", "Video", newState);
|
||||
apply();
|
||||
}
|
||||
}
|
||||
else if (_sender == mShadersButton)
|
||||
{
|
||||
|
||||
}
|
||||
else if (_sender == mVSyncButton)
|
||||
{
|
||||
|
@ -324,6 +361,18 @@ namespace MWGui
|
|||
Settings::Manager::setBool("reflect actors", "Water", newState);
|
||||
else if (_sender == mReflectTerrainButton)
|
||||
Settings::Manager::setBool("reflect terrain", "Water", newState);
|
||||
else if (_sender == mShadowsEnabledButton)
|
||||
Settings::Manager::setBool("enabled", "Shadows", newState);
|
||||
else if (_sender == mShadowsLargeDistance)
|
||||
Settings::Manager::setBool("split", "Shadows", newState);
|
||||
else if (_sender == mActorShadows)
|
||||
Settings::Manager::setBool("actor shadows", "Shadows", newState);
|
||||
else if (_sender == mStaticsShadows)
|
||||
Settings::Manager::setBool("statics shadows", "Shadows", newState);
|
||||
else if (_sender == mMiscShadows)
|
||||
Settings::Manager::setBool("misc shadows", "Shadows", newState);
|
||||
else if (_sender == mShadowsDebug)
|
||||
Settings::Manager::setBool("debug", "Shadows", newState);
|
||||
|
||||
apply();
|
||||
}
|
||||
|
@ -352,6 +401,11 @@ namespace MWGui
|
|||
mReflectActorsButton->setEnabled(false);
|
||||
mReflectTerrainButton->setEnabled(false);
|
||||
Settings::Manager::setBool("shader", "Water", false);
|
||||
|
||||
// shadows not supported
|
||||
mShadowsEnabledButton->setEnabled(false);
|
||||
mShadowsEnabledButton->setCaptionWithReplacing("#{sOff}");
|
||||
Settings::Manager::setBool("enabled", "Shadows", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -360,6 +414,7 @@ namespace MWGui
|
|||
mReflectObjectsButton->setEnabled(true);
|
||||
mReflectActorsButton->setEnabled(true);
|
||||
mReflectTerrainButton->setEnabled(true);
|
||||
mShadowsEnabledButton->setEnabled(true);
|
||||
|
||||
Settings::Manager::setBool("shaders", "Objects", true);
|
||||
Settings::Manager::setString("shader mode", "General", val);
|
||||
|
@ -390,7 +445,6 @@ namespace MWGui
|
|||
next = "none";
|
||||
|
||||
mTextureFilteringButton->setCaption(textureFilteringToStr(next));
|
||||
mAnisotropyBox->setVisible(next == "anisotropic");
|
||||
|
||||
Settings::Manager::setString("texture filtering", "General", next);
|
||||
apply();
|
||||
|
|
|
@ -44,6 +44,14 @@ namespace MWGui
|
|||
MyGUI::Button* mReflectTerrainButton;
|
||||
MyGUI::Button* mShadersButton;
|
||||
|
||||
MyGUI::Button* mShadowsEnabledButton;
|
||||
MyGUI::Button* mShadowsLargeDistance;
|
||||
MyGUI::Button* mShadowsTextureSize;
|
||||
MyGUI::Button* mActorShadows;
|
||||
MyGUI::Button* mStaticsShadows;
|
||||
MyGUI::Button* mMiscShadows;
|
||||
MyGUI::Button* mShadowsDebug;
|
||||
|
||||
// audio
|
||||
MyGUI::ScrollBar* mMasterVolumeSlider;
|
||||
MyGUI::ScrollBar* mVoiceVolumeSlider;
|
||||
|
@ -61,6 +69,7 @@ namespace MWGui
|
|||
void onResolutionCancel();
|
||||
|
||||
void onShadersToggled(MyGUI::Widget* _sender);
|
||||
void onShadowTextureSize(MyGUI::Widget* _sender);
|
||||
|
||||
void apply();
|
||||
};
|
||||
|
|
|
@ -62,8 +62,6 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
|
|||
sh::OgrePlatform* platform = new sh::OgrePlatform("General", (resDir / "materials").string());
|
||||
platform->setCacheFolder ("./");
|
||||
mFactory = new sh::Factory(platform);
|
||||
mFactory->setSharedParameter ("pssmSplitPoints", sh::makeProperty<sh::Vector4>(new sh::Vector4(0,0,0,0)));
|
||||
mFactory->setSharedParameter ("shadowFar_fadeStart", sh::makeProperty<sh::Vector4>(new sh::Vector4(0,0,0,0)));
|
||||
|
||||
//The fog type must be set before any terrain objects are created as if the
|
||||
//fog type is set to FOG_NONE then the initially created terrain won't have any fog
|
||||
|
@ -646,6 +644,12 @@ void RenderingManager::processChangedSettings(const Settings::CategorySettingVec
|
|||
sh::Factory::getInstance ().setCurrentLanguage (lang);
|
||||
mObjects.rebuildStaticGeometry ();
|
||||
}
|
||||
else if (it->first == "Shadows")
|
||||
{
|
||||
mShadows->recreate ();
|
||||
|
||||
mObjects.rebuildStaticGeometry ();
|
||||
}
|
||||
}
|
||||
|
||||
if (changeRes)
|
||||
|
|
|
@ -36,6 +36,9 @@ void Shadows::recreate()
|
|||
bool split = Settings::Manager::getBool("split", "Shadows");
|
||||
//const bool split = false;
|
||||
|
||||
sh::Factory::getInstance ().setGlobalSetting ("shadows", enabled && !split ? "true" : "false");
|
||||
sh::Factory::getInstance ().setGlobalSetting ("shadows_pssm", enabled && split ? "true" : "false");
|
||||
|
||||
if (!enabled)
|
||||
{
|
||||
mSceneMgr->setShadowTechnique(SHADOWTYPE_NONE);
|
||||
|
@ -122,53 +125,62 @@ void Shadows::recreate()
|
|||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// --------------------------- Debug overlays to display the content of shadow maps -----------------------------------
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
if (Settings::Manager::getBool("debug", "Shadows"))
|
||||
{
|
||||
OverlayManager& mgr = OverlayManager::getSingleton();
|
||||
Overlay* overlay;
|
||||
|
||||
OverlayManager& mgr = OverlayManager::getSingleton();
|
||||
Overlay* overlay;
|
||||
|
||||
// destroy if already exists
|
||||
if (overlay = mgr.getByName("DebugOverlay"))
|
||||
mgr.destroy(overlay);
|
||||
|
||||
overlay = mgr.create("DebugOverlay");
|
||||
for (size_t i = 0; i < (split ? 3 : 1); ++i) {
|
||||
TexturePtr tex = mRendering->getScene()->getShadowTexture(i);
|
||||
|
||||
// Set up a debug panel to display the shadow
|
||||
|
||||
if (MaterialManager::getSingleton().resourceExists("Ogre/DebugTexture" + StringConverter::toString(i)))
|
||||
MaterialManager::getSingleton().remove("Ogre/DebugTexture" + StringConverter::toString(i));
|
||||
MaterialPtr debugMat = MaterialManager::getSingleton().create(
|
||||
"Ogre/DebugTexture" + StringConverter::toString(i),
|
||||
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
|
||||
|
||||
debugMat->getTechnique(0)->getPass(0)->setLightingEnabled(false);
|
||||
TextureUnitState *t = debugMat->getTechnique(0)->getPass(0)->createTextureUnitState(tex->getName());
|
||||
t->setTextureAddressingMode(TextureUnitState::TAM_CLAMP);
|
||||
// destroy if already exists
|
||||
if (overlay = mgr.getByName("DebugOverlay"))
|
||||
mgr.destroy(overlay);
|
||||
|
||||
OverlayContainer* debugPanel;
|
||||
|
||||
// destroy container if exists
|
||||
try
|
||||
{
|
||||
if (debugPanel =
|
||||
static_cast<OverlayContainer*>(
|
||||
mgr.getOverlayElement("Ogre/DebugTexPanel" + StringConverter::toString(i)
|
||||
)))
|
||||
mgr.destroyOverlayElement(debugPanel);
|
||||
}
|
||||
catch (Ogre::Exception&) {}
|
||||
|
||||
debugPanel = (OverlayContainer*)
|
||||
(OverlayManager::getSingleton().createOverlayElement("Panel", "Ogre/DebugTexPanel" + StringConverter::toString(i)));
|
||||
debugPanel->_setPosition(0.8, i*0.25);
|
||||
debugPanel->_setDimensions(0.2, 0.24);
|
||||
debugPanel->setMaterialName(debugMat->getName());
|
||||
debugPanel->show();
|
||||
overlay->add2D(debugPanel);
|
||||
overlay->show();
|
||||
}
|
||||
overlay = mgr.create("DebugOverlay");
|
||||
for (size_t i = 0; i < (split ? 3 : 1); ++i) {
|
||||
TexturePtr tex = mRendering->getScene()->getShadowTexture(i);
|
||||
|
||||
// Set up a debug panel to display the shadow
|
||||
|
||||
if (MaterialManager::getSingleton().resourceExists("Ogre/DebugTexture" + StringConverter::toString(i)))
|
||||
MaterialManager::getSingleton().remove("Ogre/DebugTexture" + StringConverter::toString(i));
|
||||
MaterialPtr debugMat = MaterialManager::getSingleton().create(
|
||||
"Ogre/DebugTexture" + StringConverter::toString(i),
|
||||
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
|
||||
|
||||
debugMat->getTechnique(0)->getPass(0)->setLightingEnabled(false);
|
||||
TextureUnitState *t = debugMat->getTechnique(0)->getPass(0)->createTextureUnitState(tex->getName());
|
||||
t->setTextureAddressingMode(TextureUnitState::TAM_CLAMP);
|
||||
|
||||
OverlayContainer* debugPanel;
|
||||
|
||||
// destroy container if exists
|
||||
try
|
||||
{
|
||||
if (debugPanel =
|
||||
static_cast<OverlayContainer*>(
|
||||
mgr.getOverlayElement("Ogre/DebugTexPanel" + StringConverter::toString(i)
|
||||
)))
|
||||
mgr.destroyOverlayElement(debugPanel);
|
||||
}
|
||||
catch (Ogre::Exception&) {}
|
||||
|
||||
debugPanel = (OverlayContainer*)
|
||||
(OverlayManager::getSingleton().createOverlayElement("Panel", "Ogre/DebugTexPanel" + StringConverter::toString(i)));
|
||||
debugPanel->_setPosition(0.8, i*0.25);
|
||||
debugPanel->_setDimensions(0.2, 0.24);
|
||||
debugPanel->setMaterialName(debugMat->getName());
|
||||
debugPanel->show();
|
||||
overlay->add2D(debugPanel);
|
||||
overlay->show();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OverlayManager& mgr = OverlayManager::getSingleton();
|
||||
Overlay* overlay;
|
||||
|
||||
if (overlay = mgr.getByName("DebugOverlay"))
|
||||
mgr.destroy(overlay);
|
||||
}
|
||||
}
|
||||
|
||||
PSSMShadowCameraSetup* Shadows::getPSSMSetup()
|
||||
|
|
|
@ -7,11 +7,8 @@
|
|||
#define MRT @shPropertyNotBool(is_transparent) && @shPropertyBool(mrt_output) && @shGlobalSettingBool(mrt_output)
|
||||
#define LIGHTING @shPropertyBool(lighting)
|
||||
|
||||
#define SHADOWS LIGHTING && 0
|
||||
#define SHADOWS_PSSM LIGHTING
|
||||
|
||||
#define SHADOWS 0 && LIGHTING
|
||||
#define SHADOWS_PSSM 0 && LIGHTING
|
||||
#define SHADOWS_PSSM LIGHTING && @shGlobalSettingBool(shadows_pssm)
|
||||
#define SHADOWS LIGHTING && @shGlobalSettingBool(shadows)
|
||||
|
||||
#if FOG || MRT || SHADOWS_PSSM
|
||||
#define NEED_DEPTH
|
||||
|
@ -183,7 +180,7 @@
|
|||
|
||||
lightDir = normalize(lightDir);
|
||||
|
||||
#if @shIterator == 0
|
||||
#if @shIterator == 0 && (SHADOWS || SHADOWS_PSSM)
|
||||
diffuse += materialDiffuse.xyz * lightDiffuse@shIterator.xyz * (1.0 / ((lightAttenuation@shIterator.y) + (lightAttenuation@shIterator.z * d) + (lightAttenuation@shIterator.w * d * d))) * max(dot(normal, lightDir), 0) * shadow;
|
||||
#else
|
||||
diffuse += materialDiffuse.xyz * lightDiffuse@shIterator.xyz * (1.0 / ((lightAttenuation@shIterator.y) + (lightAttenuation@shIterator.z * d) + (lightAttenuation@shIterator.w * d * d))) * max(dot(normal, lightDir), 0);
|
||||
|
|
|
@ -190,6 +190,50 @@
|
|||
</Widget>
|
||||
</Widget>
|
||||
|
||||
<Widget type="TabItem" skin="" position="4 28 344 272">
|
||||
<Property key="Caption" value=" Shadows "/>
|
||||
|
||||
<Widget type="TextBox" skin="SandText" position="42 4 120 24" align="Left Top">
|
||||
<Property key="Caption" value="Enabled"/>
|
||||
</Widget>
|
||||
<Widget type="Button" skin="MW_Button" position="4 4 34 24" align="Left Top" name="ShadowsEnabledButton"/>
|
||||
|
||||
<Widget type="Widget" skin="" position="24 32 300 230">
|
||||
<Widget type="TextBox" skin="SandText" position="42 0 300 24" align="Left Top">
|
||||
<Property key="Caption" value="Large distance (PSSM3)"/>
|
||||
</Widget>
|
||||
<Widget type="Button" skin="MW_Button" position="4 0 34 24" align="Left Top" name="ShadowsLargeDistance"/>
|
||||
|
||||
<Widget type="TextBox" skin="SandText" position="72 28 120 24" align="Left Top">
|
||||
<Property key="Caption" value="Texture size"/>
|
||||
</Widget>
|
||||
<Widget type="Button" skin="MW_Button" position="4 28 64 24" align="Left Top" name="ShadowsTextureSize"/>
|
||||
|
||||
<Widget type="TextBox" skin="SandText" position="42 56 120 24" align="Left Top">
|
||||
<Property key="Caption" value="Actor shadows"/>
|
||||
</Widget>
|
||||
<Widget type="Button" skin="MW_Button" position="4 56 34 24" align="Left Top" name="ActorShadows"/>
|
||||
|
||||
<Widget type="TextBox" skin="SandText" position="42 84 120 24" align="Left Top">
|
||||
<Property key="Caption" value="World shadows"/>
|
||||
</Widget>
|
||||
<Widget type="Button" skin="MW_Button" position="4 84 34 24" align="Left Top" name="StaticsShadows"/>
|
||||
|
||||
<Widget type="TextBox" skin="SandText" position="42 112 120 24" align="Left Top">
|
||||
<Property key="Caption" value="Misc shadows"/>
|
||||
</Widget>
|
||||
<Widget type="Button" skin="MW_Button" position="4 112 34 24" align="Left Top" name="MiscShadows"/>
|
||||
|
||||
<Widget type="TextBox" skin="SandText" position="42 172 120 24" align="Left Top">
|
||||
<Property key="Caption" value="Debug overlay"/>
|
||||
</Widget>
|
||||
<Widget type="Button" skin="MW_Button" position="4 172 34 24" align="Left Top" name="ShadowsDebug"/>
|
||||
|
||||
|
||||
</Widget>
|
||||
|
||||
</Widget>
|
||||
|
||||
</Widget>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
|
|
@ -76,6 +76,8 @@ statics shadows = true
|
|||
# Fraction of the total shadow distance after which the shadow starts to fade out
|
||||
fade start = 0.8
|
||||
|
||||
debug = false
|
||||
|
||||
[HUD]
|
||||
# FPS counter
|
||||
# 0: not visible
|
||||
|
|
Loading…
Reference in a new issue