Ogre Version: : 1 13 6 5:
Operating System: :Linux Tumbleweed:
Render System: :OpenGL3+
Instancing: HW Basic
Code: Select all
Ogre.log (optional)
Hello, It seems there is a small bug either in my code or even in Ogre3d engine ( maybe that's not a bug -- maybe it's a feature .
As you remember or not from previous posts I have tried to establish instancing for the "fog of war" tiles ( remember those tiny cubes which build OpenDungeonsPlus) . Something similar to that :
First I create InstanceManagers like this :
Code: Select all
mInstanceManagerDirt = mSceneManager->createInstanceManager(
"InstanceManagerMeshDirt",
"FogOfWarDirt.mesh",
"Graphics",
Ogre::InstanceManager::HWInstancingBasic,
128,
Ogre::IM_USEALL,
0);
mInstanceManagerCloud = mSceneManager->createInstanceManager(
"InstanceManagerMeshCloud2",
"FogOfWarCloud2.mesh",
"Graphics",
Ogre::InstanceManager::HWInstancingBasic,
64,
Ogre::IM_USEALL,
0);
Then in rrCreateTile I coupled the creation of actual mesh with the shadowing mesh --- the Dirt and the Fog ( or cloud as you wish to call it ) ( those are two separate materials so I do use two separate InstanceManagers):
Code: Select all
Ogre::InstancedEntity* myDirt = mInstanceManagerDirt->createInstancedEntity("DirtInstanced");
Ogre::InstancedEntity* myCloud = mInstanceManagerCloud->createInstancedEntity("Fog");
And then in rrRefreshTile I have this mechanism which synchronizes the given flag vision ( bool vision) with the sceneGraph by attaching and detaching proper Entities to Nodes:
Code: Select all
if (vision && !tile.getHasFogOfWar())
{
tileMeshEnt = mSceneManager->createEntity(tileMeshName, meshPtr);
// If the node does not exist, we create it
// Link the tile mesh back to the relevant scene node so OGRE will render it
tileMeshNode->attachObject(tileMeshEnt);
tile.setHasFogOfWar(false);
}
else if ( !vision && !tile.getHasFogOfWar())
{
tileMeshNode->attachObject(tile.getFogOfWarMesh());
tileMeshNode->attachObject(tile.getFogOfWarCloud());
tile.setHasFogOfWar(true);
}
else if( vision && tile.getHasFogOfWar())
{
tileMeshNode->detachObject(tile.getFogOfWarMesh());
tileMeshNode->detachObject(tile.getFogOfWarCloud());
tileMeshEnt = mSceneManager->createEntity(tileMeshName, meshPtr);
// If the node does not exist, we create it
// Link the tile mesh back to the relevant scene node so OGRE will render it
tileMeshNode->attachObject(tileMeshEnt);
tile.setHasFogOfWar(false);
}
In cooking and wash this works reasonably well.... until the number of detached Tiles grows really large ! For example in editor ( all Fog of war meshes detached because every tile has vision) OR by calling proper command in console ( cheats.togglefow()) brings performance to it' s knees , that is I get 14 FPS on my shiny RTX 3060 !!! ;( I have tried to observe what happens with callgrind tool --- and it seems most of the time CPU performs various visibitlity tests on those detached Entities !!! How that's possible in the first place ?