mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 16:45:33 +00:00
Finalize settings, torch fix
This commit is contained in:
parent
71c30a31df
commit
4ba473b684
15 changed files with 318 additions and 152 deletions
|
@ -7,6 +7,7 @@
|
||||||
#include <QProxyStyle>
|
#include <QProxyStyle>
|
||||||
#include <components/contentselector/view/contentselector.hpp>
|
#include <components/contentselector/view/contentselector.hpp>
|
||||||
#include <components/contentselector/model/esmfile.hpp>
|
#include <components/contentselector/model/esmfile.hpp>
|
||||||
|
#include <components/sceneutil/lightmanager.hpp>
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
@ -124,6 +125,11 @@ bool Launcher::AdvancedPage::loadSettings()
|
||||||
|
|
||||||
loadSettingBool(activeGridObjectPagingCheckBox, "object paging active grid", "Terrain");
|
loadSettingBool(activeGridObjectPagingCheckBox, "object paging active grid", "Terrain");
|
||||||
viewingDistanceComboBox->setValue(convertToCells(mEngineSettings.getInt("viewing distance", "Camera")));
|
viewingDistanceComboBox->setValue(convertToCells(mEngineSettings.getInt("viewing distance", "Camera")));
|
||||||
|
|
||||||
|
auto lightingMethod = SceneUtil::LightManager::getLightingMethodFromString(mEngineSettings.getString("lighting method", "Shaders"));
|
||||||
|
if (lightingMethod == SceneUtil::LightingMethod::Undefined)
|
||||||
|
lightingMethod = SceneUtil::LightingMethod::PerObjectUniform;
|
||||||
|
lightingMethodComboBox->setCurrentIndex(static_cast<int>(lightingMethod));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
|
@ -246,6 +252,9 @@ void Launcher::AdvancedPage::saveSettings()
|
||||||
{
|
{
|
||||||
mEngineSettings.setInt("viewing distance", "Camera", convertToUnits(viewingDistance));
|
mEngineSettings.setInt("viewing distance", "Camera", convertToUnits(viewingDistance));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto lightingMethodStr = SceneUtil::LightManager::getLightingMethodString(static_cast<SceneUtil::LightingMethod>(lightingMethodComboBox->currentIndex()));
|
||||||
|
mEngineSettings.setString("lighting method", "Shaders", lightingMethodStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
|
|
|
@ -83,7 +83,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, bool fsStrict, const Files::Pat
|
||||||
defines["clamp"] = "1"; // Clamp lighting
|
defines["clamp"] = "1"; // Clamp lighting
|
||||||
defines["preLightEnv"] = "0"; // Apply environment maps after lighting like Morrowind
|
defines["preLightEnv"] = "0"; // Apply environment maps after lighting like Morrowind
|
||||||
defines["radialFog"] = "0";
|
defines["radialFog"] = "0";
|
||||||
defines["ffpLighting"] = "1";
|
defines["lightingModel"] = "0";
|
||||||
for (const auto& define : shadowDefines)
|
for (const auto& define : shadowDefines)
|
||||||
defines[define.first] = define.second;
|
defines[define.first] = define.second;
|
||||||
mResourceSystem->getSceneManager()->getShaderManager().setGlobalDefines(defines);
|
mResourceSystem->getSceneManager()->getShaderManager().setGlobalDefines(defines);
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include <MyGUI_ScrollView.h>
|
#include <MyGUI_ScrollView.h>
|
||||||
#include <MyGUI_Gui.h>
|
#include <MyGUI_Gui.h>
|
||||||
#include <MyGUI_TabControl.h>
|
#include <MyGUI_TabControl.h>
|
||||||
#include <MyGUI_TabItem.h>
|
|
||||||
|
|
||||||
#include <SDL_video.h>
|
#include <SDL_video.h>
|
||||||
|
|
||||||
|
@ -214,9 +213,9 @@ namespace MWGui
|
||||||
getWidget(mControllerSwitch, "ControllerButton");
|
getWidget(mControllerSwitch, "ControllerButton");
|
||||||
getWidget(mWaterTextureSize, "WaterTextureSize");
|
getWidget(mWaterTextureSize, "WaterTextureSize");
|
||||||
getWidget(mWaterReflectionDetail, "WaterReflectionDetail");
|
getWidget(mWaterReflectionDetail, "WaterReflectionDetail");
|
||||||
getWidget(mLightingMethodButton, "LightingMethodButton");
|
getWidget(mLightingMethodText, "LightingMethodText");
|
||||||
getWidget(mMaxLightsSlider, "MaxLightsSlider");
|
|
||||||
getWidget(mLightsResetButton, "LightsResetButton");
|
getWidget(mLightsResetButton, "LightsResetButton");
|
||||||
|
getWidget(mLightSettingOverlay, "LightSettingOverlay");
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
// hide gamma controls since it currently does not work under Linux
|
// hide gamma controls since it currently does not work under Linux
|
||||||
|
@ -242,7 +241,6 @@ namespace MWGui
|
||||||
mWaterTextureSize->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onWaterTextureSizeChanged);
|
mWaterTextureSize->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onWaterTextureSizeChanged);
|
||||||
mWaterReflectionDetail->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onWaterReflectionDetailChanged);
|
mWaterReflectionDetail->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onWaterReflectionDetailChanged);
|
||||||
|
|
||||||
mLightingMethodButton->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onLightingMethodChanged);
|
|
||||||
mLightsResetButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onLightsResetButtonClicked);
|
mLightsResetButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onLightsResetButtonClicked);
|
||||||
|
|
||||||
mKeyboardSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onKeyboardSwitchClicked);
|
mKeyboardSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onKeyboardSwitchClicked);
|
||||||
|
@ -289,18 +287,36 @@ namespace MWGui
|
||||||
mWaterReflectionDetail->setIndexSelected(waterReflectionDetail);
|
mWaterReflectionDetail->setIndexSelected(waterReflectionDetail);
|
||||||
|
|
||||||
auto lightingMethod = SceneUtil::LightManager::getLightingMethodFromString(Settings::Manager::getString("lighting method", "Shaders"));
|
auto lightingMethod = SceneUtil::LightManager::getLightingMethodFromString(Settings::Manager::getString("lighting method", "Shaders"));
|
||||||
switch (lightingMethod)
|
mLightingMethodText->setCaption(SceneUtil::LightManager::getLightingMethodString(lightingMethod));
|
||||||
|
|
||||||
|
if (lightingMethod == SceneUtil::LightingMethod::FFP || !Settings::Manager::getBool("force shaders", "Shaders"))
|
||||||
{
|
{
|
||||||
case SceneUtil::LightingMethod::Undefined:
|
std::string warningText =
|
||||||
case SceneUtil::LightingMethod::FFP:
|
"Unavailable with current settings."
|
||||||
mLightingMethodButton->setIndexSelected(0);
|
"\n\nEnable \"force shaders\" and use either the \"shaders\" or \"shaders compatibility\" lighting method.";
|
||||||
break;
|
MyGUI::Widget* parent = mLightSettingOverlay->getParent();
|
||||||
case SceneUtil::LightingMethod::PerObjectUniform:
|
mLightSettingOverlay->setEnabled(false);
|
||||||
mLightingMethodButton->setIndexSelected(1);
|
mLightSettingOverlay->setAlpha(0.8);
|
||||||
break;
|
parent->setUserString("ToolTipType", "Layout");
|
||||||
case SceneUtil::LightingMethod::SingleUBO:
|
parent->setUserString("ToolTipLayout", "TextToolTip");
|
||||||
mLightingMethodButton->setIndexSelected(2);
|
parent->setUserString("Caption_Text", warningText);
|
||||||
break;
|
parent->setEnabled(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string captionText;
|
||||||
|
if (lightingMethod == SceneUtil::LightingMethod::FFP)
|
||||||
|
captionText =
|
||||||
|
"Emulates fixed function pipeline lighting, advanced light settings are disabled when this mode is active";
|
||||||
|
else if (lightingMethod == SceneUtil::LightingMethod::PerObjectUniform)
|
||||||
|
captionText =
|
||||||
|
"Removes limit of 8 lights per object, fixes lighting attenuation, and enables groundcover lighting and light fade."
|
||||||
|
"\n\nDesigned for compatibility across hardware, and is not meant for large max light counts.";
|
||||||
|
else if (lightingMethod == SceneUtil::LightingMethod::SingleUBO)
|
||||||
|
captionText =
|
||||||
|
"Removes limit of 8 lights per object, fixes lighting attenuation, and enables groundcover lighting and light fade."
|
||||||
|
"\n\nDesigned for more modern hardware and large max light counts.";
|
||||||
|
mLightingMethodText->setUserString("Caption_Text", captionText);
|
||||||
}
|
}
|
||||||
|
|
||||||
mWindowBorderButton->setEnabled(!Settings::Manager::getBool("fullscreen", "Video"));
|
mWindowBorderButton->setEnabled(!Settings::Manager::getBool("fullscreen", "Video"));
|
||||||
|
@ -405,33 +421,10 @@ namespace MWGui
|
||||||
Settings::Manager::setFloat("minimum interior brightness", "Shaders", 0.1);
|
Settings::Manager::setFloat("minimum interior brightness", "Shaders", 0.1);
|
||||||
Settings::Manager::setInt("max lights", "Shaders", 8);
|
Settings::Manager::setInt("max lights", "Shaders", 8);
|
||||||
|
|
||||||
mLightingMethodButton->setIndexSelected(1);
|
|
||||||
|
|
||||||
apply();
|
apply();
|
||||||
configureWidgets(mMainWidget, false);
|
configureWidgets(mMainWidget, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsWindow::onLightingMethodChanged(MyGUI::ComboBox* _sender, size_t pos)
|
|
||||||
{
|
|
||||||
std::string setting;
|
|
||||||
auto lightingMethod = SceneUtil::LightManager::getLightingMethodFromString(_sender->getItemNameAt(pos));
|
|
||||||
switch (lightingMethod)
|
|
||||||
{
|
|
||||||
case SceneUtil::LightingMethod::FFP:
|
|
||||||
setting = "legacy";
|
|
||||||
break;
|
|
||||||
case SceneUtil::LightingMethod::Undefined:
|
|
||||||
case SceneUtil::LightingMethod::PerObjectUniform:
|
|
||||||
setting = "shaders compatibility";
|
|
||||||
break;
|
|
||||||
case SceneUtil::LightingMethod::SingleUBO:
|
|
||||||
setting = "shaders";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Settings::Manager::setString("lighting method", "Shaders", setting);
|
|
||||||
apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsWindow::onButtonToggled(MyGUI::Widget* _sender)
|
void SettingsWindow::onButtonToggled(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
std::string on = MWBase::Environment::get().getWindowManager()->getGameSettingString("sOn", "On");
|
std::string on = MWBase::Environment::get().getWindowManager()->getGameSettingString("sOn", "On");
|
||||||
|
|
|
@ -35,8 +35,8 @@ namespace MWGui
|
||||||
MyGUI::ComboBox* mWaterTextureSize;
|
MyGUI::ComboBox* mWaterTextureSize;
|
||||||
MyGUI::ComboBox* mWaterReflectionDetail;
|
MyGUI::ComboBox* mWaterReflectionDetail;
|
||||||
|
|
||||||
MyGUI::ComboBox* mLightingMethodButton;
|
MyGUI::Widget* mLightSettingOverlay;
|
||||||
MyGUI::ScrollBar* mMaxLightsSlider;
|
MyGUI::TextBox* mLightingMethodText;
|
||||||
MyGUI::Button* mLightsResetButton;
|
MyGUI::Button* mLightsResetButton;
|
||||||
|
|
||||||
// controls
|
// controls
|
||||||
|
@ -60,7 +60,6 @@ namespace MWGui
|
||||||
void onWaterReflectionDetailChanged(MyGUI::ComboBox* _sender, size_t pos);
|
void onWaterReflectionDetailChanged(MyGUI::ComboBox* _sender, size_t pos);
|
||||||
|
|
||||||
void onLightsResetButtonClicked(MyGUI::Widget* _sender);
|
void onLightsResetButtonClicked(MyGUI::Widget* _sender);
|
||||||
void onLightingMethodChanged(MyGUI::ComboBox* _sender, size_t pos);
|
|
||||||
|
|
||||||
void onRebindAction(MyGUI::Widget* _sender);
|
void onRebindAction(MyGUI::Widget* _sender);
|
||||||
void onInputTabMouseWheel(MyGUI::Widget* _sender, int _rel);
|
void onInputTabMouseWheel(MyGUI::Widget* _sender, int _rel);
|
||||||
|
|
|
@ -499,6 +499,11 @@ namespace MWRender
|
||||||
mAlpha = alpha;
|
mAlpha = alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setLightSource(const osg::ref_ptr<SceneUtil::LightSource>& lightSource)
|
||||||
|
{
|
||||||
|
mLightSource = lightSource;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setDefaults(osg::StateSet* stateset) override
|
void setDefaults(osg::StateSet* stateset) override
|
||||||
{
|
{
|
||||||
|
@ -517,14 +522,17 @@ namespace MWRender
|
||||||
stateset->addUniform(new osg::Uniform("colorMode", 0), osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
|
stateset->addUniform(new osg::Uniform("colorMode", 0), osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply(osg::StateSet* stateset, osg::NodeVisitor* /*nv*/) override
|
void apply(osg::StateSet* stateset, osg::NodeVisitor* nv) override
|
||||||
{
|
{
|
||||||
osg::Material* material = static_cast<osg::Material*>(stateset->getAttribute(osg::StateAttribute::MATERIAL));
|
osg::Material* material = static_cast<osg::Material*>(stateset->getAttribute(osg::StateAttribute::MATERIAL));
|
||||||
material->setAlpha(osg::Material::FRONT_AND_BACK, mAlpha);
|
material->setAlpha(osg::Material::FRONT_AND_BACK, mAlpha);
|
||||||
|
if (mLightSource)
|
||||||
|
mLightSource->setActorFade(mAlpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float mAlpha;
|
float mAlpha;
|
||||||
|
osg::ref_ptr<SceneUtil::LightSource> mLightSource;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Animation::AnimSource
|
struct Animation::AnimSource
|
||||||
|
@ -1613,7 +1621,7 @@ namespace MWRender
|
||||||
{
|
{
|
||||||
bool exterior = mPtr.isInCell() && mPtr.getCell()->getCell()->isExterior();
|
bool exterior = mPtr.isInCell() && mPtr.getCell()->getCell()->isExterior();
|
||||||
|
|
||||||
SceneUtil::addLight(parent, esmLight, Mask_ParticleSystem, Mask_Lighting, exterior);
|
mExtraLightSource = SceneUtil::addLight(parent, esmLight, Mask_ParticleSystem, Mask_Lighting, exterior);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animation::addEffect (const std::string& model, int effectId, bool loop, const std::string& bonename, const std::string& texture)
|
void Animation::addEffect (const std::string& model, int effectId, bool loop, const std::string& bonename, const std::string& texture)
|
||||||
|
@ -1763,6 +1771,7 @@ namespace MWRender
|
||||||
if (mTransparencyUpdater == nullptr)
|
if (mTransparencyUpdater == nullptr)
|
||||||
{
|
{
|
||||||
mTransparencyUpdater = new TransparencyUpdater(alpha);
|
mTransparencyUpdater = new TransparencyUpdater(alpha);
|
||||||
|
mTransparencyUpdater->setLightSource(mExtraLightSource);
|
||||||
mObjectRoot->addCullCallback(mTransparencyUpdater);
|
mObjectRoot->addCullCallback(mTransparencyUpdater);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -278,6 +278,7 @@ protected:
|
||||||
osg::ref_ptr<SceneUtil::LightSource> mGlowLight;
|
osg::ref_ptr<SceneUtil::LightSource> mGlowLight;
|
||||||
osg::ref_ptr<SceneUtil::GlowUpdater> mGlowUpdater;
|
osg::ref_ptr<SceneUtil::GlowUpdater> mGlowUpdater;
|
||||||
osg::ref_ptr<TransparencyUpdater> mTransparencyUpdater;
|
osg::ref_ptr<TransparencyUpdater> mTransparencyUpdater;
|
||||||
|
osg::ref_ptr<SceneUtil::LightSource> mExtraLightSource;
|
||||||
|
|
||||||
float mAlpha;
|
float mAlpha;
|
||||||
|
|
||||||
|
|
|
@ -1154,14 +1154,36 @@ namespace MWRender
|
||||||
else if (it->first == "Shaders" && it->second == "minimum interior brightness")
|
else if (it->first == "Shaders" && it->second == "minimum interior brightness")
|
||||||
{
|
{
|
||||||
mMinimumAmbientLuminance = std::clamp(Settings::Manager::getFloat("minimum interior brightness", "Shaders"), 0.f, 1.f);
|
mMinimumAmbientLuminance = std::clamp(Settings::Manager::getFloat("minimum interior brightness", "Shaders"), 0.f, 1.f);
|
||||||
if (MWMechanics::getPlayer().getCell())
|
if (MWMechanics::getPlayer().isInCell())
|
||||||
configureAmbient(MWMechanics::getPlayer().getCell()->getCell());
|
configureAmbient(MWMechanics::getPlayer().getCell()->getCell());
|
||||||
}
|
}
|
||||||
else if (it->first == "Shaders" && (it->second == "light bounds multiplier" ||
|
else if (it->first == "Shaders" && (it->second == "light bounds multiplier" ||
|
||||||
it->second == "maximum light distance" ||
|
it->second == "maximum light distance" ||
|
||||||
it->second == "light fade start"))
|
it->second == "light fade start" ||
|
||||||
|
it->second == "max lights"))
|
||||||
{
|
{
|
||||||
static_cast<SceneUtil::LightManager*>(getLightRoot())->processChangedSettings(changed);
|
auto* lightManager = static_cast<SceneUtil::LightManager*>(getLightRoot());
|
||||||
|
lightManager->processChangedSettings(changed);
|
||||||
|
|
||||||
|
if (it->second == "max lights" && !lightManager->usingFFP())
|
||||||
|
{
|
||||||
|
mViewer->stopThreading();
|
||||||
|
|
||||||
|
lightManager->updateMaxLights();
|
||||||
|
|
||||||
|
auto defines = mResourceSystem->getSceneManager()->getShaderManager().getGlobalDefines();
|
||||||
|
for (auto& define : lightManager->getLightDefines())
|
||||||
|
defines[define.first] = define.second;
|
||||||
|
mResourceSystem->getSceneManager()->getShaderManager().setGlobalDefines(defines);
|
||||||
|
|
||||||
|
mSceneRoot->removeUpdateCallback(mStateUpdater);
|
||||||
|
mStateUpdater = new StateUpdater;
|
||||||
|
mSceneRoot->addUpdateCallback(mStateUpdater);
|
||||||
|
mStateUpdater->setFogEnd(mViewDistance);
|
||||||
|
updateAmbient();
|
||||||
|
|
||||||
|
mViewer->startThreading();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,8 @@ namespace SceneUtil
|
||||||
mPhase = mPhase <= 0.5f ? 1.f : 0.25f;
|
mPhase = mPhase <= 0.5f ? 1.f : 0.25f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static_cast<SceneUtil::LightSource*>(node)->getLight(nv->getTraversalNumber())->setDiffuse(mDiffuseColor * mBrightness);
|
auto* lightSource = static_cast<SceneUtil::LightSource*>(node);
|
||||||
|
lightSource->getLight(nv->getTraversalNumber())->setDiffuse(mDiffuseColor * mBrightness * lightSource->getActorFade());
|
||||||
|
|
||||||
traverse(node, nv);
|
traverse(node, nv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -415,6 +415,11 @@ namespace SceneUtil
|
||||||
|
|
||||||
META_StateAttribute(NifOsg, LightStateAttributePerObjectUniform, osg::StateAttribute::LIGHT)
|
META_StateAttribute(NifOsg, LightStateAttributePerObjectUniform, osg::StateAttribute::LIGHT)
|
||||||
|
|
||||||
|
void resize(int numLights)
|
||||||
|
{
|
||||||
|
mLights.resize(std::min(static_cast<size_t>(numLights), mLights.size()));
|
||||||
|
}
|
||||||
|
|
||||||
void apply(osg::State &state) const override
|
void apply(osg::State &state) const override
|
||||||
{
|
{
|
||||||
auto* lightUniform = mLightManager->getStateSet()->getUniform("LightBuffer");
|
auto* lightUniform = mLightManager->getStateSet()->getUniform("LightBuffer");
|
||||||
|
@ -511,6 +516,9 @@ namespace SceneUtil
|
||||||
|
|
||||||
uOldCount->get(oldCount);
|
uOldCount->get(oldCount);
|
||||||
|
|
||||||
|
// max lights count can change during runtime
|
||||||
|
oldCount = std::min(mLightManager->getMaxLights(), oldCount);
|
||||||
|
|
||||||
auto& lightData = mLightManager->getLightIndexMap(frameNum);
|
auto& lightData = mLightManager->getLightIndexMap(frameNum);
|
||||||
|
|
||||||
for (int i = 0; i < oldCount; ++i)
|
for (int i = 0; i < oldCount; ++i)
|
||||||
|
@ -779,6 +787,14 @@ namespace SceneUtil
|
||||||
return LightingMethod::Undefined;
|
return LightingMethod::Undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string LightManager::getLightingMethodString(LightingMethod method)
|
||||||
|
{
|
||||||
|
for (const auto& p : LightManager::mLightingMethodSettingMap)
|
||||||
|
if (p.second == method)
|
||||||
|
return p.first;
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
LightManager::LightManager(bool ffp)
|
LightManager::LightManager(bool ffp)
|
||||||
: mStartLight(0)
|
: mStartLight(0)
|
||||||
, mLightingMask(~0u)
|
, mLightingMask(~0u)
|
||||||
|
@ -891,6 +907,61 @@ namespace SceneUtil
|
||||||
updateSettings();
|
updateSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LightManager::updateMaxLights()
|
||||||
|
{
|
||||||
|
if (usingFFP())
|
||||||
|
return;
|
||||||
|
|
||||||
|
setMaxLights(std::clamp(Settings::Manager::getInt("max lights", "Shaders"), mMaxLightsLowerLimit, mMaxLightsUpperLimit));
|
||||||
|
|
||||||
|
if (getLightingMethod() == LightingMethod::PerObjectUniform)
|
||||||
|
{
|
||||||
|
auto* prevUniform = getStateSet()->getUniform("LightBuffer");
|
||||||
|
osg::ref_ptr<osg::Uniform> newUniform = new osg::Uniform(osg::Uniform::FLOAT_MAT4, "LightBuffer", getMaxLights() + 1);
|
||||||
|
|
||||||
|
for (int i = 0; i < getMaxLights() + 1; ++i)
|
||||||
|
{
|
||||||
|
osg::Matrixf prevLightData;
|
||||||
|
prevUniform->getElement(i, prevLightData);
|
||||||
|
newUniform->setElement(i, prevLightData);
|
||||||
|
}
|
||||||
|
|
||||||
|
getStateSet()->removeUniform(prevUniform);
|
||||||
|
getStateSet()->addUniform(newUniform);
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; ++i)
|
||||||
|
{
|
||||||
|
for (auto& pair : mStateSetCache[i])
|
||||||
|
static_cast<LightStateAttributePerObjectUniform*>(pair.second->getAttribute(osg::StateAttribute::LIGHT))->resize(getMaxLights());
|
||||||
|
mStateSetCache[i].clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 2; ++i)
|
||||||
|
{
|
||||||
|
for (auto& pair : mStateSetCache[i])
|
||||||
|
{
|
||||||
|
auto& stateset = pair.second;
|
||||||
|
osg::Uniform* uOldArray = stateset->getUniform("PointLightIndex");
|
||||||
|
osg::Uniform* uOldCount = stateset->getUniform("PointLightCount");
|
||||||
|
|
||||||
|
int prevCount;
|
||||||
|
uOldCount->get(prevCount);
|
||||||
|
int newCount = std::min(getMaxLights(), prevCount);
|
||||||
|
uOldCount->set(newCount);
|
||||||
|
|
||||||
|
osg::ref_ptr<osg::IntArray> newArray = uOldArray->getIntArray();
|
||||||
|
newArray->resize(newCount);
|
||||||
|
|
||||||
|
stateset->removeUniform(uOldArray);
|
||||||
|
stateset->addUniform(new osg::Uniform("PointLightIndex", newArray));
|
||||||
|
}
|
||||||
|
mStateSetCache[i].clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void LightManager::updateSettings()
|
void LightManager::updateSettings()
|
||||||
{
|
{
|
||||||
if (getLightingMethod() == LightingMethod::FFP)
|
if (getLightingMethod() == LightingMethod::FFP)
|
||||||
|
@ -920,7 +991,7 @@ namespace SceneUtil
|
||||||
auto* stateset = getOrCreateStateSet();
|
auto* stateset = getOrCreateStateSet();
|
||||||
|
|
||||||
setLightingMethod(LightingMethod::PerObjectUniform);
|
setLightingMethod(LightingMethod::PerObjectUniform);
|
||||||
setMaxLights(std::clamp(targetLights, 2, 64));
|
setMaxLights(std::clamp(targetLights, mMaxLightsLowerLimit, LightManager::mMaxLightsUpperLimit));
|
||||||
|
|
||||||
stateset->addUniform(new osg::Uniform(osg::Uniform::FLOAT_MAT4, "LightBuffer", getMaxLights() + 1));
|
stateset->addUniform(new osg::Uniform(osg::Uniform::FLOAT_MAT4, "LightBuffer", getMaxLights() + 1));
|
||||||
}
|
}
|
||||||
|
@ -928,7 +999,7 @@ namespace SceneUtil
|
||||||
void LightManager::initSingleUBO(int targetLights)
|
void LightManager::initSingleUBO(int targetLights)
|
||||||
{
|
{
|
||||||
setLightingMethod(LightingMethod::SingleUBO);
|
setLightingMethod(LightingMethod::SingleUBO);
|
||||||
setMaxLights(std::clamp(targetLights, 2, 64));
|
setMaxLights(std::clamp(targetLights, mMaxLightsLowerLimit, LightManager::mMaxLightsUpperLimit));
|
||||||
|
|
||||||
for (int i = 0; i < 2; ++i)
|
for (int i = 0; i < 2; ++i)
|
||||||
{
|
{
|
||||||
|
@ -1000,7 +1071,7 @@ namespace SceneUtil
|
||||||
getLightIndexMap(frameNum).clear();
|
getLightIndexMap(frameNum).clear();
|
||||||
mLights.clear();
|
mLights.clear();
|
||||||
mLightsInViewSpace.clear();
|
mLightsInViewSpace.clear();
|
||||||
|
return;
|
||||||
// Do an occasional cleanup for orphaned lights.
|
// Do an occasional cleanup for orphaned lights.
|
||||||
for (int i = 0; i < 2; ++i)
|
for (int i = 0; i < 2; ++i)
|
||||||
{
|
{
|
||||||
|
@ -1133,6 +1204,7 @@ namespace SceneUtil
|
||||||
|
|
||||||
LightSource::LightSource()
|
LightSource::LightSource()
|
||||||
: mRadius(0.f)
|
: mRadius(0.f)
|
||||||
|
, mActorFade(1.f)
|
||||||
{
|
{
|
||||||
setUpdateCallback(new CollectLightCallback);
|
setUpdateCallback(new CollectLightCallback);
|
||||||
mId = sLightId++;
|
mId = sLightId++;
|
||||||
|
@ -1141,6 +1213,7 @@ namespace SceneUtil
|
||||||
LightSource::LightSource(const LightSource ©, const osg::CopyOp ©op)
|
LightSource::LightSource(const LightSource ©, const osg::CopyOp ©op)
|
||||||
: osg::Node(copy, copyop)
|
: osg::Node(copy, copyop)
|
||||||
, mRadius(copy.mRadius)
|
, mRadius(copy.mRadius)
|
||||||
|
, mActorFade(copy.mActorFade)
|
||||||
{
|
{
|
||||||
mId = sLightId++;
|
mId = sLightId++;
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ namespace SceneUtil
|
||||||
enum class LightingMethod
|
enum class LightingMethod
|
||||||
{
|
{
|
||||||
FFP,
|
FFP,
|
||||||
SingleUBO,
|
|
||||||
PerObjectUniform,
|
PerObjectUniform,
|
||||||
|
SingleUBO,
|
||||||
Undefined
|
Undefined
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -54,6 +54,8 @@ namespace SceneUtil
|
||||||
|
|
||||||
int mId;
|
int mId;
|
||||||
|
|
||||||
|
float mActorFade;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
META_Node(SceneUtil, LightSource)
|
META_Node(SceneUtil, LightSource)
|
||||||
|
@ -73,6 +75,16 @@ namespace SceneUtil
|
||||||
mRadius = radius;
|
mRadius = radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setActorFade(float alpha)
|
||||||
|
{
|
||||||
|
mActorFade = alpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
float getActorFade() const
|
||||||
|
{
|
||||||
|
return mActorFade;
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the osg::Light safe for modification in the given frame.
|
/// Get the osg::Light safe for modification in the given frame.
|
||||||
/// @par May be used externally to animate the light's color/attenuation properties,
|
/// @par May be used externally to animate the light's color/attenuation properties,
|
||||||
/// and is used internally to synchronize the light's position with the position of the LightSource.
|
/// and is used internally to synchronize the light's position with the position of the LightSource.
|
||||||
|
@ -104,15 +116,8 @@ namespace SceneUtil
|
||||||
public:
|
public:
|
||||||
static bool isValidLightingModelString(const std::string& value);
|
static bool isValidLightingModelString(const std::string& value);
|
||||||
static LightingMethod getLightingMethodFromString(const std::string& value);
|
static LightingMethod getLightingMethodFromString(const std::string& value);
|
||||||
|
/// Returns string as used in settings file, or the empty string if the method is undefined
|
||||||
enum class UniformKey
|
static std::string getLightingMethodString(LightingMethod method);
|
||||||
{
|
|
||||||
Diffuse,
|
|
||||||
Ambient,
|
|
||||||
Specular,
|
|
||||||
Position,
|
|
||||||
Attenuation
|
|
||||||
};
|
|
||||||
|
|
||||||
struct LightSourceTransform
|
struct LightSourceTransform
|
||||||
{
|
{
|
||||||
|
@ -178,10 +183,10 @@ namespace SceneUtil
|
||||||
|
|
||||||
void processChangedSettings(const Settings::CategorySettingVector& changed);
|
void processChangedSettings(const Settings::CategorySettingVector& changed);
|
||||||
|
|
||||||
private:
|
/// Not thread safe, it is the responsibility of the caller to stop/start threading on the viewer
|
||||||
friend class LightManagerStateAttribute;
|
void updateMaxLights();
|
||||||
friend class LightManagerCullCallback;
|
|
||||||
|
|
||||||
|
private:
|
||||||
void initFFP(int targetLights);
|
void initFFP(int targetLights);
|
||||||
void initPerObjectUniform(int targetLights);
|
void initPerObjectUniform(int targetLights);
|
||||||
void initSingleUBO(int targetLights);
|
void initSingleUBO(int targetLights);
|
||||||
|
@ -226,6 +231,8 @@ namespace SceneUtil
|
||||||
|
|
||||||
int mMaxLights;
|
int mMaxLights;
|
||||||
|
|
||||||
|
static constexpr auto mMaxLightsLowerLimit = 2;
|
||||||
|
static constexpr auto mMaxLightsUpperLimit = 64;
|
||||||
static constexpr auto mFFPMaxLights = 8;
|
static constexpr auto mFFPMaxLights = 8;
|
||||||
|
|
||||||
static const std::unordered_map<std::string, LightingMethod> mLightingMethodSettingMap;
|
static const std::unordered_map<std::string, LightingMethod> mLightingMethodSettingMap;
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace SceneUtil
|
||||||
light->setQuadraticAttenuation(quadraticAttenuation);
|
light->setQuadraticAttenuation(quadraticAttenuation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addLight(osg::Group* node, const ESM::Light* esmLight, unsigned int partsysMask, unsigned int lightMask, bool isExterior)
|
osg::ref_ptr<LightSource> addLight(osg::Group* node, const ESM::Light* esmLight, unsigned int partsysMask, unsigned int lightMask, bool isExterior)
|
||||||
{
|
{
|
||||||
SceneUtil::FindByNameVisitor visitor("AttachLight");
|
SceneUtil::FindByNameVisitor visitor("AttachLight");
|
||||||
node->accept(visitor);
|
node->accept(visitor);
|
||||||
|
@ -87,6 +87,7 @@ namespace SceneUtil
|
||||||
|
|
||||||
osg::ref_ptr<LightSource> lightSource = createLightSource(esmLight, lightMask, isExterior, osg::Vec4f(0,0,0,1));
|
osg::ref_ptr<LightSource> lightSource = createLightSource(esmLight, lightMask, isExterior, osg::Vec4f(0,0,0,1));
|
||||||
attachTo->addChild(lightSource);
|
attachTo->addChild(lightSource);
|
||||||
|
return lightSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::ref_ptr<LightSource> createLightSource(const ESM::Light* esmLight, unsigned int lightMask, bool isExterior, const osg::Vec4f& ambient)
|
osg::ref_ptr<LightSource> createLightSource(const ESM::Light* esmLight, unsigned int lightMask, bool isExterior, const osg::Vec4f& ambient)
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace SceneUtil
|
||||||
/// @param partsysMask Node mask to ignore when computing the sub graph's bounding box.
|
/// @param partsysMask Node mask to ignore when computing the sub graph's bounding box.
|
||||||
/// @param lightMask Mask to assign to the newly created LightSource.
|
/// @param lightMask Mask to assign to the newly created LightSource.
|
||||||
/// @param isExterior Is the light outside? May be used for deciding which attenuation settings to use.
|
/// @param isExterior Is the light outside? May be used for deciding which attenuation settings to use.
|
||||||
void addLight (osg::Group* node, const ESM::Light* esmLight, unsigned int partsysMask, unsigned int lightMask, bool isExterior);
|
osg::ref_ptr<LightSource> addLight (osg::Group* node, const ESM::Light* esmLight, unsigned int partsysMask, unsigned int lightMask, bool isExterior);
|
||||||
|
|
||||||
/// @brief Convert an ESM::Light to a SceneUtil::LightSource, and return it.
|
/// @brief Convert an ESM::Light to a SceneUtil::LightSource, and return it.
|
||||||
/// @param esmLight The light definition coming from the game files containing radius, color, flicker, etc.
|
/// @param esmLight The light definition coming from the game files containing radius, color, flicker, etc.
|
||||||
|
|
|
@ -460,91 +460,110 @@
|
||||||
|
|
||||||
<Widget type="TabItem" skin="" position="4 32 360 308">
|
<Widget type="TabItem" skin="" position="4 32 360 308">
|
||||||
<Property key="Caption" value=" Lights "/>
|
<Property key="Caption" value=" Lights "/>
|
||||||
<!-- Lighting Method -->
|
<Widget type="Widget" skin="" position="0 0 360 315" align="Stretch">
|
||||||
<Widget type="TextBox" skin="NormalText" position="0 4 160 18" align="Left Top">
|
<Widget type="Widget" skin="" position="0 0 360 315" align="Stretch" name="LightSettingOverlay">
|
||||||
<Property key="Caption" value="*Lighting Method"/>
|
<!-- Lighting Method -->
|
||||||
|
<Widget type="TextBox" skin="NormalText" position="0 4 170 18" align="Left Top">
|
||||||
|
<Property key="Caption" value="Lighting Method:"/>
|
||||||
|
</Widget>
|
||||||
|
<Widget type="TextBox" skin="SandText" position="0 28 170 18" align="Left Top" name="LightingMethodText">
|
||||||
|
<UserString key="ToolTipType" value="Layout"/>
|
||||||
|
<UserString key="ToolTipLayout" value="TextToolTip"/>
|
||||||
|
</Widget>
|
||||||
|
<!-- Max Lights -->
|
||||||
|
<Widget type="TextBox" skin="NormalText" position="178 4 160 18" align="Left Top" name="MaxLightsText">
|
||||||
|
<UserString key="ToolTipType" value="Layout"/>
|
||||||
|
<UserString key="ToolTipLayout" value="TextToolTip"/>
|
||||||
|
<UserString key="Caption_Text" value="Default: 8\nMaximum number of lights per object.\n\nA low number near default will cause light popping similar to what you would see with legacy lighting."/>
|
||||||
|
</Widget>
|
||||||
|
<Widget type="ScrollBar" skin="MW_HScroll" position="178 30 160 18" align="Right Top HStretch" name="MaxLightsSlider">
|
||||||
|
<Property key="Range" value="24"/>
|
||||||
|
<Property key="Page" value="1"/>
|
||||||
|
<UserString key="SettingType" value="Slider"/>
|
||||||
|
<UserString key="SettingMin" value="4"/>
|
||||||
|
<UserString key="SettingMax" value="32"/>
|
||||||
|
<UserString key="SettingCategory" value="Shaders"/>
|
||||||
|
<UserString key="SettingName" value="max lights"/>
|
||||||
|
<UserString key="SettingValueType" value="Integer"/>
|
||||||
|
<UserString key="SettingLabelWidget" value="MaxLightsText"/>
|
||||||
|
<UserString key="SettingLabelCaption" value="Max Lights (%s)"/>
|
||||||
|
</Widget>
|
||||||
|
<Widget type="ImageBox" skin="MW_HLine" position="0 54 360 18" align="Top HStretch"/>
|
||||||
|
<!-- Light Fade Start -->
|
||||||
|
<Widget type="TextBox" skin="NormalText" position="0 78 352 18" align="Left Top" name="MaxLightDistanceText">
|
||||||
|
<UserString key="ToolTipType" value="Layout"/>
|
||||||
|
<UserString key="ToolTipLayout" value="TextToolTip"/>
|
||||||
|
<UserString key="Caption_Text" value="Default: 8192 (units)\nMaximum distance at which lights will appear.\n\nSet this to 0.0 to disable it."/>
|
||||||
|
</Widget>
|
||||||
|
<Widget type="ScrollBar" skin="MW_HScroll" position="0 104 352 18" align="HStretch Top">
|
||||||
|
<Property key="Range" value="8192"/>
|
||||||
|
<Property key="Page" value="1"/>
|
||||||
|
<UserString key="SettingType" value="Slider"/>
|
||||||
|
<UserString key="SettingMin" value="0"/>
|
||||||
|
<UserString key="SettingMax" value="8192"/>
|
||||||
|
<UserString key="SettingCategory" value="Shaders"/>
|
||||||
|
<UserString key="SettingName" value="maximum light distance"/>
|
||||||
|
<UserString key="SettingValueType" value="Integer"/>
|
||||||
|
<UserString key="SettingLabelWidget" value="MaxLightDistanceText"/>
|
||||||
|
<UserString key="SettingLabelCaption" value="Maximum Light Distance (%s)"/>
|
||||||
|
</Widget>
|
||||||
|
<!-- Light Fade Multiplier -->
|
||||||
|
<Widget type="TextBox" skin="NormalText" position="0 128 352 18" align="Left Top" name="LightFadeMultiplierText">
|
||||||
|
<UserString key="ToolTipType" value="Layout"/>
|
||||||
|
<UserString key="ToolTipLayout" value="TextToolTip"/>
|
||||||
|
<UserString key="Caption_Text" value="Default: 0.85\nFraction of maximum distance at which lights will start to fade.\n\nSet this to a low value for slower transitions or a high value of quicker transitions."/>
|
||||||
|
</Widget>
|
||||||
|
<Widget type="ScrollBar" skin="MW_HScroll" position="0 152 352 18" align="HStretch Top">
|
||||||
|
<Property key="Range" value="10000"/>
|
||||||
|
<Property key="Page" value="100"/>
|
||||||
|
<UserString key="SettingType" value="Slider"/>
|
||||||
|
<UserString key="SettingCategory" value="Shaders"/>
|
||||||
|
<UserString key="SettingName" value="light fade start"/>
|
||||||
|
<UserString key="SettingValueType" value="Float"/>
|
||||||
|
<UserString key="SettingMin" value="0.0"/>
|
||||||
|
<UserString key="SettingMax" value="1.0"/>
|
||||||
|
<UserString key="SettingLabelWidget" value="LightFadeMultiplierText"/>
|
||||||
|
<UserString key="SettingLabelCaption" value="Fade Start Multiplier (%s)"/>
|
||||||
|
</Widget>
|
||||||
|
<!-- Bounding Sphere Multiplier -->
|
||||||
|
<Widget type="TextBox" skin="NormalText" position="0 176 352 18" align="Left Top" name="BoundingSphereMultText">
|
||||||
|
<UserString key="ToolTipType" value="Layout"/>
|
||||||
|
<UserString key="ToolTipLayout" value="TextToolTip"/>
|
||||||
|
<UserString key="Caption_Text" value="Default: 1.75\nMultipler for bounding sphere of lights.\nHigher numbers allows for smooth falloff but require an increase in number of max lights.\n\nDoes not effect the illumination or strength of lights."/>
|
||||||
|
</Widget>
|
||||||
|
<Widget type="ScrollBar" skin="MW_HScroll" position="0 200 352 18" align="HStretch Top">
|
||||||
|
<Property key="Range" value="500000"/>
|
||||||
|
<Property key="Page" value="1000"/>
|
||||||
|
<UserString key="SettingType" value="Slider"/>
|
||||||
|
<UserString key="SettingMin" value="0.0"/>
|
||||||
|
<UserString key="SettingMax" value="5.0"/>
|
||||||
|
<UserString key="SettingCategory" value="Shaders"/>
|
||||||
|
<UserString key="SettingName" value="light bounds multiplier"/>
|
||||||
|
<UserString key="SettingValueType" value="Float"/>
|
||||||
|
<UserString key="SettingLabelWidget" value="BoundingSphereMultText"/>
|
||||||
|
<UserString key="SettingLabelCaption" value="Bounding Sphere Multiplier (%s)"/>
|
||||||
|
</Widget>
|
||||||
|
<!-- Minimum Ambient Brightness -->
|
||||||
|
<Widget type="TextBox" skin="NormalText" position="0 224 352 18" align="Left Top" name="MinimumBrightnessText">
|
||||||
|
<UserString key="ToolTipType" value="Layout"/>
|
||||||
|
<UserString key="ToolTipLayout" value="TextToolTip"/>
|
||||||
|
<UserString key="Caption_Text" value="Default: 0.1\nMinimum ambient interior brightness.\n\nIncrease this if you feel interiors are too dark."/>
|
||||||
|
</Widget>
|
||||||
|
<Widget type="ScrollBar" skin="MW_HScroll" position="0 248 352 18" align="HStretch Top">
|
||||||
|
<Property key="Range" value="10000"/>
|
||||||
|
<Property key="Page" value="100"/>
|
||||||
|
<UserString key="SettingType" value="Slider"/>
|
||||||
|
<UserString key="SettingCategory" value="Shaders"/>
|
||||||
|
<UserString key="SettingName" value="minimum interior brightness"/>
|
||||||
|
<UserString key="SettingValueType" value="Float"/>
|
||||||
|
<UserString key="SettingLabelWidget" value="MinimumBrightnessText"/>
|
||||||
|
<UserString key="SettingLabelCaption" value="Minimum Interior Brightness (%s)"/>
|
||||||
|
</Widget>
|
||||||
|
<Widget type="AutoSizedButton" skin="MW_Button" position="0 290 0 0" align="Top Left" name="LightsResetButton">
|
||||||
|
<Property key="Caption" value="Reset To Defaults"/>
|
||||||
|
</Widget>
|
||||||
</Widget>
|
</Widget>
|
||||||
<Widget type="ComboBox" skin="MW_ComboBox" position="0 28 170 24" align="Left Top" name="LightingMethodButton">
|
|
||||||
<Property key="AddItem" value="legacy"/>
|
|
||||||
<Property key="AddItem" value="shaders compatibility"/>
|
|
||||||
<Property key="AddItem" value="shaders"/>
|
|
||||||
</Widget>
|
</Widget>
|
||||||
<!-- Max Lights -->
|
|
||||||
<Widget type="TextBox" skin="NormalText" position="178 4 160 18" align="Left Top" name="MaxLightsText"/>
|
|
||||||
<Widget type="ScrollBar" skin="MW_HScroll" position="178 30 160 18" align="Right Top HStretch" name="MaxLightsSlider">
|
|
||||||
<Property key="Range" value="24"/>
|
|
||||||
<Property key="Page" value="1"/>
|
|
||||||
<UserString key="SettingType" value="Slider"/>
|
|
||||||
<UserString key="SettingMin" value="8"/>
|
|
||||||
<UserString key="SettingMax" value="32"/>
|
|
||||||
<UserString key="SettingCategory" value="Shaders"/>
|
|
||||||
<UserString key="SettingName" value="max lights"/>
|
|
||||||
<UserString key="SettingValueType" value="Integer"/>
|
|
||||||
<UserString key="SettingLabelWidget" value="MaxLightsText"/>
|
|
||||||
<UserString key="SettingLabelCaption" value="*Max Lights (%s)"/>
|
|
||||||
</Widget>
|
|
||||||
<Widget type="ImageBox" skin="MW_HLine" position="0 54 360 18" align="Top HStretch"/>
|
|
||||||
<!-- Light Fade Start -->
|
|
||||||
<Widget type="TextBox" skin="NormalText" position="0 78 352 18" align="Left Top" name="MaxLightDistanceText"/>
|
|
||||||
<Widget type="ScrollBar" skin="MW_HScroll" position="0 104 352 18" align="HStretch Top">
|
|
||||||
<Property key="Range" value="8192"/>
|
|
||||||
<Property key="Page" value="1"/>
|
|
||||||
<UserString key="SettingType" value="Slider"/>
|
|
||||||
<UserString key="SettingMin" value="0"/>
|
|
||||||
<UserString key="SettingMax" value="8192"/>
|
|
||||||
<UserString key="SettingCategory" value="Shaders"/>
|
|
||||||
<UserString key="SettingName" value="maximum light distance"/>
|
|
||||||
<UserString key="SettingValueType" value="Integer"/>
|
|
||||||
<UserString key="SettingLabelWidget" value="MaxLightDistanceText"/>
|
|
||||||
<UserString key="SettingLabelCaption" value="Maximum Light Distance (%s)"/>
|
|
||||||
</Widget>
|
|
||||||
<!-- Light Fade Multiplier -->
|
|
||||||
<Widget type="TextBox" skin="NormalText" position="0 128 352 18" align="Left Top" name="LightFadeMultiplierText"/>
|
|
||||||
<Widget type="ScrollBar" skin="MW_HScroll" position="0 152 352 18" align="HStretch Top">
|
|
||||||
<Property key="Range" value="10000"/>
|
|
||||||
<Property key="Page" value="300"/>
|
|
||||||
<UserString key="SettingType" value="Slider"/>
|
|
||||||
<UserString key="SettingCategory" value="Shaders"/>
|
|
||||||
<UserString key="SettingName" value="light fade start"/>
|
|
||||||
<UserString key="SettingValueType" value="Float"/>
|
|
||||||
<UserString key="SettingLabelWidget" value="LightFadeMultiplierText"/>
|
|
||||||
<UserString key="SettingLabelCaption" value="Fade Start Multiplier (%s)"/>
|
|
||||||
</Widget>
|
|
||||||
<!-- Bounding Sphere Multiplier -->
|
|
||||||
<Widget type="TextBox" skin="NormalText" position="0 176 352 18" align="Left Top" name="BoundingSphereMultText"/>
|
|
||||||
<Widget type="ScrollBar" skin="MW_HScroll" position="0 200 352 18" align="HStretch Top">
|
|
||||||
<Property key="Range" value="10000"/>
|
|
||||||
<Property key="Page" value="300"/>
|
|
||||||
<UserString key="SettingType" value="Slider"/>
|
|
||||||
<UserString key="SettingMin" value="0.1"/>
|
|
||||||
<UserString key="SettingMax" value="5.0"/>
|
|
||||||
<UserString key="SettingCategory" value="Shaders"/>
|
|
||||||
<UserString key="SettingName" value="light bounds multiplier"/>
|
|
||||||
<UserString key="SettingValueType" value="Float"/>
|
|
||||||
<UserString key="SettingLabelWidget" value="BoundingSphereMultText"/>
|
|
||||||
<UserString key="SettingLabelCaption" value="Bounding Sphere Multiplier (%s)"/>
|
|
||||||
</Widget>
|
|
||||||
<!-- Minimum Ambient Brightness -->
|
|
||||||
<Widget type="TextBox" skin="NormalText" position="0 224 352 18" align="Left Top" name="MinimumBrightnessText"/>
|
|
||||||
<Widget type="ScrollBar" skin="MW_HScroll" position="0 248 352 18" align="HStretch Top">
|
|
||||||
<Property key="Range" value="10000"/>
|
|
||||||
<Property key="Page" value="300"/>
|
|
||||||
<UserString key="SettingType" value="Slider"/>
|
|
||||||
<UserString key="SettingCategory" value="Shaders"/>
|
|
||||||
<UserString key="SettingName" value="minimum interior brightness"/>
|
|
||||||
<UserString key="SettingValueType" value="Float"/>
|
|
||||||
<UserString key="SettingLabelWidget" value="MinimumBrightnessText"/>
|
|
||||||
<UserString key="SettingLabelCaption" value="Minimum Interior Brightness (%s)"/>
|
|
||||||
</Widget>
|
|
||||||
|
|
||||||
<Widget type="AutoSizedButton" skin="MW_Button" position="0 308 0 0" align="Bottom Left" name="LightsResetButton">
|
|
||||||
<Property key="Caption" value="Reset To Defaults"/>
|
|
||||||
</Widget>
|
|
||||||
<Widget type="AutoSizedTextBox" skin="NormalText" position="210 308 0 0" align="Bottom Right HStretch">
|
|
||||||
<Property key="Caption" value="(*) Requires Restart"/>
|
|
||||||
<Property key="TextAlign" value="Right"/>
|
|
||||||
</Widget>
|
|
||||||
|
|
||||||
</Widget>
|
</Widget>
|
||||||
<!--
|
<!--
|
||||||
<Widget type="TabItem" skin="" position="0 28 352 268">
|
<Widget type="TabItem" skin="" position="0 28 352 268">
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#define LIGHTING_MODEL_FFP 0
|
#define LIGHTING_MODEL_FFP 0
|
||||||
#define LIGHTING_MODEL_SINGLE_UBO 1
|
#define LIGHTING_MODEL_PER_OBJECT_UNIFORM 1
|
||||||
#define LIGHTING_MODEL_PER_OBJECT_UNIFORM 2
|
#define LIGHTING_MODEL_SINGLE_UBO 2
|
||||||
|
|
||||||
#if @lightingModel != LIGHTING_MODEL_FFP
|
#if @lightingModel != LIGHTING_MODEL_FFP
|
||||||
#define getLight LightBuffer
|
#define getLight LightBuffer
|
||||||
|
@ -35,7 +35,7 @@ vec4 unpackRGBA(int data)
|
||||||
|
|
||||||
/* Layout:
|
/* Layout:
|
||||||
packedColors: 8-bit unsigned RGB packed as (diffuse, ambient, specular).
|
packedColors: 8-bit unsigned RGB packed as (diffuse, ambient, specular).
|
||||||
sign bit is stored in diffuse alpha component
|
sign bit is stored in unused alpha component
|
||||||
attenuation: constant, linear, quadratic, light radius (as defined in content)
|
attenuation: constant, linear, quadratic, light radius (as defined in content)
|
||||||
*/
|
*/
|
||||||
struct LightData
|
struct LightData
|
||||||
|
@ -138,10 +138,12 @@ void perLightPoint(out vec3 ambientOut, out vec3 diffuseOut, int lightIndex, vec
|
||||||
#if @lightingModel == LIGHTING_MODEL_PER_OBJECT_UNIFORM
|
#if @lightingModel == LIGHTING_MODEL_PER_OBJECT_UNIFORM
|
||||||
float illumination = clamp(1.0 / (getLight[lightIndex][0].w + getLight[lightIndex][1].w * lightDistance + getLight[lightIndex][2].w * lightDistance * lightDistance), 0.0, 1.0);
|
float illumination = clamp(1.0 / (getLight[lightIndex][0].w + getLight[lightIndex][1].w * lightDistance + getLight[lightIndex][2].w * lightDistance * lightDistance), 0.0, 1.0);
|
||||||
illumination *= 1.0 - quickstep((lightDistance / radius) - 1.0);
|
illumination *= 1.0 - quickstep((lightDistance / radius) - 1.0);
|
||||||
|
|
||||||
ambientOut = getLight[lightIndex][1].xyz * illumination;
|
ambientOut = getLight[lightIndex][1].xyz * illumination;
|
||||||
#elif @lightingModel == LIGHTING_MODEL_SINGLE_UBO
|
#elif @lightingModel == LIGHTING_MODEL_SINGLE_UBO
|
||||||
float illumination = clamp(1.0 / (getLight[lightIndex].attenuation.x + getLight[lightIndex].attenuation.y * lightDistance + getLight[lightIndex].attenuation.z * lightDistance * lightDistance), 0.0, 1.0);
|
float illumination = clamp(1.0 / (getLight[lightIndex].attenuation.x + getLight[lightIndex].attenuation.y * lightDistance + getLight[lightIndex].attenuation.z * lightDistance * lightDistance), 0.0, 1.0);
|
||||||
illumination *= 1.0 - quickstep((lightDistance / radius) - 1.0);
|
illumination *= 1.0 - quickstep((lightDistance / radius) - 1.0);
|
||||||
|
|
||||||
ivec4 data = getLight[lightIndex].packedColors;
|
ivec4 data = getLight[lightIndex].packedColors;
|
||||||
ambientOut = unpackRGB(data.y) * illumination;
|
ambientOut = unpackRGB(data.y) * illumination;
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -273,6 +273,36 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="6" column="1">
|
||||||
|
<layout class="QHBoxLayout" name="lightingMethodLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lightingMethodLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Lighting Method:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="lightingMethodComboBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>legacy</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>shaders compatibility</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>shaders</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="QCheckBox" name="smoothMovementCheckBox">
|
<widget class="QCheckBox" name="smoothMovementCheckBox">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
|
|
Loading…
Reference in a new issue