I thought of putting this code snippets, but at more than 700 lines of code, I think this is a better spot

This is a mesh combiner I made. Not only does it combine the meshes, but it combines their textures so the whole group can be drawn in one call. This speeds up drawing immensely in some cases, and I have the code and a test case included.

Things to note: It only support S3DVertex as of yet, but I plan on adding the other two types soon. It also does not support animation, and that will come later if ever. Also, as with any use of a texture atlas TILING TEXTURES ARE BROKEN BY THIS.

Screenshots:

Using scene nodes:

Using mesh combiner:

Keep in mind that the tiles have separate textures and they are being combined by the mesh combiner. It even corrects the uv's!

Two help against bleeding of separate textures in mipmaps, the mesh combiner gives two methods. One, is too expand the texture according to the padding amount (this is a texture atlas for the tiles created by the class):

The second method is to tile it according to the texture padding:

This eliminates most (but not all) problems associated with mipmapping.

Combining mesh scene nodes applies their transformations to the mesh and then combines it. It also corrects the normals and uv's so it looks exactly the same as the separate meshes. Also, feel free to add as many meshes as you need. If the 16 bit index limit is reached, a new mesh buffer is added, so you can add as much as you like.

Thanks guys. I'm also thinking about adding a function that only combines textures, then fixes the coordinates of any meshes using one of those textures. This way, you could get speedup in any program on both static and animated meshes. It's not as fast as rendering all geometry in one go, but it should save the time it takes to switch textures.

Virion wrote:wow great performance boost! i'll sure be using this in my game.

That's good to hear Just note though, the most speed is gained when tons of meshes are combined. If only a few are, the speedup isn't huge. But in this cases with 10,000 nodes, the speedup was enormous.

omg it really has great performance speedup!
w/o using it i got 15 fps, with using i got 1028 O.o this IS really something.
ill try to integrate it on my previous project lets see how much will it be better :3

This is an excellent piece of work. Nicely done. I should really post my texture atlas generator soon - it's like the second part of your work (it combines textures), but the mesh implementation is left up to you. It works really nicely with tiled textures, and it uses a binary tree algorithm to pack the atlas in as little space as possible.

To test out rotation+translation and correction of normals, I made a block of 300 dwarves, ninjas, and chess pieces

Scene Nodes:

Mesh Combiner:

25 fps vs 176. Not the same magnitude of speed up as the first, but this is because it using fewer nodes. And, as you can see, transformation is applied correctly and normals are also recalculated correctly.

EDIT: If you look closely at the windows it seems I keep picking the wrong renders But both directx versions and opengl run at roughly the same speed on my computer, so the comparison should still be valid.

i catched an error.
there was a warning that 2 default constructor declared. didnt know why but i found that u give default parameters for the 3 parameter constructor. So if i use: new CMeshCombiner() <- then it wont know which constructor should it use ^^

And i tried it out in my project, but didnt give me performance boost, so i guess its a different problem in my game.

First of all, i want to say that this is very nice. it really speeds up everything. but i am getting a problem. what i want to do is draw a lot of cube. With a millions of them it crash. i am not sure why..
800 000 cube is fine and fps is very good.
any idea why it would crash at 1 million?

It's quite possible that irrlicht itself cannot handle that many scene nodes. Or it may be that the program runs out of memory. If you could, please send me your code through a pm or something and I'll try to help more.