mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 16:29:55 +00:00
Merge branch 'settings_values_fog' into 'master'
Use settings values for Fog settings (#6876) See merge request OpenMW/openmw!3141
This commit is contained in:
commit
6ce072671e
7 changed files with 41 additions and 43 deletions
|
@ -7,20 +7,10 @@
|
|||
#include <components/esm4/loadcell.hpp>
|
||||
#include <components/fallback/fallback.hpp>
|
||||
#include <components/sceneutil/util.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include <apps/openmw/mwworld/cell.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
float DLLandFogStart;
|
||||
float DLLandFogEnd;
|
||||
float DLUnderwaterFogStart;
|
||||
float DLUnderwaterFogEnd;
|
||||
float DLInteriorFogStart;
|
||||
float DLInteriorFogEnd;
|
||||
}
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
FogManager::FogManager()
|
||||
|
@ -29,17 +19,10 @@ namespace MWRender
|
|||
, mUnderwaterFogStart(0.f)
|
||||
, mUnderwaterFogEnd(std::numeric_limits<float>::max())
|
||||
, mFogColor(osg::Vec4f())
|
||||
, mDistantFog(Settings::Manager::getBool("use distant fog", "Fog"))
|
||||
, mUnderwaterColor(Fallback::Map::getColour("Water_UnderwaterColor"))
|
||||
, mUnderwaterWeight(Fallback::Map::getFloat("Water_UnderwaterColorWeight"))
|
||||
, 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)
|
||||
|
@ -47,13 +30,14 @@ namespace MWRender
|
|||
osg::Vec4f color = SceneUtil::colourFromRGB(cell.getMood().mFogColor);
|
||||
|
||||
const float fogDensity = cell.getMood().mFogDensity;
|
||||
if (mDistantFog)
|
||||
if (Settings::fog().mUseDistantFog)
|
||||
{
|
||||
float density = std::max(0.2f, fogDensity);
|
||||
mLandFogStart = DLInteriorFogEnd * (1.0f - density) + DLInteriorFogStart * density;
|
||||
mLandFogEnd = DLInteriorFogEnd;
|
||||
mUnderwaterFogStart = DLUnderwaterFogStart;
|
||||
mUnderwaterFogEnd = DLUnderwaterFogEnd;
|
||||
mLandFogStart = Settings::fog().mDistantInteriorFogEnd * (1.0f - density)
|
||||
+ Settings::fog().mDistantInteriorFogStart * density;
|
||||
mLandFogEnd = Settings::fog().mDistantInteriorFogEnd;
|
||||
mUnderwaterFogStart = Settings::fog().mDistantUnderwaterFogStart;
|
||||
mUnderwaterFogEnd = Settings::fog().mDistantUnderwaterFogEnd;
|
||||
mFogColor = color;
|
||||
}
|
||||
else
|
||||
|
@ -63,12 +47,13 @@ namespace MWRender
|
|||
void FogManager::configure(float viewDistance, float fogDepth, float underwaterFog, float dlFactor, float dlOffset,
|
||||
const osg::Vec4f& color)
|
||||
{
|
||||
if (mDistantFog)
|
||||
if (Settings::fog().mUseDistantFog)
|
||||
{
|
||||
mLandFogStart = dlFactor * (DLLandFogStart - dlOffset * DLLandFogEnd);
|
||||
mLandFogEnd = dlFactor * (1.0f - dlOffset) * DLLandFogEnd;
|
||||
mUnderwaterFogStart = DLUnderwaterFogStart;
|
||||
mUnderwaterFogEnd = DLUnderwaterFogEnd;
|
||||
mLandFogStart
|
||||
= dlFactor * (Settings::fog().mDistantLandFogStart - dlOffset * Settings::fog().mDistantLandFogEnd);
|
||||
mLandFogEnd = dlFactor * (1.0f - dlOffset) * Settings::fog().mDistantLandFogEnd;
|
||||
mUnderwaterFogStart = Settings::fog().mDistantUnderwaterFogStart;
|
||||
mUnderwaterFogEnd = Settings::fog().mDistantUnderwaterFogEnd;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -29,8 +29,6 @@ namespace MWRender
|
|||
float mUnderwaterFogStart;
|
||||
float mUnderwaterFogEnd;
|
||||
osg::Vec4f mFogColor;
|
||||
bool mDistantFog;
|
||||
|
||||
osg::Vec4f mUnderwaterColor;
|
||||
float mUnderwaterWeight;
|
||||
float mUnderwaterIndoorFog;
|
||||
|
|
|
@ -159,7 +159,7 @@ namespace MWRender
|
|||
: mNear(0.f)
|
||||
, mFar(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,
|
||||
DetourNavigator::Navigator& navigator, const MWWorld::GroundcoverStore& groundcoverStore,
|
||||
SceneUtil::UnrefQueue& unrefQueue)
|
||||
: mSkyBlending(Settings::Manager::getBool("sky blending", "Fog"))
|
||||
: mSkyBlending(Settings::fog().mSkyBlending)
|
||||
, mViewer(viewer)
|
||||
, mRootNode(rootNode)
|
||||
, mResourceSystem(resourceSystem)
|
||||
|
@ -330,8 +330,7 @@ namespace MWRender
|
|||
|
||||
resourceSystem->getSceneManager()->setParticleSystemMask(MWRender::Mask_ParticleSystem);
|
||||
// Shadows and radial fog have problems with fixed-function mode.
|
||||
bool forceShaders = Settings::Manager::getBool("radial fog", "Fog")
|
||||
|| Settings::Manager::getBool("exponential fog", "Fog")
|
||||
bool forceShaders = Settings::fog().mRadialFog || Settings::fog().mExponentialFog
|
||||
|| Settings::Manager::getBool("soft particles", "Shaders")
|
||||
|| Settings::Manager::getBool("force shaders", "Shaders")
|
||||
|| Settings::Manager::getBool("enable shadows", "Shadows")
|
||||
|
@ -401,8 +400,8 @@ namespace MWRender
|
|||
globalDefines["clamp"] = Settings::Manager::getBool("clamp lighting", "Shaders") ? "1" : "0";
|
||||
globalDefines["preLightEnv"]
|
||||
= Settings::Manager::getBool("apply lighting to environment maps", "Shaders") ? "1" : "0";
|
||||
bool exponentialFog = Settings::Manager::getBool("exponential fog", "Fog");
|
||||
globalDefines["radialFog"] = (exponentialFog || Settings::Manager::getBool("radial fog", "Fog")) ? "1" : "0";
|
||||
const bool exponentialFog = Settings::fog().mExponentialFog;
|
||||
globalDefines["radialFog"] = (exponentialFog || Settings::fog().mRadialFog) ? "1" : "0";
|
||||
globalDefines["exponentialFog"] = exponentialFog ? "1" : "0";
|
||||
globalDefines["skyBlending"] = mSkyBlending ? "1" : "0";
|
||||
globalDefines["refraction_enabled"] = "0";
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <osgParticle/Operator>
|
||||
#include <osgParticle/ParticleSystemUpdater>
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
|
||||
#include <components/sceneutil/controller.hpp>
|
||||
#include <components/sceneutil/depth.hpp>
|
||||
|
@ -279,7 +279,7 @@ namespace MWRender
|
|||
|
||||
if (enableSkyRTT)
|
||||
{
|
||||
mSkyRTT = new SkyRTT(Settings::Manager::getVector2("sky rtt resolution", "Fog"), mEarlyRenderBinRoot);
|
||||
mSkyRTT = new SkyRTT(Settings::fog().mSkyRttResolution, mEarlyRenderBinRoot);
|
||||
skyroot->addChild(mSkyRTT);
|
||||
mRootNode = new osg::Group;
|
||||
skyroot->addChild(mRootNode);
|
||||
|
|
|
@ -101,9 +101,6 @@ namespace
|
|||
}))
|
||||
, 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)
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include "components/misc/strings/conversion.hpp"
|
||||
#include "components/settings/parser.hpp"
|
||||
#include "components/settings/values.hpp"
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#ifdef WIN32
|
||||
// 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
|
||||
|
@ -9,6 +15,18 @@ int main(int argc, char** argv)
|
|||
GTEST_API_ int main(int argc, char** argv)
|
||||
{
|
||||
#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);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <components/resource/scenemanager.hpp>
|
||||
#include <components/sceneutil/clearcolor.hpp>
|
||||
#include <components/sceneutil/lightmanager.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
#include <components/stereo/multiview.hpp>
|
||||
|
||||
#include "stateupdater.hpp"
|
||||
|
@ -261,8 +262,8 @@ float omw_EstimateFogCoverageFromUV(vec2 uv)
|
|||
{ "@uboStruct", StateUpdater::getStructDefinition() }, { "@ubo", mUBO ? "1" : "0" },
|
||||
{ "@normals", technique.getNormals() ? "1" : "0" },
|
||||
{ "@reverseZ", SceneUtil::AutoDepth::isReversed() ? "1" : "0" },
|
||||
{ "@radialFog", Settings::Manager::getBool("radial fog", "Fog") ? "1" : "0" },
|
||||
{ "@exponentialFog", Settings::Manager::getBool("exponential fog", "Fog") ? "1" : "0" },
|
||||
{ "@radialFog", Settings::fog().mRadialFog ? "1" : "0" },
|
||||
{ "@exponentialFog", Settings::fog().mExponentialFog ? "1" : "0" },
|
||||
{ "@hdr", technique.getHDR() ? "1" : "0" }, { "@in", mLegacyGLSL ? "varying" : "in" },
|
||||
{ "@out", mLegacyGLSL ? "varying" : "out" }, { "@position", "gl_Position" },
|
||||
{ "@texture1D", mLegacyGLSL ? "texture1D" : "texture" },
|
||||
|
|
Loading…
Reference in a new issue