diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index cd6dc0fbc..797e3c400 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -204,14 +204,22 @@ void RenderingManager::configureFog(ESMS::CellStore &mCell) Ogre::ColourValue color; color.setAsABGR (mCell.cell->ambi.fog); - float high = /*4500 + 9000 * */(1-mCell.cell->ambi.fogDensity); - float low = 200; - - mRendering.getScene()->setFog (FOG_LINEAR, color, 0, low, high); - mRendering.getCamera()->setFarClipDistance (high + 10); - mRendering.getViewport()->setBackgroundColour (color); + configureFog(mCell.cell->ambi.fogDensity, color); } +void RenderingManager::configureFog(const float density, const Ogre::ColourValue& colour) +{ + /// \todo make the viewing distance and fog start/end configurable + float low = 3000 / density; + float high = 6200 / density; + + mRendering.getScene()->setFog (FOG_LINEAR, colour, 0, low, high); + + mRendering.getCamera()->setFarClipDistance ( high ); + mRendering.getViewport()->setBackgroundColour (colour); +} + + void RenderingManager::setAmbientMode() { switch (mAmbientMode) diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index fb7e19997..d84ee43e0 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -102,9 +102,13 @@ class RenderingManager: private RenderingInterface { int skyGetSecundaPhase() const; void skySetMoonColour (bool red); void configureAmbient(ESMS::CellStore &mCell); + /// configure fog according to cell void configureFog(ESMS::CellStore &mCell); - + + /// configure fog manually + void configureFog(const float density, const Ogre::ColourValue& colour); + void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number = 1); ///< Run animation for a MW-reference. Calls to this function for references that are currently not diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index fdc3a5348..b39ad3046 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -623,8 +623,6 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather) } mAtmosphereNight->setVisible(weather.mNight && mEnabled); - - mViewport->setBackgroundColour(weather.mFogColor); } void SkyManager::setGlare(bool glare) diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index c332ebbc5..47d5f1a2d 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -235,6 +235,9 @@ namespace MWWorld // adjust player mCurrentCell = cell; playerCellChange (cell, position); + + // adjust fog + mRendering.configureFog(*cell); // Sky system mWorld->adjustSky(); diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 2ffc0886c..149f211bc 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -354,6 +354,8 @@ WeatherResult WeatherManager::getResult(const String& weather) result.mNight = (mHour < 6.f+fade_duration || mHour > 20.f-fade_duration); + result.mFogDepth = result.mNight ? current.mLandFogNightDepth : current.mLandFogDayDepth; + // night if (mHour <= (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration) || mHour >= (WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration)) @@ -569,6 +571,8 @@ void WeatherManager::update(float duration) else result = getResult(mCurrentWeather); + mRendering->configureFog(result.mFogDepth, result.mFogColor); + // disable sun during night if (mHour >= WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration || mHour <= WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration) @@ -699,6 +703,8 @@ void WeatherManager::update(float duration) } } } + else + mRendering->getSkyManager()->setThunder(0.f); mRendering->setAmbientColour(result.mAmbientColor); mRendering->sunEnable();