Merge pull request #1473

0.6.3
scrawl 7 years ago
commit 0982d2175a
No known key found for this signature in database
GPG Key ID: 2E6CC3676024C402

@ -51,6 +51,16 @@
#include "terrainstorage.hpp"
#include "util.hpp"
namespace
{
float DLLandFogStart;
float DLLandFogEnd;
float DLUnderwaterFogStart;
float DLUnderwaterFogEnd;
float DLInteriorFogStart;
float DLInteriorFogEnd;
}
namespace MWRender
{
@ -173,14 +183,18 @@ namespace MWRender
, mResourceSystem(resourceSystem)
, mWorkQueue(workQueue)
, mUnrefQueue(new SceneUtil::UnrefQueue)
, mFogDepth(0.f)
, mLandFogStart(0.f)
, mLandFogEnd(std::numeric_limits<float>::max())
, mUnderwaterFogStart(0.f)
, mUnderwaterFogEnd(std::numeric_limits<float>::max())
, mUnderwaterColor(fallback->getFallbackColour("Water_UnderwaterColor"))
, mUnderwaterWeight(fallback->getFallbackFloat("Water_UnderwaterColorWeight"))
, mUnderwaterFog(0.f)
, mUnderwaterIndoorFog(fallback->getFallbackFloat("Water_UnderwaterIndoorFog"))
, mNightEyeFactor(0.f)
, mFieldOfViewOverride(0.f)
, mDistantFog(false)
, mDistantTerrain(false)
, mFieldOfViewOverridden(false)
, mFieldOfViewOverride(0.f)
{
resourceSystem->getSceneManager()->setParticleSystemMask(MWRender::Mask_ParticleSystem);
resourceSystem->getSceneManager()->setShaderPath(resourcePath + "/shaders");
@ -216,12 +230,20 @@ namespace MWRender
mWater.reset(new Water(mRootNode, sceneRoot, mResourceSystem, mViewer->getIncrementalCompileOperation(), fallback, resourcePath));
const bool distantTerrain = Settings::Manager::getBool("distant terrain", "Terrain");
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");
mDistantFog = Settings::Manager::getBool("use distant fog", "Fog");
mDistantTerrain = Settings::Manager::getBool("distant terrain", "Terrain");
mTerrainStorage = new TerrainStorage(mResourceSystem, Settings::Manager::getString("normal map pattern", "Shaders"), Settings::Manager::getString("normal height map pattern", "Shaders"),
Settings::Manager::getBool("auto use terrain normal maps", "Shaders"), Settings::Manager::getString("terrain specular map pattern", "Shaders"),
Settings::Manager::getBool("auto use terrain normal maps", "Shaders"), Settings::Manager::getString("terrain specular map pattern", "Shaders"),
Settings::Manager::getBool("auto use terrain specular maps", "Shaders"));
if (distantTerrain)
if (mDistantTerrain)
mTerrain.reset(new Terrain::QuadTreeWorld(sceneRoot, mRootNode, mResourceSystem, mTerrainStorage, Mask_Terrain, Mask_PreCompile));
else
mTerrain.reset(new Terrain::TerrainGrid(sceneRoot, mRootNode, mResourceSystem, mTerrainStorage, Mask_Terrain, Mask_PreCompile));
@ -479,14 +501,44 @@ namespace MWRender
{
osg::Vec4f color = SceneUtil::colourFromRGB(cell->mAmbi.mFog);
configureFog (cell->mAmbi.mFogDensity, mUnderwaterIndoorFog, color);
if(mDistantFog)
{
float density = std::max(0.2f, cell->mAmbi.mFogDensity);
mLandFogStart = (DLInteriorFogEnd*(1.0f-density) + DLInteriorFogStart*density);
mLandFogEnd = DLInteriorFogEnd;
mUnderwaterFogStart = DLUnderwaterFogStart;
mUnderwaterFogEnd = DLUnderwaterFogEnd;
mFogColor = color;
}
else
configureFog(cell->mAmbi.mFogDensity, mUnderwaterIndoorFog, 1.0f, 0.0f, color);
}
void RenderingManager::configureFog(float fogDepth, float underwaterFog, const osg::Vec4f &color)
void RenderingManager::configureFog(float fogDepth, float underwaterFog, float dlFactor, float dlOffset, const osg::Vec4f &color)
{
mFogDepth = fogDepth;
if(mDistantFog)
{
mLandFogStart = dlFactor * (DLLandFogStart - dlOffset*DLLandFogEnd);
mLandFogEnd = dlFactor * (1.0f-dlOffset) * DLLandFogEnd;
mUnderwaterFogStart = DLUnderwaterFogStart;
mUnderwaterFogEnd = DLUnderwaterFogEnd;
}
else
{
if(fogDepth == 0.0)
{
mLandFogStart = 0.0f;
mLandFogEnd = std::numeric_limits<float>::max();
}
else
{
mLandFogStart = mViewDistance * (1 - fogDepth);
mLandFogEnd = mViewDistance;
}
mUnderwaterFogStart = mViewDistance * (1 - underwaterFog);
mUnderwaterFogEnd = mViewDistance;
}
mFogColor = color;
mUnderwaterFog = underwaterFog;
}
SkyManager* RenderingManager::getSkyManager()
@ -517,23 +569,15 @@ namespace MWRender
float viewDistance = mViewDistance;
viewDistance = std::min(viewDistance, 6666.f);
setFogColor(mUnderwaterColor * mUnderwaterWeight + mFogColor * (1.f-mUnderwaterWeight));
mStateUpdater->setFogStart(viewDistance * (1 - mUnderwaterFog));
mStateUpdater->setFogEnd(viewDistance);
mStateUpdater->setFogStart(mUnderwaterFogStart);
mStateUpdater->setFogEnd(mUnderwaterFogEnd);
}
else
{
setFogColor(mFogColor);
if (mFogDepth == 0.f)
{
mStateUpdater->setFogStart(0.f);
mStateUpdater->setFogEnd(std::numeric_limits<float>::max());
}
else
{
mStateUpdater->setFogStart(mViewDistance * (1 - mFogDepth));
mStateUpdater->setFogEnd(mViewDistance);
}
mStateUpdater->setFogStart(mLandFogStart);
mStateUpdater->setFogEnd(mLandFogEnd);
}
}
@ -960,7 +1004,8 @@ namespace MWRender
else if (it->first == "Camera" && it->second == "viewing distance")
{
mViewDistance = Settings::Manager::getFloat("viewing distance", "Camera");
mStateUpdater->setFogEnd(mViewDistance);
if(!mDistantFog)
mStateUpdater->setFogEnd(mViewDistance);
updateProjectionMatrix();
}
else if (it->first == "General" && (it->second == "texture filter" ||

@ -106,7 +106,7 @@ namespace MWRender
void configureAmbient(const ESM::Cell* cell);
void configureFog(const ESM::Cell* cell);
void configureFog(float fogDepth, float underwaterFog, const osg::Vec4f& colour);
void configureFog(float fogDepth, float underwaterFog, float dlFactor, float dlOffset, const osg::Vec4f& colour);
void addCell(const MWWorld::CellStore* store);
void removeCell(const MWWorld::CellStore* store);
@ -241,10 +241,12 @@ namespace MWRender
osg::ref_ptr<StateUpdater> mStateUpdater;
float mFogDepth;
float mLandFogStart;
float mLandFogEnd;
float mUnderwaterFogStart;
float mUnderwaterFogEnd;
osg::Vec4f mUnderwaterColor;
float mUnderwaterWeight;
float mUnderwaterFog;
float mUnderwaterIndoorFog;
osg::Vec4f mFogColor;
@ -253,8 +255,10 @@ namespace MWRender
float mNearClip;
float mViewDistance;
bool mDistantFog : 1;
bool mDistantTerrain : 1;
bool mFieldOfViewOverridden : 1;
float mFieldOfViewOverride;
bool mFieldOfViewOverridden;
float mFieldOfView;
float mFirstPersonFieldOfView;

@ -65,6 +65,9 @@ namespace MWRender
float mFogDepth;
float mDLFogFactor;
float mDLFogOffset;
float mWindSpeed;
float mCloudSpeed;

@ -102,6 +102,8 @@ Weather::Weather(const std::string& name,
const Fallback::Map& fallback,
float stormWindSpeed,
float rainSpeed,
float dlFactor,
float dlOffset,
const std::string& particleEffect)
: mCloudTexture(fallback.getFallbackString("Weather_" + name + "_Cloud_Texture"))
, mSkyColor(fallback.getFallbackColour("Weather_" + name +"_Sky_Sunrise_Color"),
@ -141,6 +143,8 @@ Weather::Weather(const std::string& name,
, mFlashDecrement(fallback.getFallbackFloat("Weather_" + name + "_Flash_Decrement"))
, mFlashBrightness(0.0f)
{
mDL.FogFactor = dlFactor;
mDL.FogOffset = dlOffset;
mThunderSoundID[0] = fallback.getFallbackString("Weather_" + name + "_Thunder_Sound_ID_0");
mThunderSoundID[1] = fallback.getFallbackString("Weather_" + name + "_Thunder_Sound_ID_1");
mThunderSoundID[2] = fallback.getFallbackString("Weather_" + name + "_Thunder_Sound_ID_2");
@ -541,16 +545,18 @@ WeatherManager::WeatherManager(MWRender::RenderingManager& rendering, const Fall
mTimeSettings.mSunriseTime = mSunriseTime;
mWeatherSettings.reserve(10);
addWeather("Clear", fallback); // 0
addWeather("Cloudy", fallback); // 1
addWeather("Foggy", fallback); // 2
addWeather("Overcast", fallback); // 3
addWeather("Rain", fallback); // 4
addWeather("Thunderstorm", fallback); // 5
addWeather("Ashstorm", fallback, "meshes\\ashcloud.nif"); // 6
addWeather("Blight", fallback, "meshes\\blightcloud.nif"); // 7
addWeather("Snow", fallback, "meshes\\snow.nif"); // 8
addWeather("Blizzard", fallback, "meshes\\blizzard.nif"); // 9
// These distant land fog factor and offset values are the defaults MGE XE provides. Should be
// provided by settings somewhere?
addWeather("Clear", fallback, 1.0f, 0.0f); // 0
addWeather("Cloudy", fallback, 0.9f, 0.0f); // 1
addWeather("Foggy", fallback, 0.2f, 30.0f); // 2
addWeather("Overcast", fallback, 0.7f, 0.0f); // 3
addWeather("Rain", fallback, 0.5f, 10.0f); // 4
addWeather("Thunderstorm", fallback, 0.5f, 20.0f); // 5
addWeather("Ashstorm", fallback, 0.2f, 50.0f, "meshes\\ashcloud.nif"); // 6
addWeather("Blight", fallback, 0.2f, 60.0f, "meshes\\blightcloud.nif"); // 7
addWeather("Snow", fallback, 0.5f, 40.0f, "meshes\\snow.nif"); // 8
addWeather("Blizzard", fallback, 0.16f, 70.0f, "meshes\\blizzard.nif"); // 9
Store<ESM::Region>::iterator it = store.get<ESM::Region>().begin();
for(; it != store.get<ESM::Region>().end(); ++it)
@ -718,7 +724,8 @@ void WeatherManager::update(float duration, bool paused, const TimeStamp& time,
mRendering.getSkyManager()->setMasserState(mMasser.calculateState(time));
mRendering.getSkyManager()->setSecundaState(mSecunda.calculateState(time));
mRendering.configureFog(mResult.mFogDepth, underwaterFog, mResult.mFogColor);
mRendering.configureFog(mResult.mFogDepth, underwaterFog, mResult.mDLFogFactor,
mResult.mDLFogOffset/100.0f, mResult.mFogColor);
mRendering.setAmbientColour(mResult.mAmbientColor);
mRendering.setSunColour(mResult.mSunColor, mResult.mSunColor * mResult.mGlareView);
@ -863,11 +870,12 @@ void WeatherManager::clear()
inline void WeatherManager::addWeather(const std::string& name,
const Fallback::Map& fallback,
float dlFactor, float dlOffset,
const std::string& particleEffect)
{
static const float fStromWindSpeed = mStore.get<ESM::GameSetting>().find("fStromWindSpeed")->getFloat();
Weather weather(name, fallback, fStromWindSpeed, mRainSpeed, particleEffect);
Weather weather(name, fallback, fStromWindSpeed, mRainSpeed, dlFactor, dlOffset, particleEffect);
mWeatherSettings.push_back(weather);
}
@ -1055,6 +1063,8 @@ inline void WeatherManager::calculateResult(const int weatherID, const float gam
mResult.mNight = (gameHour < mSunriseTime || gameHour > mTimeSettings.mNightStart - 1);
mResult.mFogDepth = current.mLandFogDepth.getValue(gameHour, mTimeSettings);
mResult.mDLFogFactor = current.mDL.FogFactor;
mResult.mDLFogOffset = current.mDL.FogOffset;
mResult.mFogColor = current.mFogColor.getValue(gameHour, mTimeSettings);
mResult.mAmbientColor = current.mAmbientColor.getValue(gameHour, mTimeSettings);
mResult.mSunColor = current.mSunColor.getValue(gameHour, mTimeSettings);
@ -1110,6 +1120,8 @@ inline void WeatherManager::calculateTransitionResult(const float factor, const
mResult.mAmbientColor = lerp(current.mAmbientColor, other.mAmbientColor, factor);
mResult.mSunDiscColor = lerp(current.mSunDiscColor, other.mSunDiscColor, factor);
mResult.mFogDepth = lerp(current.mFogDepth, other.mFogDepth, factor);
mResult.mDLFogFactor = lerp(current.mDLFogFactor, other.mDLFogFactor, factor);
mResult.mDLFogOffset = lerp(current.mDLFogOffset, other.mDLFogOffset, factor);
mResult.mWindSpeed = lerp(current.mWindSpeed, other.mWindSpeed, factor);
mResult.mCloudSpeed = lerp(current.mCloudSpeed, other.mCloudSpeed, factor);
mResult.mGlareView = lerp(current.mGlareView, other.mGlareView, factor);

@ -73,6 +73,8 @@ namespace MWWorld
const Fallback::Map& fallback,
float stormWindSpeed,
float rainSpeed,
float dlFactor,
float dlOffset,
const std::string& particleEffect);
std::string mCloudTexture;
@ -102,6 +104,12 @@ namespace MWWorld
// Also appears to modify how visible the sun, moons, and stars are for various weather effects.
float mGlareView;
// Fog factor and offset used with distant land rendering.
struct {
float FogFactor;
float FogOffset;
} mDL;
// Sound effect
// This is used for Blight, Ashstorm and Blizzard (Bloodmoon)
std::string mAmbientLoopSoundID;
@ -293,6 +301,7 @@ namespace MWWorld
void addWeather(const std::string& name,
const Fallback::Map& fallback,
float dlFactor, float dlOffset,
const std::string& particleEffect = "");
void importRegions();

@ -90,6 +90,24 @@ pointers cache size = 40
# If true, use paging and LOD algorithms to display the entire terrain. If false, only display terrain of the loaded cells
distant terrain = false
[Fog]
# If true, use extended fog parameters for distant terrain not controlled by
# viewing distance. If false, use the standard fog calculations.
use distant fog = false
distant land fog start = 16384
distant land fog end = 40960
distant underwater fog start = -4096
distant underwater fog end = 2457.6
distant interior fog start = 0
distant interior fog end = 16384
[Map]
# Size of each exterior cell in pixels in the world map. (e.g. 12 to 24).

Loading…
Cancel
Save