Add setting to control composite geometry size

pull/2190/head
Andrei Kortunov 6 years ago
parent 9d44e18af6
commit 56fea4b062

@ -300,7 +300,11 @@ namespace MWRender
float compMapLevel = pow(2, compMapPower);
const float lodFactor = Settings::Manager::getFloat("lod factor", "Terrain");
const int vertexLodMod = Settings::Manager::getInt("vertex lod mod", "Terrain");
mTerrain.reset(new Terrain::QuadTreeWorld(sceneRoot, mRootNode, mResourceSystem, mTerrainStorage, Mask_Terrain, Mask_PreCompile, Mask_Debug, compMapResolution, compMapLevel, lodFactor, vertexLodMod));
float maxCompGeometrySize = Settings::Manager::getFloat("max composite geometry size", "Terrain");
maxCompGeometrySize = std::max(maxCompGeometrySize, 1.f);
mTerrain.reset(new Terrain::QuadTreeWorld(
sceneRoot, mRootNode, mResourceSystem, mTerrainStorage, Mask_Terrain, Mask_PreCompile, Mask_Debug,
compMapResolution, compMapLevel, lodFactor, vertexLodMod, maxCompGeometrySize));
}
else
mTerrain.reset(new Terrain::TerrainGrid(sceneRoot, mRootNode, mResourceSystem, mTerrainStorage, Mask_Terrain, Mask_PreCompile, Mask_Debug));

@ -29,6 +29,7 @@ ChunkManager::ChunkManager(Storage *storage, Resource::SceneManager *sceneMgr, T
, mCompositeMapRenderer(renderer)
, mCompositeMapSize(512)
, mCompositeMapLevel(1.f)
, mMaxCompGeometrySize(1.f)
, mCullingActive(true)
{
@ -85,7 +86,7 @@ osg::ref_ptr<osg::Texture2D> ChunkManager::createCompositeMapRTT()
void ChunkManager::createCompositeMapGeometry(float chunkSize, const osg::Vec2f& chunkCenter, const osg::Vec4f& texCoords, CompositeMap& compositeMap)
{
if (chunkSize > 1.f)
if (chunkSize > mMaxCompGeometrySize)
{
createCompositeMapGeometry(chunkSize/2.f, chunkCenter + osg::Vec2f(chunkSize/4.f, chunkSize/4.f), osg::Vec4f(texCoords.x() + texCoords.z()/2.f, texCoords.y(), texCoords.z()/2.f, texCoords.w()/2.f), compositeMap);
createCompositeMapGeometry(chunkSize/2.f, chunkCenter + osg::Vec2f(-chunkSize/4.f, chunkSize/4.f), osg::Vec4f(texCoords.x(), texCoords.y(), texCoords.z()/2.f, texCoords.w()/2.f), compositeMap);

@ -35,6 +35,7 @@ namespace Terrain
void setCullingActive(bool active) { mCullingActive = active; }
void setCompositeMapSize(unsigned int size) { mCompositeMapSize = size; }
void setCompositeMapLevel(float level) { mCompositeMapLevel = level; }
void setMaxCompositeGeometrySize(float maxCompGeometrySize) { mMaxCompGeometrySize = maxCompGeometrySize; }
void reportStats(unsigned int frameNumber, osg::Stats* stats) const override;
@ -59,6 +60,7 @@ namespace Terrain
unsigned int mCompositeMapSize;
float mCompositeMapLevel;
float mMaxCompGeometrySize;
bool mCullingActive;
};

@ -233,7 +233,7 @@ private:
osg::ref_ptr<RootNode> mRootNode;
};
QuadTreeWorld::QuadTreeWorld(osg::Group *parent, osg::Group *compileRoot, Resource::ResourceSystem *resourceSystem, Storage *storage, int nodeMask, int preCompileMask, int borderMask, int compMapResolution, float compMapLevel, float lodFactor, int vertexLodMod)
QuadTreeWorld::QuadTreeWorld(osg::Group *parent, osg::Group *compileRoot, Resource::ResourceSystem *resourceSystem, Storage *storage, int nodeMask, int preCompileMask, int borderMask, int compMapResolution, float compMapLevel, float lodFactor, int vertexLodMod, float maxCompGeometrySize)
: World(parent, compileRoot, resourceSystem, storage, nodeMask, preCompileMask, borderMask)
, mViewDataMap(new ViewDataMap)
, mQuadTreeBuilt(false)
@ -245,6 +245,7 @@ QuadTreeWorld::QuadTreeWorld(osg::Group *parent, osg::Group *compileRoot, Resour
mChunkManager->setCompositeMapSize(compMapResolution);
mChunkManager->setCompositeMapLevel(compMapLevel);
mChunkManager->setMaxCompositeGeometrySize(maxCompGeometrySize);
}
QuadTreeWorld::~QuadTreeWorld()

@ -19,7 +19,7 @@ namespace Terrain
class QuadTreeWorld : public Terrain::World
{
public:
QuadTreeWorld(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, int nodeMask, int preCompileMask, int borderMask, int compMapResolution, float comMapLevel, float lodFactor, int vertexLodMod);
QuadTreeWorld(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, int nodeMask, int preCompileMask, int borderMask, int compMapResolution, float comMapLevel, float lodFactor, int vertexLodMod, float maxCompGeometrySize);
~QuadTreeWorld();

@ -33,9 +33,12 @@ vertex lod mod
Controls only the Vertex LOD of the terrain. The amount of terrain chunks and the detail of composite maps is left unchanged.
Must be changed in increments of 1. Each increment will double (for positive values) or halve (for negative values) the number of vertices rendered. For example: -2 means 4x reduced detail, +3 means 8x increased detail.
Must be changed in increments of 1. Each increment will double (for positive values) or halve (for negative values) the number of vertices rendered.
For example: -2 means 4x reduced detail, +3 means 8x increased detail.
Note this setting will typically not affect near terrain. When set to increase detail, the detail of near terrain can not be increased because the detail is simply not there in the data files, and when set to reduce detail, the detail of near terrain will not be reduced because it was already less detailed than the far terrain (in view relative terms) to begin with.
Note this setting will typically not affect near terrain. When set to increase detail, the detail of near terrain can not be increased
because the detail is simply not there in the data files, and when set to reduce detail,
the detail of near terrain will not be reduced because it was already less detailed than the far terrain (in view relative terms) to begin with.
lod factor
----------
@ -44,13 +47,21 @@ lod factor
:Range: >0
:Default: 1.0
Controls the level of detail if distant terrain is enabled. Higher values increase detail at the cost of performance, lower values reduce detail but increase performance.
Controls the level of detail if distant terrain is enabled.
Higher values increase detail at the cost of performance, lower values reduce detail but increase performance.
Note this also changes how the Quad Tree is split. Increasing detail with this setting results in the visible terrain being divided into more chunks, where as reducing detail with this setting would reduce the number of chunks.
Note: it also changes how the Quad Tree is split.
Increasing detail with this setting results in the visible terrain being divided into more chunks,
where as reducing detail with this setting would reduce the number of chunks.
Fewer terrain chunks is faster for rendering, but on the other hand a larger proportion of the entire terrain must be rebuilt when LOD levels change as the camera moves. This could result in frame drops if moving across the map at high speed.
Fewer terrain chunks is faster for rendering, but on the other hand a larger proportion of the entire terrain
must be rebuilt when LOD levels change as the camera moves.
This could result in frame drops if moving across the map at high speed.
For this reason, it is not recommended to change this setting if you want to change the LOD. If you want to do that, first try using the 'vertex lod mod' setting to configure the detail of the terrain outlines to your liking and then use 'composite map resolution' to configure the texture detail to your liking. But these settings can only be changed in multiples of two, so you may want to adjust 'lod factor' afterwards for even more fine-tuning.
For this reason, it is not recommended to change this setting if you want to change the LOD.
If you want to do that, first try using the 'vertex lod mod' setting to configure the detail of the terrain outlines
to your liking and then use 'composite map resolution' to configure the texture detail to your liking.
But these settings can only be changed in multiples of two, so you may want to adjust 'lod factor' afterwards for even more fine-tuning.
composite map level
-------------------
@ -59,11 +70,13 @@ composite map level
:Range: >= -3
:Default: 0
Controls at what size (in 2^value cell units) terrain chunks will start to use a composite map instead of the high-detail textures.
Controls at which minimum size (in 2^value cell units) terrain chunks will start to use a composite map instead of the high-detail textures.
With value -3 composite maps are used everywhere.
With value >= 1 the map window will not use composited textures.
A composite map is a pre-rendered texture that contains all the texture layers combined. Note that resolution of composite maps is currently always fixed at 'composite map resolution', regardless of the resolution of the underlying terrain textures. If high-detail texture replacers are used, probably it is worth to increase 'composite map resolution' setting value.
A composite map is a pre-rendered texture that contains all the texture layers combined.
Note that resolution of composite maps is currently always fixed at 'composite map resolution',
regardless of the resolution of the underlying terrain textures.
If high-detail texture replacers are used, probably it is worth to increase 'composite map resolution' setting value.
composite map resolution
------------------------
@ -72,6 +85,19 @@ composite map resolution
:Range: >0
:Default: 512
Controls the resolution of composite maps. Larger values result in increased detail, but may take longer to prepare and thus could result in longer loading times and an increased chance of frame drops during play. As with most other texture resolution settings, it's most efficient to use values that are powers of two.
Controls the resolution of composite maps. Larger values result in increased detail,
but may take longer to prepare and thus could result in longer loading times and an increased chance of frame drops during play.
As with most other texture resolution settings, it's most efficient to use values that are powers of two.
An easy way to observe changes to loading time is to load a save in an interior next to an exterior door (so it will start preloding terrain) and watch how long it takes for the 'Composite' counter on the F4 panel to fall to zero.
An easy way to observe changes to loading time is to load a save in an interior next to an exterior door
(so it will start preloding terrain) and watch how long it takes for the 'Composite' counter on the F4 panel to fall to zero.
max composite geometry size
---------------------------
:Type: float
:Range: >=1.0
:Default: 4.0
Controls the maximum size of simple composite geometry chunk in cell units. With small values there will more draw calls and small textures,
but higher values create more overdraw (not every texture layer is used everywhere).

@ -103,6 +103,9 @@ composite map level = 0
# Controls the resolution of composite maps.
composite map resolution = 512
# Controls the maximum size of composite geometry, should be >= 1.0. With low values there will be many small chunks, with high values - lesser count of bigger chunks.
max composite geometry size = 4.0
[Fog]
# If true, use extended fog parameters for distant terrain not controlled by

Loading…
Cancel
Save