From 49a744b65a6d5436608224f567e364ccd83587bf Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Wed, 12 May 2021 09:18:54 +0400 Subject: [PATCH] Make groundcover to use rendering distance in units instead of cells --- apps/openmw/mwrender/renderingmanager.cpp | 10 ++++++---- .../reference/modding/settings/groundcover.rst | 13 ++++++------- files/settings-default.cfg | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 7093c2b984..e497fdecd2 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -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(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) { diff --git a/docs/source/reference/modding/settings/groundcover.rst b/docs/source/reference/modding/settings/groundcover.rst index ef97caeecc..7c5a965e01 100644 --- a/docs/source/reference/modding/settings/groundcover.rst +++ b/docs/source/reference/modding/settings/groundcover.rst @@ -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. diff --git a/files/settings-default.cfg b/files/settings-default.cfg index ecce453d42..b4910c9b86 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -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