Make groundcover to use rendering distance in units instead of cells

pull/3086/head
Andrei Kortunov 4 years ago
parent 852c71fe22
commit 49a744b65a

@ -262,7 +262,7 @@ namespace MWRender
globalDefines[itr->first] = itr->second;
// Refactor this at some point - most shaders don't care about these defines
float groundcoverDistance = (Constants::CellSizeInUnits * std::max(1, Settings::Manager::getInt("distance", "Groundcover")) - 1024) * 0.93;
float groundcoverDistance = std::max(0.f, Settings::Manager::getFloat("rendering distance", "Groundcover"));
globalDefines["groundcoverFadeStart"] = std::to_string(groundcoverDistance * 0.9f);
globalDefines["groundcoverFadeEnd"] = std::to_string(groundcoverDistance);
globalDefines["groundcoverStompMode"] = std::to_string(std::clamp(Settings::Manager::getInt("stomp mode", "Groundcover"), 0, 2));
@ -349,6 +349,10 @@ namespace MWRender
mGroundcover.reset(new Groundcover(mResourceSystem->getSceneManager(), density));
static_cast<Terrain::QuadTreeWorld*>(mGroundcoverWorld.get())->addChunkManager(mGroundcover.get());
mResourceSystem->addResourceManager(mGroundcover.get());
// Groundcover it is handled in the same way indifferently from if it is from active grid or from distant cell.
// Use a stub grid to avoid splitting between chunks for active grid and chunks for distant cells.
mGroundcoverWorld->setActiveGrid(osg::Vec4i(0, 0, 0, 0));
}
// water goes after terrain for correct waterculling order
mWater.reset(new Water(sceneRoot->getParent(0), sceneRoot, mResourceSystem, mViewer->getIncrementalCompileOperation(), resourcePath));
@ -1076,7 +1080,7 @@ namespace MWRender
if (mGroundcoverWorld)
{
int groundcoverDistance = Constants::CellSizeInUnits * std::max(1, Settings::Manager::getInt("distance", "Groundcover"));
float groundcoverDistance = std::max(0.f, Settings::Manager::getFloat("rendering distance", "Groundcover"));
mGroundcoverWorld->setViewDistance(groundcoverDistance * (distanceMult ? 1.f/distanceMult : 1.f));
}
}
@ -1311,8 +1315,6 @@ namespace MWRender
void RenderingManager::setActiveGrid(const osg::Vec4i &grid)
{
mTerrain->setActiveGrid(grid);
if (mGroundcoverWorld)
mGroundcoverWorld->setActiveGrid(grid);
}
bool RenderingManager::pagingEnableObject(int type, const MWWorld::ConstPtr& ptr, bool enabled)
{

@ -28,15 +28,14 @@ are used in the game. Can affect performance a lot.
This setting can only be configured by editing the settings configuration file.
distance
--------
rendering distance
------------------
:Type: integer
:Range: > 0
:Default: 1
:Type: floating point
:Range: >= 0.0
:Default: 6144.0
Determines on which distance in cells grass pages are rendered.
Default 1 value means 3x3 cells area (active grid).
Determines on which distance in game units grass pages are rendered.
May affect performance a lot.
This setting can only be configured by editing the settings configuration file.

@ -1071,8 +1071,8 @@ enabled = false
# 1.0 means 100% density
density = 1.0
# A maximum distance in cells on which groundcover is rendered.
distance = 1
# A maximum distance in game units on which groundcover is rendered.
rendering distance = 6144.0
# A minimum size of groundcover chunk in cells (0.125, 0.25, 0.5, 1.0)
min chunk size = 0.5

Loading…
Cancel
Save