LOD on meshes
LOD on meshes
Greetings,
I'm wondering if still any example on how to implement LOD on meshes.
My idea would be make a big city like in Grand Theft Auto, so i think LOD would be crucial.
PS. c++ beginner here.
I'm wondering if still any example on how to implement LOD on meshes.
My idea would be make a big city like in Grand Theft Auto, so i think LOD would be crucial.
PS. c++ beginner here.
-
- Posts: 1215
- Joined: Tue Jan 09, 2007 7:03 pm
- Location: Leuven, Belgium
Dynamic LOD is pretty hard to accomplish, as far as I know the only implementation of this is inside the terrain scene node, but I've only skimmed through that code once in the past, so I couldn't tell if this would be applicable to other meshes (probably not)
You could however implement a scene node which holds a set of pre-made meshes each with increasing detail with every iteration and write it so that the active level of detail changes based on distance from the player
But for a C++ beginner this might be a bit too much, so I'd suggest to keep it simple until you are completely familiar with the language
EDIT:
For city scenes it might be better to go with some more advanced occlusion mechanisms instead of dynamic LOD, since such scenes allow for a great deal of optimisation in that field
Irrlicht supports occlusion queries I believe, so you could check those out
You could however implement a scene node which holds a set of pre-made meshes each with increasing detail with every iteration and write it so that the active level of detail changes based on distance from the player
But for a C++ beginner this might be a bit too much, so I'd suggest to keep it simple until you are completely familiar with the language
EDIT:
For city scenes it might be better to go with some more advanced occlusion mechanisms instead of dynamic LOD, since such scenes allow for a great deal of optimisation in that field
Irrlicht supports occlusion queries I believe, so you could check those out
Actually Jorus that pic is easy to achieve with irrlicht....it just depends on how you want it. You could change irrlicht so that a meshscenenode/animatedmeshscenenode holds different meshes for each LOD level or implement a triangle reducing lib there are some out there. and then decide on rendertime which mesh to use.
Another solution would be to not mess with irrlicht and implement the lod one level higher with your entities so that they hold several scenenode which they set to visible/invisible when needed. or create a managing scenenode who decides which of its children sould be visible depending on camera distance.
And of course use some culling technics city scenes are perfect for those you could for example easily disable rendering of objects in another block which simply cannot be scene the player and then for the rest occlusion queries or something like that.
Another solution would be to not mess with irrlicht and implement the lod one level higher with your entities so that they hold several scenenode which they set to visible/invisible when needed. or create a managing scenenode who decides which of its children sould be visible depending on camera distance.
And of course use some culling technics city scenes are perfect for those you could for example easily disable rendering of objects in another block which simply cannot be scene the player and then for the rest occlusion queries or something like that.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
If I wanted to do it the easiest way to get me started I'd pre-create N different levels of detail (polygon complexity) for my models using whatever modelling software. Some modelling software can do this for you, or has functions to at least reduce the poly count (like optimise, in 3ds max). Then, I'd choose which view distances I want to display each of these N models. You'd have to find a balance based on speed and how good the models look at certain distances.Jorus wrote: This pic shows what is my idea of lod, its just hard to realize in C++
I'd make a custom scenenode (look at the tutorials) and instead of only holding one mesh, I'd have an array of N meshes, one for each detail level. When it comes to rendering, I'd find out how far away the node is from the camera, then render the best LOD mesh for that.
Here's some pseudo code off the top of my head.. you should be able to fill in the blanks using the tutorial examples.
Code: Select all
class MultiLODMeshSceneNode : public ISceneNode
{
//3 meshes - 3 levels of detail
IMesh* meshes[3];
//pointer to current level of detail
IMesh* currentLOD;
// > SQUARED < distances where you want the LODs active
float distance1,distance2,distance3;
loadMeshes( ..list of filenames..)
{
meshes[0] = smgr->getMesh("meshlod1.3ds");
meshes[1] = smgr->getMesh("meshlod2.3ds");
....repeat for all levels of detail....
}
updateLOD(vector3df cameraLocation)
{
//squared distance between camera and this scene node
float distanceSQ = cameraLocation.getDistanceFromSQ(location_of_this_scenenode);
if(distanceSQ < distance1) currentLOD = meshes[0];
if(distanceSQ >distance1 && distanceSQ < distance2) currentLOD= meshes[1];
..repeat for all levels of detail ..
}
render()
{
..set up render stuff etc..
//draw current lod mesh
driver->drawMeshBuffer(currentLOD);
}
};
I'd say Radikalizm is right, for city scenes the main portion of optimization is efficient occlusion culling. When moving though the streets you'll see some buildings, the rest is occluded.
Plus, if you'll do it as in GTA, most of the buildings consist of a couple of boxes so LOD won't do much here.
Plus, if you'll do it as in GTA, most of the buildings consist of a couple of boxes so LOD won't do much here.
beer->setMotivationCallback(this);
the best thing you can do is replace every building/groupOfBuilding with a axial billboard (with low texture resolution, up to 256x256 pixels) when you are looking the building from far.
if every building is made up of few polygons the best optimiziations you can do is culling building that are not visibles. When you are looking from far textures are optimized with mipmap(that's automatic), but you can always add custom mipmaps (lower resolution than autogenerated mipmaps, remember to blurr a bit those images). or just change LOD parameter of material settings.. Since you are moving using roads in a GTA style game you can instead of adding billboards for buildings add a "fake" at the end of roads. the idea is the same of paint the road on a wall:
if every building is made up of few polygons the best optimiziations you can do is culling building that are not visibles. When you are looking from far textures are optimized with mipmap(that's automatic), but you can always add custom mipmaps (lower resolution than autogenerated mipmaps, remember to blurr a bit those images). or just change LOD parameter of material settings.. Since you are moving using roads in a GTA style game you can instead of adding billboards for buildings add a "fake" at the end of roads. the idea is the same of paint the road on a wall:
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
It is also a common error to rely on the distance to switch the levels of detail, It is better to use the covered area of the object on screen to make an approach of what LOD display. That can be calculated using the bounding box projection on screen, perhaps.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Occlusion culling would be awesome, i will search for an example tutorial on how implement it. Thanks anyone for his own answers.polylux wrote:When moving though the streets you'll see some buildings, the rest is occluded.
Edit: Just did some "googling", is occlusion culling already implemented in Irrlicht?
I'm using the last svn revision (at the moment 3605).
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Yes, occlusion culling is already implemented in Irrlicht. Simple discrete LOD is probably best kept in a scene node animator, at least as long as only different resolutions of some mesh are used.
When including impostors it depends on which implementation you use. bitplane's version was making use of grouping many impostors into one node to speed up the rendering a lot. This would require some higher level of access to the meshes, as you'd group many scene nodes into one.
BTW: Without C++ knowledge lf is also a little too much for you probably...
When including impostors it depends on which implementation you use. bitplane's version was making use of grouping many impostors into one node to speed up the rendering a lot. This would require some higher level of access to the meshes, as you'd group many scene nodes into one.
BTW: Without C++ knowledge lf is also a little too much for you probably...