Thousands of trees? Model details/billboard
Thousands of trees? Model details/billboard
Hi
Im doing a airplane game with lots of trees (many hundred seen at the same time) etc scattered over the terrain (I will also have units/buildings but much fewer). How to keep it fast?
1. Can i scale model-quality based on how far they are from camera? Is it automatic?
2. Do nodes cost gpu/cpu when they are outside view of the camera (like behind)? Is this automatic?
3. Should i switch nodes to billboards if they are far away? How is this done?
Thanks for your help
Erik
Im doing a airplane game with lots of trees (many hundred seen at the same time) etc scattered over the terrain (I will also have units/buildings but much fewer). How to keep it fast?
1. Can i scale model-quality based on how far they are from camera? Is it automatic?
2. Do nodes cost gpu/cpu when they are outside view of the camera (like behind)? Is this automatic?
3. Should i switch nodes to billboards if they are far away? How is this done?
Thanks for your help
Erik
Re: Thousands of trees? Model details/billboard
You've basically got the right idea, I think.
1) Mesh LODing isn't automated as far as I know, but it shouldn't be too hard to do. You would just check how far from the camera a tree is and, if it's beyond some threshold, swap it out for a lower poly version. I probably wouldn't check every tree every frame, since that doesn't seem like much of an optimization! I would probably group tree nodes into "patches" and then work on patches of trees rather than individuals. Also, you probably wouldn't need to check or update them every frame. You could probably skip a few!
2) I think that is occlusion culling, and that it is indeed automatic.
3) Just make it another step in your LOD system. Instead of a single plane, I might use 2 crossed with identical textures so I don't need to rotate them to the camera all the time.
Also, I think this is probably a good candidate for shader instancing, but I don't know enough about it to really say any more.
1) Mesh LODing isn't automated as far as I know, but it shouldn't be too hard to do. You would just check how far from the camera a tree is and, if it's beyond some threshold, swap it out for a lower poly version. I probably wouldn't check every tree every frame, since that doesn't seem like much of an optimization! I would probably group tree nodes into "patches" and then work on patches of trees rather than individuals. Also, you probably wouldn't need to check or update them every frame. You could probably skip a few!
2) I think that is occlusion culling, and that it is indeed automatic.
3) Just make it another step in your LOD system. Instead of a single plane, I might use 2 crossed with identical textures so I don't need to rotate them to the camera all the time.
Also, I think this is probably a good candidate for shader instancing, but I don't know enough about it to really say any more.
Re: Thousands of trees? Model details/billboard
but what is most important? Number of faces on the model? I use 3ds-file format, would that matter for irrlicht?
When i add 400 "trees", each a 3ds of simply a 16 face sphere and a rectangle (no textures even) and this brings irrlicht from 100 to 50 fps, which seems wierd as i can run shogun 2 total war at decent framerate with thousands of models on screen each with hundreds of faces.
And switching between different quality models, doesnt that require a lot of processing? I need to create and remove nodes each time right? Or should a I create all 3 levels (lets say) of complexity models at startup and simply swith switch which one is enabled at each time?
thanks
When i add 400 "trees", each a 3ds of simply a 16 face sphere and a rectangle (no textures even) and this brings irrlicht from 100 to 50 fps, which seems wierd as i can run shogun 2 total war at decent framerate with thousands of models on screen each with hundreds of faces.
And switching between different quality models, doesnt that require a lot of processing? I need to create and remove nodes each time right? Or should a I create all 3 levels (lets say) of complexity models at startup and simply swith switch which one is enabled at each time?
thanks
Re: Thousands of trees? Model details/billboard
Rendering 100s of nodes will definitely affect your fps. It is not easy to render 1000+ objects on screen without advanced OpenGL techniques or tricks.
If your mesh and texture are same for all trees, the you can try instancing. Or you can try mesh batching if the trees have different mesh.
If your mesh and texture are same for all trees, the you can try instancing. Or you can try mesh batching if the trees have different mesh.
IrrNaCl - Irrlicht Port for Google Chrome Native Client - Demo
Iyan 3D - Make your own 3d animation using your iOS Device
Iyan 3D - Make your own 3d animation using your iOS Device
Re: Thousands of trees? Model details/billboard
ok i know what instancing is but not how to do it, is there support for it in irrlicht? And what about the other questions if you know?
Re: Thousands of trees? Model details/billboard
No official support so far. Bitplane started coding it once (see http://svn.bitplane.net/misc/trunk/irr/CImpostorNode/) and if you search for "impostors" in the forum you find probably some more info. I think he got something working, but not completed.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Thousands of trees? Model details/billboard
Yeah hardly something for a non-advanced user of irrlicht then sadly. But does anyone know:
1. No automatic mesh LOD i guess?
2. If i do my own, should i create and remove nodes (meshes?) when changing LOD? Or create them all at level creation (each tree has 3 different nodes which varying complexity) and just switch which version is visible? Is that better?
3. Does mesh-format matter when it comes to performance? I use 3ds for my statics but its not very practical to import/export from 3dsmax, size changes. Any more practical solutions?
thanks
1. No automatic mesh LOD i guess?
2. If i do my own, should i create and remove nodes (meshes?) when changing LOD? Or create them all at level creation (each tree has 3 different nodes which varying complexity) and just switch which version is visible? Is that better?
3. Does mesh-format matter when it comes to performance? I use 3ds for my statics but its not very practical to import/export from 3dsmax, size changes. Any more practical solutions?
thanks
Re: Thousands of trees? Model details/billboard
I don't know if you have already given MeshCombiner a go.
Answering 1 & 2: It's not so much about the geometric complexity of your trees but rather the traversion of all the scene nodes (and hence redundant draw calls) that slow down your rendering step. MeshCombiner would account for that.
3: Nope, as the engine keeps its own independent representation of the model.
Answering 1 & 2: It's not so much about the geometric complexity of your trees but rather the traversion of all the scene nodes (and hence redundant draw calls) that slow down your rendering step. MeshCombiner would account for that.
3: Nope, as the engine keeps its own independent representation of the model.
beer->setMotivationCallback(this);
Re: Thousands of trees? Model details/billboard
1. Im confused, the program i can download there draws many textures on a flat "ground"/plane, there doesnt seem to be any models at all drawn. Im clearly missing something.
2. I dont understand this really. Isnt the point of LOD to reduce polycount? And if i do should i create and remove old or switch visibility?
3. So 3ds-format is advised from 3ds max? Its the easiest format to work with? Because it changes the size in a wierd way when exporting.
thanks for helping out
erik
2. I dont understand this really. Isnt the point of LOD to reduce polycount? And if i do should i create and remove old or switch visibility?
3. So 3ds-format is advised from 3ds max? Its the easiest format to work with? Because it changes the size in a wierd way when exporting.
thanks for helping out
erik
Re: Thousands of trees? Model details/billboard
Ad 1: What's the issue there exactly? Can you elaborate?
Ad 2: Basically yes, LOD reduces the geom. complexity which comes in handy when you display distant objects. As I said, the polycount itself will not be the big issues assuming your tree model is rather lowpoly (can we have an exact count?). It's rather the overhead you create drawing each tree separately. So ways to go would be let MeshCombiner make one big mesh out of your 'forest' or - given you use the same model for all the trees - use hardware instancing. AFAIK there are some examplary implementations of the latter somewhere on the forums. If you merely wanna do it the easy way, give MeshCombiner a try.
Ad 3: Exporting models from blender I usually use .3ds as I've experienced the least problems with it. I'd love to use collada as it's an open format though I always seem to have issues once I open such files in irrlicht.
Ad 2: Basically yes, LOD reduces the geom. complexity which comes in handy when you display distant objects. As I said, the polycount itself will not be the big issues assuming your tree model is rather lowpoly (can we have an exact count?). It's rather the overhead you create drawing each tree separately. So ways to go would be let MeshCombiner make one big mesh out of your 'forest' or - given you use the same model for all the trees - use hardware instancing. AFAIK there are some examplary implementations of the latter somewhere on the forums. If you merely wanna do it the easy way, give MeshCombiner a try.
Ad 3: Exporting models from blender I usually use .3ds as I've experienced the least problems with it. I'd love to use collada as it's an open format though I always seem to have issues once I open such files in irrlicht.
beer->setMotivationCallback(this);
Re: Thousands of trees? Model details/billboard
the example (the downloadable one) adds lots of planes ("plane.obj" is the file in question).
It seemed to only optimize lots of texture drawing. But i guess it helps in drawing models as well... (As seen with the dwarfs). Im maybe just a bit confused on what it does.
It seemed to only optimize lots of texture drawing. But i guess it helps in drawing models as well... (As seen with the dwarfs). Im maybe just a bit confused on what it does.
Re: Thousands of trees? Model details/billboard
It puts everything into one (or more?) mesh buffers and also batches textures into a bigger one (texture atlas) so the draw calls are reduced more or less to the minimum.suliman wrote:the example (the downloadable one) adds lots of planes ("plane.obj" is the file in question).
It seemed to only optimize lots of texture drawing. But i guess it helps in drawing models as well... (As seen with the dwarfs). Im maybe just a bit confused on what it does.
Working on game: Marrbles (Currently stopped).
Re: Thousands of trees? Model details/billboard
You can batch static models, you cant animate batched models.serengeor wrote:suliman wrote:But i guess it helps in drawing models as well... (As seen with the dwarfs).
Got fps 150 -> 300 when batched my grass.
Code: Select all
array<IMeshSceneNode*> nodes;
for(int q=0;q<10000;q++)
{
const float S=50;
float x = ((float)rand()/(float)RAND_MAX) * S - (S/2.f);
float z = ((float)rand()/(float)RAND_MAX) * S - (S/2.f);
node->setPosition(vector3df(x,0,z));
nodes.push_back(node);
}
CMeshCombiner* combiner = new CMeshCombiner(0.8f, ETPT_TILE);
IMesh* combinedMesh = combiner->combineMeshes(sceneManager, nodes, "../media/grass.irrmesh");
IMeshSceneNode* k = sceneManager->addMeshSceneNode(combinedMesh);
k->setMaterialFlag(EMF_LIGHTING,false);
Re: Thousands of trees? Model details/billboard
ok seems cool, will look into it more
Can i still rotate, move and scale the individual nodes even if their meshes is combined or how does this work? Seems like it from the picture with the dwarves. So only drawback is no animation? Can i remove one of them later on or do i need to redo the combination then?
erik
Can i still rotate, move and scale the individual nodes even if their meshes is combined or how does this work? Seems like it from the picture with the dwarves. So only drawback is no animation? Can i remove one of them later on or do i need to redo the combination then?
erik
Re: Thousands of trees? Model details/billboard
Code: Select all
Can i still rotate, move and scale the individual nodes even if their meshes is combined or how does this work?
Code: Select all
Can i remove one of them later on or do i need to redo the combination then?
so no need to re-create it.