Performance drop with more than 800 trimesh

State changes (each material requires a different GL state) are costly. You can use geometry instancing and a custom shader instead of material… but that's quite advanced. Do you really need those different materials? Probably you can put many of your small meshes into a big one and change color for the parts or similar?

I do not know the internals of graphics cards etc, but it sure sound like… up to a certain point, the program manages to cache the information and accessing it is fast. However after the limit is exceeded - in your case you have 800 objects it will need to swap data all the time… not everything fits in the fast cache… so it creates basically a 'line' after which performance drops fast.

… sigh… another useless comment by me but I like posting and talking 

btw. another optimization might be locking your meshes (or parts of them, eg. geometry).

Thank you for your suggestions. I'll try to experiment something and i'll keep posting.


There are countless things that can slow your app down. First of all run a profiler on your app. Why you need 800 small meshes in the first place?

Modern graphics cards hate getting lots and lots of small meshes.  If you can replace these with a few large meshes, you'll run much better.

Rather than adding 100 individual small trees to a terrain - would it be more performant in joining them as part of one big mesh ( transparently linked )

irrisor said:

btw. another optimization might be locking your meshes (or parts of them, eg. geometry).

What operations does jME perform on a mesh/geo that isn't locked, vs. one that is?  (I don't have this performance issue yet, but I may further in my development process)

i've finally solved merging trimeshes.

Now i've to face multitexturing :slight_smile:

Thanks to everybody answered :wink:


mastershadow said:

i've finally solved merging trimeshes.

Out of interest, how did you do it ??

my datasource is hierarchical so i've a surface made of all small polygons.

to merge meshes i've triangulated the polygons and then i've added vertices, faces (considering vertices offset per polygon) and normals.

the problem i'm facing now is about texturing. every polygon in the surface may have a texture and i need to do multitexturing over the whole merged trimesh.

Does anyone has a suggest? :slight_smile: