[SOLVED] [NooB] Tips for 3D in a Heroes Of M&M - like ga
The 4fps problem is too much static mesh data (200,000 vertices) being passed to the graphics card each frame. Irrlicht doesn't (yet) support hardware mesh buffers, there is a patch for this but it's currently broke.
For the moment, I suggest stealing the code from irrSpintz's opengl driver and deriving your own static mesh scene node that uses the new draw calls, you'll see a massive fps increase on systems that support hardware vertex+index buffers (all modern cards)
For the moment, I suggest stealing the code from irrSpintz's opengl driver and deriving your own static mesh scene node that uses the new draw calls, you'll see a massive fps increase on systems that support hardware vertex+index buffers (all modern cards)
Hi bitplane,
Thanks for the answer, and especially for the explanation (it helps me understand some things )
I'll try to have a look at it, but since the octree thing works at the moment, I will may be stick to it and work on the graphics (I mean modeling).
Thanks anyway, and if you have advices for the 2 other quesitons, I am you man
Good night,
Thanks for the answer, and especially for the explanation (it helps me understand some things )
I'll try to have a look at it, but since the octree thing works at the moment, I will may be stick to it and work on the graphics (I mean modeling).
Thanks anyway, and if you have advices for the 2 other quesitons, I am you man
Good night,
--
Lideln, France
Lideln, France
re: 2
check out prosoft's demo for quad-tree node culling and a LODSceneNode and animator for fading between different levels of detail. you'll need to make an opengl material renderer for vertex alpha and texture alpha together, or just not use alpha channel textures in your lod meshes. if you want to go the whole hog, you could replace the lowest detail level with my mariokart billboard, but you'd need to edit the texture generator and billboard node to display spherical rotation rather than cylindrical. (trivial)
re: 3
oct-trees can only take you so far without hardware buffers. if you dont want to use these, you could use the LODSceneNode again to control level of detail, or use a bunch of terrain nodes with a low level of detail set on the distant ones
check out prosoft's demo for quad-tree node culling and a LODSceneNode and animator for fading between different levels of detail. you'll need to make an opengl material renderer for vertex alpha and texture alpha together, or just not use alpha channel textures in your lod meshes. if you want to go the whole hog, you could replace the lowest detail level with my mariokart billboard, but you'd need to edit the texture generator and billboard node to display spherical rotation rather than cylindrical. (trivial)
re: 3
oct-trees can only take you so far without hardware buffers. if you dont want to use these, you could use the LODSceneNode again to control level of detail, or use a bunch of terrain nodes with a low level of detail set on the distant ones
Hi !
Dibalo, Im sorry, I did not see your answer.
Thank you Dibalo and Bitplane for your help. I'll try to take advantage of what you told me to progress (but Bitplane I must admit I did not understand anything of your question 2 answer lol do not forget I do not have your level and experience )
Thanks again ! Ill post a reply later to give results
Dibalo, Im sorry, I did not see your answer.
Thank you Dibalo and Bitplane for your help. I'll try to take advantage of what you told me to progress (but Bitplane I must admit I did not understand anything of your question 2 answer lol do not forget I do not have your level and experience )
Thanks again ! Ill post a reply later to give results
--
Lideln, France
Lideln, France
hmm which part didn't you understand? I'll try and explain...
LOD Scene Node = swaps one node for another depending on distance from the camera. In Prosoft's demo, the trees get more complex as you approach them.
QuadTree = a way of culling nodes based on their size and distance (in the demo, small plants are not visible from a distance, everything outside the camera's view has setVisible(false) )
Fade in/out animator: a scene node animator that sets the transparency of the mesh (vertex alpha) to make things fade in and out.
MaterialRenderer = a class that sets the render states for drawing, see the docs. In the demo, everything fades in and out instead of just appearing. This uses a new directx material renderer, which does texture transparency (alpha channel) and mesh transparency (vertex alpha) together. you'd need to make this for opengl if you want smooth fading between detail levels like in the demo
your project is off to a good start, hope this all helps
LOD Scene Node = swaps one node for another depending on distance from the camera. In Prosoft's demo, the trees get more complex as you approach them.
QuadTree = a way of culling nodes based on their size and distance (in the demo, small plants are not visible from a distance, everything outside the camera's view has setVisible(false) )
Fade in/out animator: a scene node animator that sets the transparency of the mesh (vertex alpha) to make things fade in and out.
MaterialRenderer = a class that sets the render states for drawing, see the docs. In the demo, everything fades in and out instead of just appearing. This uses a new directx material renderer, which does texture transparency (alpha channel) and mesh transparency (vertex alpha) together. you'd need to make this for opengl if you want smooth fading between detail levels like in the demo
your project is off to a good start, hope this all helps
Hi Bitplane,
I did not understand anything lol but I am a really beginner in 3D, so every word you used in that part of your answer was totally new for me.
- Mmmmh... So, LODSceneNode does the swap by itself ? Ill have a look at the irrlicht api for that, dont worry, but it seems "magical"
- So QuadTree is better than Octree ? (since there is a distance factor that's added to spare some displays, as far as I understood ) But does QuadTree optimize animated meshes as well ? Because I understood (unless Im mistaken) that Octree does not allow animated meshes (so when I will put animated meshes on the map, they won't be optimized so my FPS will fall I think ?)
- Fade animator : does it work automatically, like the LODSceneNode ?
- MaterialRenderer : I will look at the docs It seems to be like the Fade animator ? I'm afraid that making a 3D engine class for OpenGL is far over my competences (knowledge), I am ("could be", to be less pretentious) just able to write a game engine, not a 3D one
Thanks for your help and support. My project is a test project but I would really like to continue it, and finish it. I have the will, but not the sufficient 3D knowledge...
If you know of a good web site to progressively learn 3D things (words, etc.) I would love to bookmark it and read it often ('cause the only 3D book I tried to read is the 3D Gems, but I stopped reading it quite quickly... too hard for me )
Thanks again for your help !
ps : Ill of course have a deep look at the demo and the api
I did not understand anything lol but I am a really beginner in 3D, so every word you used in that part of your answer was totally new for me.
- Mmmmh... So, LODSceneNode does the swap by itself ? Ill have a look at the irrlicht api for that, dont worry, but it seems "magical"
- So QuadTree is better than Octree ? (since there is a distance factor that's added to spare some displays, as far as I understood ) But does QuadTree optimize animated meshes as well ? Because I understood (unless Im mistaken) that Octree does not allow animated meshes (so when I will put animated meshes on the map, they won't be optimized so my FPS will fall I think ?)
- Fade animator : does it work automatically, like the LODSceneNode ?
- MaterialRenderer : I will look at the docs It seems to be like the Fade animator ? I'm afraid that making a 3D engine class for OpenGL is far over my competences (knowledge), I am ("could be", to be less pretentious) just able to write a game engine, not a 3D one
Thanks for your help and support. My project is a test project but I would really like to continue it, and finish it. I have the will, but not the sufficient 3D knowledge...
If you know of a good web site to progressively learn 3D things (words, etc.) I would love to bookmark it and read it often ('cause the only 3D book I tried to read is the 3D Gems, but I stopped reading it quite quickly... too hard for me )
Thanks again for your help !
ps : Ill of course have a deep look at the demo and the api
--
Lideln, France
Lideln, France
Hi everybody !
Here are news of this test project !
Why a sad smiley ? Because I have bad news (at least for me lol)
I am using the octree, as I have been wisely advised.
I was displaying 100 octree trees (the trees you can see in the forest), each tree is : 4 nodes and 68 polycount (as told by the irrlicht output).
This tree in blender counts 68 vertices and 50 faces.
I ran at 130 fps
But since in a Heroes Of Might And Magic level, there are more than 100 trees, I act as a fool and put not less than 2500 trees on the map
The code to display them is :
one question : each time, irrlicht computes an octree... But it is the same tree each time ! So it needs about 20seconds to load the map... Can I save some time with a workaround, like maybe only one calculation, and just duplicate the result ?
But this is not the purpose of my new post...
With these 2500 trees, and that EVEN if I place the camera where nothing is displayed, I run at 10fps
Graaa !!!!!!! You all are writing many great games and demos, why can't I display a standard map with trees on it ?
I am begging for help : I'm not a 3D developer, my purpose is the game engine, and at the moment I'm wasting (not wasting but spending) all my time to get a simple map with meshes on it displayed with a decent framerate...
and I have to precise that I still can't apply a texture (with roads, grass, etc.) on my map... It becomes all dark green when I call :
Thank you all for your time and help !
(and patience with me )
Here are news of this test project !
Why a sad smiley ? Because I have bad news (at least for me lol)
I am using the octree, as I have been wisely advised.
I was displaying 100 octree trees (the trees you can see in the forest), each tree is : 4 nodes and 68 polycount (as told by the irrlicht output).
This tree in blender counts 68 vertices and 50 faces.
I ran at 130 fps
But since in a Heroes Of Might And Magic level, there are more than 100 trees, I act as a fool and put not less than 2500 trees on the map
The code to display them is :
Code: Select all
mesh = hotp->scene->getMesh("data/objects/arbre2.obj");
for (int j = 0; j < 50; ++j)
{
for (int i = 0; i < 50; ++i)
{
// Add another copy
ptiga = hotp->scene->addOctTreeSceneNode(mesh->getMesh(0));
// No global light, so...
ptiga->setMaterialFlag(video::EMF_LIGHTING, false);
// Align the copies in a row
ptiga->setPosition(vector3df(0 + 4 * i, 10, -10 + 4 * j));
}
}
But this is not the purpose of my new post...
With these 2500 trees, and that EVEN if I place the camera where nothing is displayed, I run at 10fps
Graaa !!!!!!! You all are writing many great games and demos, why can't I display a standard map with trees on it ?
I am begging for help : I'm not a 3D developer, my purpose is the game engine, and at the moment I'm wasting (not wasting but spending) all my time to get a simple map with meshes on it displayed with a decent framerate...
and I have to precise that I still can't apply a texture (with roads, grass, etc.) on my map... It becomes all dark green when I call :
Code: Select all
node->setMaterialTexture(0, hotp->driver->getTexture("data/levels/map1.jpg"));
Thank you all for your time and help !
(and patience with me )
--
Lideln, France
Lideln, France
Your FPS problem has already been addressed by a developer. You need to either look into hardware vertex buffers or use LOD.
As for your green world... you already said earlier that the UV data of the mesh was not being exported.... in this case what you are seeing is a single pixel of your texture being stretched across the entire mesh. You need to either use a different model type or learn how to export UVs from your 3D modeler. (I used Lightwave so anything other than that and I cannot help you.)
David
As for your green world... you already said earlier that the UV data of the mesh was not being exported.... in this case what you are seeing is a single pixel of your texture being stretched across the entire mesh. You need to either use a different model type or learn how to export UVs from your 3D modeler. (I used Lightwave so anything other than that and I cannot help you.)
David
Hi Dloomis
Oh yes you are talking about the post of Bitplane, thats true I forgot this one, and yes, he gave me a solution, sorry for this thing I forgot (I really have bad memory, not only a joke).
But one thing... You say "use LOD", but unless Im mistaken it is used to display meshes that are far from the camera, but still visible, with less details ? For me, I dont have anything in the camera field of view, so maybe the Hardware vertex buffer is a great idea.
I already downloaded the demo Bitplane told me about yesterday, and looked at the code, but this is not very easy for me to understand everything since Im a beginner in 3D, so it may take me a long time before finding where the hardware vertex buffer is But Im currently looking at it
For the map, I thought it would have placed the texture all over the map. In the example 12 from Irrlicht sdk, they don't use a mesh to display the map, so they dont have a UVmap, but the texture is still correctly displayed, I thought it would have been the same.
Isn't it a bit "too much" to use a UVmap to texture a level ?
Anyway, Ill try again the UVmap thing (I had issues the first time I tried to use it), and Ill tell you the results.
Thanks for your reply
Oh yes you are talking about the post of Bitplane, thats true I forgot this one, and yes, he gave me a solution, sorry for this thing I forgot (I really have bad memory, not only a joke).
But one thing... You say "use LOD", but unless Im mistaken it is used to display meshes that are far from the camera, but still visible, with less details ? For me, I dont have anything in the camera field of view, so maybe the Hardware vertex buffer is a great idea.
I already downloaded the demo Bitplane told me about yesterday, and looked at the code, but this is not very easy for me to understand everything since Im a beginner in 3D, so it may take me a long time before finding where the hardware vertex buffer is But Im currently looking at it
For the map, I thought it would have placed the texture all over the map. In the example 12 from Irrlicht sdk, they don't use a mesh to display the map, so they dont have a UVmap, but the texture is still correctly displayed, I thought it would have been the same.
Isn't it a bit "too much" to use a UVmap to texture a level ?
Anyway, Ill try again the UVmap thing (I had issues the first time I tried to use it), and Ill tell you the results.
Thanks for your reply
--
Lideln, France
Lideln, France
Even though they're not on screen they are still being sent to the meshbuffer... so the idea is to reduce the total number of triangles to under the maximum. Are the trees placed randomly? If so... try to create a function that generates the trees for your map in several groups and then turn off trees that are a certain distance away (the simplest LOD) to keep the maximum number of trees down.
You don't need to do alot of complicated math necessarily.
edit: I looked back over some things and a couple of things sprang to mind:
about the OCTrees... you could load them into irrEdit and use the resulting DAE files which I think save the OCTree.
Also, I'm pretty sure the irrlicht example works because they generate texture coordinates for their terrain shape.
UV mapping flatish objects isn't hard... use planar mapping pointing straight down and then the texture will apply.
(screenshots help with this kind of thing)
David
You don't need to do alot of complicated math necessarily.
edit: I looked back over some things and a couple of things sprang to mind:
about the OCTrees... you could load them into irrEdit and use the resulting DAE files which I think save the OCTree.
Also, I'm pretty sure the irrlicht example works because they generate texture coordinates for their terrain shape.
UV mapping flatish objects isn't hard... use planar mapping pointing straight down and then the texture will apply.
(screenshots help with this kind of thing)
David
things that are most expensive are-
sending lots of data to the graphics card (oct-tree for large meshes, steal Spintz's vertex buffers)
lots of separate draw calls (compare 1000 billboard nodes to a particle system)
the oct-tree and the quad-tree nodes are both culling methods, but they work on different scales. the oct-tree is a nice way to split a large mesh up so you don't send too much to the card.
prosoft's quad-tree is a container for lots of small nodes so you dont draw too many times (i stole the idea to make this). it doesn't make sense to put lots of small meshes into oct-trees, splitting them up will only make things go slower (lots of draw calls).
oh and there's no hardware buffers in prosoft's demo, they are in irrSpintz
sending lots of data to the graphics card (oct-tree for large meshes, steal Spintz's vertex buffers)
lots of separate draw calls (compare 1000 billboard nodes to a particle system)
the oct-tree and the quad-tree nodes are both culling methods, but they work on different scales. the oct-tree is a nice way to split a large mesh up so you don't send too much to the card.
prosoft's quad-tree is a container for lots of small nodes so you dont draw too many times (i stole the idea to make this). it doesn't make sense to put lots of small meshes into oct-trees, splitting them up will only make things go slower (lots of draw calls).
oh and there's no hardware buffers in prosoft's demo, they are in irrSpintz
Hi !
Thank you both for your answers !
Bitplane you are drawing soooooooooo many things in your demo !!!
I really have to have a look at this Quadtree (do I only have to get the .cpp and .h files and to call the quadtree somewhere ?)
Ill have a look because It is very fast !
For my project, I run now at 200-250 fps, because my map is now made of only a few faces (say 9 at the moment), then the draw is very fast ! (my old map was made of... I dunno, thousands of faces easily ! The difference is enormeous )
Thank for your idea, when I have the time I will make using Quadtree my priority !
Thank you both again, Ill be back
Thank you both for your answers !
Bitplane you are drawing soooooooooo many things in your demo !!!
I really have to have a look at this Quadtree (do I only have to get the .cpp and .h files and to call the quadtree somewhere ?)
Ill have a look because It is very fast !
For my project, I run now at 200-250 fps, because my map is now made of only a few faces (say 9 at the moment), then the draw is very fast ! (my old map was made of... I dunno, thousands of faces easily ! The difference is enormeous )
Thank for your idea, when I have the time I will make using Quadtree my priority !
Thank you both again, Ill be back
--
Lideln, France
Lideln, France
I finally tried the Quadtree thing
I simply copied the 2 files (cpp, h) in my src directory, and use a define to use (or not) the quadtree, like in their demo (but I do not use the LODSceneNode... At least not for the time being).
Before speaking of the results (comparison between not using it, and using it), I had a compile error... I checked the forums and Hybrid told in the "bugs report" that he changed the include orders.
Here is the "crashing" code (in CQuadTreeSceneNode.cpp) :
The line that generates the compile error is the commented one, the error is :
I could not get rid of it, and according to Hybrid this is not possible (otherwise he would have posted the workaround).
So, I always setVisible(true), so I guess there is a performance leak compared to the original code. If you have an idea on how to make it compile... I would be happy to learn it
Here is now the performance comparison between Octree and Quadtree (about Octree : it makes my map disappear if I add it as an OctreeSceneNode... CF the topic "triangles disappearing then reappearing")
The tests are made with a map composed of 9 simple faces (one face is a separate object in the .obj file), and 70 objects.
Octree :
Camera where there are all the objects : 160 fps
Camera where there are NO object : 330 fps
Quadtree :
Camera where there are all the objects : 190 fps
Camera where there are NO object : 190 fps
(this is normal since I always set setVisible(true) in the prerender(), as I told above)
Then, Quadtree seems far better !
(but I have not tested with about 300 objects though)
One question :
I'm only creating ONE QuadTreeSceneNode, and then adding ALL my objects to it... Is that good ?
Thank you again for that Quadtree thing
If you have the solution about the compile error, and also the answer for my last question (about the single QuadTreeNode usage), I would really be glad to read that
Good afternoon,
I simply copied the 2 files (cpp, h) in my src directory, and use a define to use (or not) the quadtree, like in their demo (but I do not use the LODSceneNode... At least not for the time being).
Before speaking of the results (comparison between not using it, and using it), I had a compile error... I checked the forums and Hybrid told in the "bugs report" that he changed the include orders.
Here is the "crashing" code (in CQuadTreeSceneNode.cpp) :
Code: Select all
void CQuadTreeSceneNode::OnPreRender() {
ICameraSceneNode* cam = smgr->getActiveCamera();
// bool vis = ( viewFrustrum->getBoundingBox().intersectsWithBox( bbox ) );// getTransformedBoundingBox() ) );
bool vis = true;
setVisible( vis );
SceneManager->registerNodeForRendering( this );
ISceneNode::OnPreRender();
}
Code: Select all
src/CQuadTreeSceneNode.cpp: In member function «virtual void CQuadTreeSceneNode::OnPreRender()»:
src/CQuadTreeSceneNode.cpp:72: erreur: invalid use of undefined type «const struct irr::scene::SViewFrustrum»
/home/renaud/Irrlicht/irrlicht_svn/include/ICameraSceneNode.h:16: erreur: forward declaration of «const struct irr::scene::SViewFrustrum»
So, I always setVisible(true), so I guess there is a performance leak compared to the original code. If you have an idea on how to make it compile... I would be happy to learn it
Here is now the performance comparison between Octree and Quadtree (about Octree : it makes my map disappear if I add it as an OctreeSceneNode... CF the topic "triangles disappearing then reappearing")
The tests are made with a map composed of 9 simple faces (one face is a separate object in the .obj file), and 70 objects.
Octree :
Camera where there are all the objects : 160 fps
Camera where there are NO object : 330 fps
Quadtree :
Camera where there are all the objects : 190 fps
Camera where there are NO object : 190 fps
(this is normal since I always set setVisible(true) in the prerender(), as I told above)
Then, Quadtree seems far better !
(but I have not tested with about 300 objects though)
One question :
I'm only creating ONE QuadTreeSceneNode, and then adding ALL my objects to it... Is that good ?
Thank you again for that Quadtree thing
If you have the solution about the compile error, and also the answer for my last question (about the single QuadTreeNode usage), I would really be glad to read that
Good afternoon,
--
Lideln, France
Lideln, France
Thanks for the workaround
Mmmmh... Then why do I gain 30fps with Quadtree ?
Ok, it now compiles successfuly, thanks !
But I do not see any performance gain
Maybe 10fps (I run between 190 and 200fps)
Ill try with more objects, but I am currently working on the map file format (the file containing all the objects positions etc.) so Ill try this when Im done with that, and Ill keep you informed of course
Mmmmh... Then why do I gain 30fps with Quadtree ?
Ok, it now compiles successfuly, thanks !
But I do not see any performance gain
Maybe 10fps (I run between 190 and 200fps)
Ill try with more objects, but I am currently working on the map file format (the file containing all the objects positions etc.) so Ill try this when Im done with that, and Ill keep you informed of course
--
Lideln, France
Lideln, France