Skip to content

Commit

Permalink
Make groundcover to use rendering distance in units instead of cells
Browse files Browse the repository at this point in the history
  • Loading branch information
akortunov committed May 12, 2021
1 parent 852c71f commit 49a744b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
10 changes: 6 additions & 4 deletions apps/openmw/mwrender/renderingmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
}
}
Expand Down Expand Up @@ -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)
{
Expand Down
13 changes: 6 additions & 7 deletions docs/source/reference/modding/settings/groundcover.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions files/settings-default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 49a744b

Please sign in to comment.