mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-22 03:40:49 +00:00
Use settings values for Fog settings
This commit is contained in:
parent
1630e04d1b
commit
04215ca9ec
@ -7,20 +7,10 @@
|
|||||||
#include <components/esm4/loadcell.hpp>
|
#include <components/esm4/loadcell.hpp>
|
||||||
#include <components/fallback/fallback.hpp>
|
#include <components/fallback/fallback.hpp>
|
||||||
#include <components/sceneutil/util.hpp>
|
#include <components/sceneutil/util.hpp>
|
||||||
#include <components/settings/settings.hpp>
|
#include <components/settings/values.hpp>
|
||||||
|
|
||||||
#include <apps/openmw/mwworld/cell.hpp>
|
#include <apps/openmw/mwworld/cell.hpp>
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
float DLLandFogStart;
|
|
||||||
float DLLandFogEnd;
|
|
||||||
float DLUnderwaterFogStart;
|
|
||||||
float DLUnderwaterFogEnd;
|
|
||||||
float DLInteriorFogStart;
|
|
||||||
float DLInteriorFogEnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
FogManager::FogManager()
|
FogManager::FogManager()
|
||||||
@ -29,17 +19,10 @@ namespace MWRender
|
|||||||
, mUnderwaterFogStart(0.f)
|
, mUnderwaterFogStart(0.f)
|
||||||
, mUnderwaterFogEnd(std::numeric_limits<float>::max())
|
, mUnderwaterFogEnd(std::numeric_limits<float>::max())
|
||||||
, mFogColor(osg::Vec4f())
|
, mFogColor(osg::Vec4f())
|
||||||
, mDistantFog(Settings::Manager::getBool("use distant fog", "Fog"))
|
|
||||||
, mUnderwaterColor(Fallback::Map::getColour("Water_UnderwaterColor"))
|
, mUnderwaterColor(Fallback::Map::getColour("Water_UnderwaterColor"))
|
||||||
, mUnderwaterWeight(Fallback::Map::getFloat("Water_UnderwaterColorWeight"))
|
, mUnderwaterWeight(Fallback::Map::getFloat("Water_UnderwaterColorWeight"))
|
||||||
, mUnderwaterIndoorFog(Fallback::Map::getFloat("Water_UnderwaterIndoorFog"))
|
, mUnderwaterIndoorFog(Fallback::Map::getFloat("Water_UnderwaterIndoorFog"))
|
||||||
{
|
{
|
||||||
DLLandFogStart = Settings::Manager::getFloat("distant land fog start", "Fog");
|
|
||||||
DLLandFogEnd = Settings::Manager::getFloat("distant land fog end", "Fog");
|
|
||||||
DLUnderwaterFogStart = Settings::Manager::getFloat("distant underwater fog start", "Fog");
|
|
||||||
DLUnderwaterFogEnd = Settings::Manager::getFloat("distant underwater fog end", "Fog");
|
|
||||||
DLInteriorFogStart = Settings::Manager::getFloat("distant interior fog start", "Fog");
|
|
||||||
DLInteriorFogEnd = Settings::Manager::getFloat("distant interior fog end", "Fog");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FogManager::configure(float viewDistance, const MWWorld::Cell& cell)
|
void FogManager::configure(float viewDistance, const MWWorld::Cell& cell)
|
||||||
@ -47,13 +30,14 @@ namespace MWRender
|
|||||||
osg::Vec4f color = SceneUtil::colourFromRGB(cell.getMood().mFogColor);
|
osg::Vec4f color = SceneUtil::colourFromRGB(cell.getMood().mFogColor);
|
||||||
|
|
||||||
const float fogDensity = cell.getMood().mFogDensity;
|
const float fogDensity = cell.getMood().mFogDensity;
|
||||||
if (mDistantFog)
|
if (Settings::fog().mUseDistantFog)
|
||||||
{
|
{
|
||||||
float density = std::max(0.2f, fogDensity);
|
float density = std::max(0.2f, fogDensity);
|
||||||
mLandFogStart = DLInteriorFogEnd * (1.0f - density) + DLInteriorFogStart * density;
|
mLandFogStart = Settings::fog().mDistantInteriorFogEnd * (1.0f - density)
|
||||||
mLandFogEnd = DLInteriorFogEnd;
|
+ Settings::fog().mDistantInteriorFogStart * density;
|
||||||
mUnderwaterFogStart = DLUnderwaterFogStart;
|
mLandFogEnd = Settings::fog().mDistantInteriorFogEnd;
|
||||||
mUnderwaterFogEnd = DLUnderwaterFogEnd;
|
mUnderwaterFogStart = Settings::fog().mDistantUnderwaterFogStart;
|
||||||
|
mUnderwaterFogEnd = Settings::fog().mDistantUnderwaterFogEnd;
|
||||||
mFogColor = color;
|
mFogColor = color;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -63,12 +47,13 @@ namespace MWRender
|
|||||||
void FogManager::configure(float viewDistance, float fogDepth, float underwaterFog, float dlFactor, float dlOffset,
|
void FogManager::configure(float viewDistance, float fogDepth, float underwaterFog, float dlFactor, float dlOffset,
|
||||||
const osg::Vec4f& color)
|
const osg::Vec4f& color)
|
||||||
{
|
{
|
||||||
if (mDistantFog)
|
if (Settings::fog().mUseDistantFog)
|
||||||
{
|
{
|
||||||
mLandFogStart = dlFactor * (DLLandFogStart - dlOffset * DLLandFogEnd);
|
mLandFogStart
|
||||||
mLandFogEnd = dlFactor * (1.0f - dlOffset) * DLLandFogEnd;
|
= dlFactor * (Settings::fog().mDistantLandFogStart - dlOffset * Settings::fog().mDistantLandFogEnd);
|
||||||
mUnderwaterFogStart = DLUnderwaterFogStart;
|
mLandFogEnd = dlFactor * (1.0f - dlOffset) * Settings::fog().mDistantLandFogEnd;
|
||||||
mUnderwaterFogEnd = DLUnderwaterFogEnd;
|
mUnderwaterFogStart = Settings::fog().mDistantUnderwaterFogStart;
|
||||||
|
mUnderwaterFogEnd = Settings::fog().mDistantUnderwaterFogEnd;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -29,8 +29,6 @@ namespace MWRender
|
|||||||
float mUnderwaterFogStart;
|
float mUnderwaterFogStart;
|
||||||
float mUnderwaterFogEnd;
|
float mUnderwaterFogEnd;
|
||||||
osg::Vec4f mFogColor;
|
osg::Vec4f mFogColor;
|
||||||
bool mDistantFog;
|
|
||||||
|
|
||||||
osg::Vec4f mUnderwaterColor;
|
osg::Vec4f mUnderwaterColor;
|
||||||
float mUnderwaterWeight;
|
float mUnderwaterWeight;
|
||||||
float mUnderwaterIndoorFog;
|
float mUnderwaterIndoorFog;
|
||||||
|
@ -159,7 +159,7 @@ namespace MWRender
|
|||||||
: mNear(0.f)
|
: mNear(0.f)
|
||||||
, mFar(0.f)
|
, mFar(0.f)
|
||||||
, mWindSpeed(0.f)
|
, mWindSpeed(0.f)
|
||||||
, mSkyBlendingStartCoef(Settings::Manager::getFloat("sky blending start", "Fog"))
|
, mSkyBlendingStartCoef(Settings::fog().mSkyBlendingStart)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,7 +306,7 @@ namespace MWRender
|
|||||||
Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue,
|
Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue,
|
||||||
DetourNavigator::Navigator& navigator, const MWWorld::GroundcoverStore& groundcoverStore,
|
DetourNavigator::Navigator& navigator, const MWWorld::GroundcoverStore& groundcoverStore,
|
||||||
SceneUtil::UnrefQueue& unrefQueue)
|
SceneUtil::UnrefQueue& unrefQueue)
|
||||||
: mSkyBlending(Settings::Manager::getBool("sky blending", "Fog"))
|
: mSkyBlending(Settings::fog().mSkyBlending)
|
||||||
, mViewer(viewer)
|
, mViewer(viewer)
|
||||||
, mRootNode(rootNode)
|
, mRootNode(rootNode)
|
||||||
, mResourceSystem(resourceSystem)
|
, mResourceSystem(resourceSystem)
|
||||||
@ -330,8 +330,7 @@ namespace MWRender
|
|||||||
|
|
||||||
resourceSystem->getSceneManager()->setParticleSystemMask(MWRender::Mask_ParticleSystem);
|
resourceSystem->getSceneManager()->setParticleSystemMask(MWRender::Mask_ParticleSystem);
|
||||||
// Shadows and radial fog have problems with fixed-function mode.
|
// Shadows and radial fog have problems with fixed-function mode.
|
||||||
bool forceShaders = Settings::Manager::getBool("radial fog", "Fog")
|
bool forceShaders = Settings::fog().mRadialFog || Settings::fog().mExponentialFog
|
||||||
|| Settings::Manager::getBool("exponential fog", "Fog")
|
|
||||||
|| Settings::Manager::getBool("soft particles", "Shaders")
|
|| Settings::Manager::getBool("soft particles", "Shaders")
|
||||||
|| Settings::Manager::getBool("force shaders", "Shaders")
|
|| Settings::Manager::getBool("force shaders", "Shaders")
|
||||||
|| Settings::Manager::getBool("enable shadows", "Shadows")
|
|| Settings::Manager::getBool("enable shadows", "Shadows")
|
||||||
@ -401,8 +400,8 @@ namespace MWRender
|
|||||||
globalDefines["clamp"] = Settings::Manager::getBool("clamp lighting", "Shaders") ? "1" : "0";
|
globalDefines["clamp"] = Settings::Manager::getBool("clamp lighting", "Shaders") ? "1" : "0";
|
||||||
globalDefines["preLightEnv"]
|
globalDefines["preLightEnv"]
|
||||||
= Settings::Manager::getBool("apply lighting to environment maps", "Shaders") ? "1" : "0";
|
= Settings::Manager::getBool("apply lighting to environment maps", "Shaders") ? "1" : "0";
|
||||||
bool exponentialFog = Settings::Manager::getBool("exponential fog", "Fog");
|
const bool exponentialFog = Settings::fog().mExponentialFog;
|
||||||
globalDefines["radialFog"] = (exponentialFog || Settings::Manager::getBool("radial fog", "Fog")) ? "1" : "0";
|
globalDefines["radialFog"] = (exponentialFog || Settings::fog().mRadialFog) ? "1" : "0";
|
||||||
globalDefines["exponentialFog"] = exponentialFog ? "1" : "0";
|
globalDefines["exponentialFog"] = exponentialFog ? "1" : "0";
|
||||||
globalDefines["skyBlending"] = mSkyBlending ? "1" : "0";
|
globalDefines["skyBlending"] = mSkyBlending ? "1" : "0";
|
||||||
globalDefines["refraction_enabled"] = "0";
|
globalDefines["refraction_enabled"] = "0";
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <osgParticle/Operator>
|
#include <osgParticle/Operator>
|
||||||
#include <osgParticle/ParticleSystemUpdater>
|
#include <osgParticle/ParticleSystemUpdater>
|
||||||
|
|
||||||
#include <components/settings/settings.hpp>
|
#include <components/settings/values.hpp>
|
||||||
|
|
||||||
#include <components/sceneutil/controller.hpp>
|
#include <components/sceneutil/controller.hpp>
|
||||||
#include <components/sceneutil/depth.hpp>
|
#include <components/sceneutil/depth.hpp>
|
||||||
@ -279,7 +279,7 @@ namespace MWRender
|
|||||||
|
|
||||||
if (enableSkyRTT)
|
if (enableSkyRTT)
|
||||||
{
|
{
|
||||||
mSkyRTT = new SkyRTT(Settings::Manager::getVector2("sky rtt resolution", "Fog"), mEarlyRenderBinRoot);
|
mSkyRTT = new SkyRTT(Settings::fog().mSkyRttResolution, mEarlyRenderBinRoot);
|
||||||
skyroot->addChild(mSkyRTT);
|
skyroot->addChild(mSkyRTT);
|
||||||
mRootNode = new osg::Group;
|
mRootNode = new osg::Group;
|
||||||
skyroot->addChild(mRootNode);
|
skyroot->addChild(mRootNode);
|
||||||
|
@ -101,9 +101,6 @@ namespace
|
|||||||
}))
|
}))
|
||||||
, mImageManager(mVFS.get())
|
, mImageManager(mVFS.get())
|
||||||
{
|
{
|
||||||
Settings::Manager::setBool("radial fog", "Fog", true);
|
|
||||||
Settings::Manager::setBool("exponential fog", "Fog", false);
|
|
||||||
Settings::Manager::setBool("stereo enabled", "Stereo", false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void compile(const std::string& name)
|
void compile(const std::string& name)
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include "components/misc/strings/conversion.hpp"
|
||||||
|
#include "components/settings/parser.hpp"
|
||||||
|
#include "components/settings/values.hpp"
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
// we cannot use GTEST_API_ before main if we're building standalone exe application,
|
// we cannot use GTEST_API_ before main if we're building standalone exe application,
|
||||||
// and we're linking GoogleTest / GoogleMock as DLLs and not linking gtest_main / gmock_main
|
// and we're linking GoogleTest / GoogleMock as DLLs and not linking gtest_main / gmock_main
|
||||||
@ -9,6 +15,18 @@ int main(int argc, char** argv)
|
|||||||
GTEST_API_ int main(int argc, char** argv)
|
GTEST_API_ int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
const std::filesystem::path settingsDefaultPath = std::filesystem::path{ OPENMW_PROJECT_SOURCE_DIR } / "files"
|
||||||
|
/ Misc::StringUtils::stringToU8String("settings-default.cfg");
|
||||||
|
|
||||||
|
Settings::SettingsFileParser parser;
|
||||||
|
parser.loadSettingsFile(settingsDefaultPath, Settings::Manager::mDefaultSettings);
|
||||||
|
|
||||||
|
Settings::StaticValues::initDefaults();
|
||||||
|
|
||||||
|
Settings::Manager::mUserSettings = Settings::Manager::mDefaultSettings;
|
||||||
|
|
||||||
|
Settings::StaticValues::init();
|
||||||
|
|
||||||
testing::InitGoogleTest(&argc, argv);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <components/resource/scenemanager.hpp>
|
#include <components/resource/scenemanager.hpp>
|
||||||
#include <components/sceneutil/clearcolor.hpp>
|
#include <components/sceneutil/clearcolor.hpp>
|
||||||
#include <components/sceneutil/lightmanager.hpp>
|
#include <components/sceneutil/lightmanager.hpp>
|
||||||
|
#include <components/settings/values.hpp>
|
||||||
#include <components/stereo/multiview.hpp>
|
#include <components/stereo/multiview.hpp>
|
||||||
|
|
||||||
#include "stateupdater.hpp"
|
#include "stateupdater.hpp"
|
||||||
@ -261,8 +262,8 @@ float omw_EstimateFogCoverageFromUV(vec2 uv)
|
|||||||
{ "@uboStruct", StateUpdater::getStructDefinition() }, { "@ubo", mUBO ? "1" : "0" },
|
{ "@uboStruct", StateUpdater::getStructDefinition() }, { "@ubo", mUBO ? "1" : "0" },
|
||||||
{ "@normals", technique.getNormals() ? "1" : "0" },
|
{ "@normals", technique.getNormals() ? "1" : "0" },
|
||||||
{ "@reverseZ", SceneUtil::AutoDepth::isReversed() ? "1" : "0" },
|
{ "@reverseZ", SceneUtil::AutoDepth::isReversed() ? "1" : "0" },
|
||||||
{ "@radialFog", Settings::Manager::getBool("radial fog", "Fog") ? "1" : "0" },
|
{ "@radialFog", Settings::fog().mRadialFog ? "1" : "0" },
|
||||||
{ "@exponentialFog", Settings::Manager::getBool("exponential fog", "Fog") ? "1" : "0" },
|
{ "@exponentialFog", Settings::fog().mExponentialFog ? "1" : "0" },
|
||||||
{ "@hdr", technique.getHDR() ? "1" : "0" }, { "@in", mLegacyGLSL ? "varying" : "in" },
|
{ "@hdr", technique.getHDR() ? "1" : "0" }, { "@in", mLegacyGLSL ? "varying" : "in" },
|
||||||
{ "@out", mLegacyGLSL ? "varying" : "out" }, { "@position", "gl_Position" },
|
{ "@out", mLegacyGLSL ? "varying" : "out" }, { "@position", "gl_Position" },
|
||||||
{ "@texture1D", mLegacyGLSL ? "texture1D" : "texture" },
|
{ "@texture1D", mLegacyGLSL ? "texture1D" : "texture" },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user