drawing optmization?
drawing optmization?
hello everybody.
i'm trying to make a simple city generator in Irrlicht. it just make random blocks and streets and puts random buildings in it. now that it's starting to work, i've come across a problem: how to optimize the drawing?
i've made some tests on polycount. the texture and UV is the same in all of them.
in the first and second tests, only 212 nodes. and in the third and fourth, 1908 nodes.
1st- 212nodes * 12tris = 2544 tris. runs at 50fps.with octree, 48~51fps.
2nd-212nodes * 2352tris = 498624 tris. runs at 28fps. with octree, 20fps.
3rd- 1908nodes * 12 tris = 22896 tris. runs at 15~16fps. with octree, same thing.
4th- 1908nodes * 2352 tris = 4487616 tris. runs at 4fps. with octree, 3fps.
my question is why the 3rd test, which have 475728 tris less than the 2nd test, runs at a so low fps? simply adding sceneNodes cause this performance loss? each building is a new node, although the mesh is loaded only once.
here goes a screenshot of what its looking like.
i don't need 2352tris in each building, but something near 1000 would be fantastic. so, i need help on how to optimize the performance. is there any tricks to do it that i'm missing?
any suggestions are really apreciated. thanks in advance
i'm trying to make a simple city generator in Irrlicht. it just make random blocks and streets and puts random buildings in it. now that it's starting to work, i've come across a problem: how to optimize the drawing?
i've made some tests on polycount. the texture and UV is the same in all of them.
in the first and second tests, only 212 nodes. and in the third and fourth, 1908 nodes.
1st- 212nodes * 12tris = 2544 tris. runs at 50fps.with octree, 48~51fps.
2nd-212nodes * 2352tris = 498624 tris. runs at 28fps. with octree, 20fps.
3rd- 1908nodes * 12 tris = 22896 tris. runs at 15~16fps. with octree, same thing.
4th- 1908nodes * 2352 tris = 4487616 tris. runs at 4fps. with octree, 3fps.
my question is why the 3rd test, which have 475728 tris less than the 2nd test, runs at a so low fps? simply adding sceneNodes cause this performance loss? each building is a new node, although the mesh is loaded only once.
here goes a screenshot of what its looking like.
i don't need 2352tris in each building, but something near 1000 would be fantastic. so, i need help on how to optimize the performance. is there any tricks to do it that i'm missing?
any suggestions are really apreciated. thanks in advance
Re: drawing optmization?
More nodes means there will be more draw calls which should be kept low. If static objects share materials and textures it would be ideal to batch them into a single object.
There were lot's of questions like this before, if you need more information search through those.
There were lot's of questions like this before, if you need more information search through those.
Working on game: Marrbles (Currently stopped).
Re: drawing optmization?
a single object? but i want the program to check which building individually is colliding with a mouse ray. is that possible to be made if i batch everything in a single object?
EDIT: oh sorry, i found a clue here:
http://irrlicht.sourceforge.net/forum/v ... es#p279306
thanks
EDIT: oh sorry, i found a clue here:
http://irrlicht.sourceforge.net/forum/v ... es#p279306
thanks
Re: drawing optmization?
Doesn't have to be a single object. But object count should be kept as minimal as possible.Stauricus wrote:a single object? but i want the program to check which building individually is colliding with a mouse ray. is that possible to be made if i batch everything in a single object?
And you can use different objects for physics/collision than graphics (if possible of course).
Working on game: Marrbles (Currently stopped).
Re: drawing optmization?
ok, got it. but sorry, i'm not being able to do it
i've made a single node, but how to add meshes to it?
the only functions i found are for adding sceneNodes, but this will not improve anything...
also, should i use meshBuffers to do it? because my models have a single texture UV mapped.
EDIT: and although i'll put many meshes in a single big one, is it possible to keep individual animations (or atleast animations at all)?
i've made a single node
Code: Select all
irr::scene::IMeshSceneNode* map_node;
the only functions i found are for adding sceneNodes, but this will not improve anything...
also, should i use meshBuffers to do it? because my models have a single texture UV mapped.
EDIT: and although i'll put many meshes in a single big one, is it possible to keep individual animations (or atleast animations at all)?
Re: drawing optmization?
You add as much geometry as possible to single meshbuffer, this way you will only have to make draw calls for one/few meshbuffers. Search for mesh batching for more info.Stauricus wrote:ok, got it. but sorry, i'm not being able to do it
i've made a single node
CPP CODE: SELECT ALL
irr::scene::IMeshSceneNode* map_node;
, but how to add meshes to it?
Animated objects should probably be instanced. But I wouldn't bother to do that unless you also have lots of them.Stauricus wrote: EDIT: and although i'll put many meshes in a single big one, is it possible to keep individual animations (or atleast animations at all)?
Working on game: Marrbles (Currently stopped).
Re: drawing optmization?
well, i coudn't find how to instance objects in irrlicht... do i have to do it directly through opengl?
also, i found CBatchingMesh and MeshCombiner here in the forum. but i wasn't able to understand how it's done... to do it manually do i have to create meshbuffer, then put it together, then create meshes and add it to a node?
i found many and many topics saying to batch meshes in order to get better performance, but none explains how to do it..
also, i found CBatchingMesh and MeshCombiner here in the forum. but i wasn't able to understand how it's done... to do it manually do i have to create meshbuffer, then put it together, then create meshes and add it to a node?
i found many and many topics saying to batch meshes in order to get better performance, but none explains how to do it..
Re: drawing optmization?
I don't think it's in irrlicht core yet, but afaik it's somewhere on forums too. (I think devsh wrote a patch )Stauricus wrote:well, i coudn't find how to instance objects in irrlicht... do i have to do it directly through opengl?
There's not much to explain really, all you have to do is put the meshes into single meshbuffer. To do that correctly you will need to understand how to make indices correct and transform the vertices.Stauricus wrote:also, i found CBatchingMesh and MeshCombiner here in the forum. but i wasn't able to understand how it's done... to do it manually do i have to create meshbuffer, then put it together, then create meshes and add it to a node?
i found many and many topics saying to batch meshes in order to get better performance, but none explains how to do it..
Try to do this with for example two transformed cube nodes or something similar.
Working on game: Marrbles (Currently stopped).
Re: drawing optmization?
well, i'm trying to do it like this:
but it get a segfault error at the last line. geez this thing i consufing
Code: Select all
irr::scene::IMesh* test_building = smgr->getMesh("building1.obj");
irr::scene::SMesh* test_map;
test_map->addMeshBuffer(test_building->getMeshBuffer(irr::u32(0)));
Re: drawing optmization?
Uhm, it will be since I see you don't really have good knowledge of c++.Stauricus wrote:well, i'm trying to do it like this:but it get a segfault error at the last line. geez this thing i consufingCode: Select all
irr::scene::IMesh* test_building = smgr->getMesh("building1.obj"); irr::scene::SMesh* test_map; test_map->addMeshBuffer(test_building->getMeshBuffer(irr::u32(0)));
Code: Select all
irr::scene::SMesh* test_map;
Working on game: Marrbles (Currently stopped).
Re: drawing optmization?
oops, you're right. i forgot to change that.
sure i don't have a good c++ knowledge. that's why i'm still in Irrlicht Begginer's forum AND C++ Begginer's forum.
thanks for the help
sure i don't have a good c++ knowledge. that's why i'm still in Irrlicht Begginer's forum AND C++ Begginer's forum.
thanks for the help