mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 21:15:33 +00:00
Make settings for distant fog parameters
This commit is contained in:
parent
4caa7c9674
commit
41669467ae
3 changed files with 53 additions and 24 deletions
|
@ -53,16 +53,13 @@
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
// These values are what MGE XE uses by default when distant land is enabled, and are specified
|
float DLRenderDistance;
|
||||||
// in cells (8192 units each). Should make them settings somewhere? Or wait to expose them
|
float DLLandFogStart;
|
||||||
// "properly"?
|
float DLLandFogEnd;
|
||||||
const float DLRenderDistance = 5.0f;
|
float DLUnderwaterFogStart;
|
||||||
const float DLLandFogStart = 2.0f;
|
float DLUnderwaterFogEnd;
|
||||||
const float DLLandFogEnd = 5.0f;
|
float DLInteriorFogStart;
|
||||||
const float DLUnderwaterFogStart = -0.5f;
|
float DLInteriorFogEnd;
|
||||||
const float DLUnderwaterFogEnd = 0.3f;
|
|
||||||
const float DLInteriorFogStart = 0.0f;
|
|
||||||
const float DLInteriorFogEnd = 2.0f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
|
@ -195,6 +192,7 @@ namespace MWRender
|
||||||
, mUnderwaterWeight(fallback->getFallbackFloat("Water_UnderwaterColorWeight"))
|
, mUnderwaterWeight(fallback->getFallbackFloat("Water_UnderwaterColorWeight"))
|
||||||
, mUnderwaterIndoorFog(fallback->getFallbackFloat("Water_UnderwaterIndoorFog"))
|
, mUnderwaterIndoorFog(fallback->getFallbackFloat("Water_UnderwaterIndoorFog"))
|
||||||
, mNightEyeFactor(0.f)
|
, mNightEyeFactor(0.f)
|
||||||
|
, mDistantFog(false)
|
||||||
, mDistantTerrain(false)
|
, mDistantTerrain(false)
|
||||||
, mFieldOfViewOverridden(false)
|
, mFieldOfViewOverridden(false)
|
||||||
, mFieldOfViewOverride(0.f)
|
, mFieldOfViewOverride(0.f)
|
||||||
|
@ -233,6 +231,15 @@ namespace MWRender
|
||||||
|
|
||||||
mWater.reset(new Water(mRootNode, sceneRoot, mResourceSystem, mViewer->getIncrementalCompileOperation(), fallback, resourcePath));
|
mWater.reset(new Water(mRootNode, sceneRoot, mResourceSystem, mViewer->getIncrementalCompileOperation(), fallback, resourcePath));
|
||||||
|
|
||||||
|
DLRenderDistance = Settings::Manager::getFloat("distant viewing distance", "Camera");
|
||||||
|
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");
|
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"),
|
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"),
|
||||||
|
@ -305,7 +312,7 @@ namespace MWRender
|
||||||
mFirstPersonFieldOfView = Settings::Manager::getFloat("first person field of view", "Camera");
|
mFirstPersonFieldOfView = Settings::Manager::getFloat("first person field of view", "Camera");
|
||||||
mStateUpdater->setFogEnd(mViewDistance);
|
mStateUpdater->setFogEnd(mViewDistance);
|
||||||
|
|
||||||
mFarClip = mDistantTerrain ? DLRenderDistance*8192.0f : mViewDistance;
|
mFarClip = mDistantTerrain ? DLRenderDistance : mViewDistance;
|
||||||
|
|
||||||
mRootNode->getOrCreateStateSet()->addUniform(new osg::Uniform("near", mNearClip));
|
mRootNode->getOrCreateStateSet()->addUniform(new osg::Uniform("near", mNearClip));
|
||||||
mRootNode->getOrCreateStateSet()->addUniform(new osg::Uniform("far", mFarClip));
|
mRootNode->getOrCreateStateSet()->addUniform(new osg::Uniform("far", mFarClip));
|
||||||
|
@ -498,13 +505,13 @@ namespace MWRender
|
||||||
{
|
{
|
||||||
osg::Vec4f color = SceneUtil::colourFromRGB(cell->mAmbi.mFog);
|
osg::Vec4f color = SceneUtil::colourFromRGB(cell->mAmbi.mFog);
|
||||||
|
|
||||||
if(mDistantTerrain)
|
if(mDistantFog)
|
||||||
{
|
{
|
||||||
float density = std::max(0.2f, cell->mAmbi.mFogDensity);
|
float density = std::max(0.2f, cell->mAmbi.mFogDensity);
|
||||||
mLandFogStart = (DLInteriorFogEnd*(1.0f-density) + DLInteriorFogStart*density) * 8192.0f;
|
mLandFogStart = (DLInteriorFogEnd*(1.0f-density) + DLInteriorFogStart*density);
|
||||||
mLandFogEnd = DLInteriorFogEnd * 8192.0f;
|
mLandFogEnd = DLInteriorFogEnd;
|
||||||
mUnderwaterFogStart = DLUnderwaterFogStart * 8192.0f;
|
mUnderwaterFogStart = DLUnderwaterFogStart;
|
||||||
mUnderwaterFogEnd = DLUnderwaterFogEnd * 8192.0f;
|
mUnderwaterFogEnd = DLUnderwaterFogEnd;
|
||||||
mFogColor = color;
|
mFogColor = color;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -513,12 +520,12 @@ namespace MWRender
|
||||||
|
|
||||||
void RenderingManager::configureFog(float fogDepth, float underwaterFog, float dlFactor, float dlOffset, const osg::Vec4f &color)
|
void RenderingManager::configureFog(float fogDepth, float underwaterFog, float dlFactor, float dlOffset, const osg::Vec4f &color)
|
||||||
{
|
{
|
||||||
if(mDistantTerrain)
|
if(mDistantFog)
|
||||||
{
|
{
|
||||||
mLandFogStart = dlFactor * (DLLandFogStart - dlOffset*DLLandFogEnd) * 8192.0f;
|
mLandFogStart = dlFactor * (DLLandFogStart - dlOffset*DLLandFogEnd);
|
||||||
mLandFogEnd = dlFactor * (1.0f-dlOffset) * DLLandFogEnd * 8192.0f;
|
mLandFogEnd = dlFactor * (1.0f-dlOffset) * DLLandFogEnd;
|
||||||
mUnderwaterFogStart = DLUnderwaterFogStart * 8192.0f;
|
mUnderwaterFogStart = DLUnderwaterFogStart;
|
||||||
mUnderwaterFogEnd = DLUnderwaterFogEnd * 8192.0f;
|
mUnderwaterFogEnd = DLUnderwaterFogEnd;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1002,12 +1009,11 @@ namespace MWRender
|
||||||
{
|
{
|
||||||
mViewDistance = Settings::Manager::getFloat("viewing distance", "Camera");
|
mViewDistance = Settings::Manager::getFloat("viewing distance", "Camera");
|
||||||
if(!mDistantTerrain)
|
if(!mDistantTerrain)
|
||||||
{
|
|
||||||
mFarClip = mViewDistance;
|
mFarClip = mViewDistance;
|
||||||
|
if(!mDistantFog)
|
||||||
mStateUpdater->setFogEnd(mViewDistance);
|
mStateUpdater->setFogEnd(mViewDistance);
|
||||||
updateProjectionMatrix();
|
updateProjectionMatrix();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (it->first == "General" && (it->second == "texture filter" ||
|
else if (it->first == "General" && (it->second == "texture filter" ||
|
||||||
it->second == "texture mipmap" ||
|
it->second == "texture mipmap" ||
|
||||||
it->second == "anisotropy"))
|
it->second == "anisotropy"))
|
||||||
|
|
|
@ -256,6 +256,7 @@ namespace MWRender
|
||||||
float mNearClip;
|
float mNearClip;
|
||||||
float mFarClip;
|
float mFarClip;
|
||||||
float mViewDistance;
|
float mViewDistance;
|
||||||
|
bool mDistantFog : 1;
|
||||||
bool mDistantTerrain : 1;
|
bool mDistantTerrain : 1;
|
||||||
bool mFieldOfViewOverridden : 1;
|
bool mFieldOfViewOverridden : 1;
|
||||||
float mFieldOfViewOverride;
|
float mFieldOfViewOverride;
|
||||||
|
|
|
@ -25,6 +25,10 @@ small feature culling pixel size = 2.0
|
||||||
# can dramatically affect performance, see documentation for details.
|
# can dramatically affect performance, see documentation for details.
|
||||||
viewing distance = 6666.0
|
viewing distance = 6666.0
|
||||||
|
|
||||||
|
# Maximum visible distance for distant terrain. Caution: setting this too high
|
||||||
|
# can increase the chance for Z-fighting (flickering artifacts).
|
||||||
|
distant viewing distance = 40960
|
||||||
|
|
||||||
# Camera field of view in degrees (e.g. 30.0 to 110.0).
|
# Camera field of view in degrees (e.g. 30.0 to 110.0).
|
||||||
# Does not affect the player's hands in the first person camera.
|
# Does not affect the player's hands in the first person camera.
|
||||||
field of view = 55.0
|
field of view = 55.0
|
||||||
|
@ -90,6 +94,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
|
# If true, use paging and LOD algorithms to display the entire terrain. If false, only display terrain of the loaded cells
|
||||||
distant terrain = false
|
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]
|
[Map]
|
||||||
|
|
||||||
# Size of each exterior cell in pixels in the world map. (e.g. 12 to 24).
|
# Size of each exterior cell in pixels in the world map. (e.g. 12 to 24).
|
||||||
|
|
Loading…
Reference in a new issue