I'm having strange performance issues in my scene.
One scene is a much higher FPS, although the number of meshes, tris and verts is much higher.
The problem:
A scene with less tiles, but more cities is much slower than a larger scene consisting of more tiles.
A scene with less tiles contains less meshes, and less tris/verts but still is slower.
Scene buildup:
the Hexagonal Tiles you see are Geometry batch instances, so the number of meshes is always the same as the number of type of tiles in the scene (around 9). Changing this does not change the FPS
the Beach addon on the Tiles, is a Geometry batch instance, 1 mesh, does not change
the Cities on the tiles are seperate nodes. So more = more meshes/nodes, n cities = n nodes
On each corner of a Hexagonal Tile is a Building position node, with a Box. But this entire Node is set to CULL_ALWAYS.
On each side of a Hexagonal Tile is a Road Position node, with a Box. But this entire Node set to CULL_ALWAYS.
Both are used in the UI construction process to position a building.
Speed ups implemented:
Backface Culling
SharedMesh (at first, now switched to:
Geometry Instancing.
No Lighting -> Lightmapped to texture
Opaque Render setting
Waterpass -> No reflection
Locking all meshes
setTwoPassTransparency(false);
Update looks like:
public void update(float tpf) {
// Update the InputHandler
if (input != null) {
input.update(tpf);
}
// Update the passes
pManager.updatePasses(tpf);
}
Disabling Water Render Pass or the updatePasses from Manager gives almost no speed bonus. (1-2FPS)
Game implemented using StandardGame.
jME 1, jME 2 gives no significant speed bonus.
The only thing I can think of, is that the amount of nodes within a scene increases, but these do not necessarily contain any meshes. They are used for positioning etc.
That's about all, any help would be greatly appreciated because I've been banging my head on this one for the past few days.
do you add things to your scene and it gets faster as you add things?
OR: do you remove things from your scene and it wont get faster (or even slower)?
I had a similar problem once, and it turned out to be the following:
I removed things from the scene graph but i still updated them manually in the various update() methods. Like that even if you remove things that you dont need anymore from the scene graph, they still cost you FPS. plus: it seemed that i was lazy and had a lot of garbage still referenced somehow -> no garbage collection -> high memory consumption -> PC starts writing to the page file -> Performance goes down
Another possibility: since shaders and textures are more expensive (performance-wise) than loads of triangles, even less triangles can be much more expensive when you apply bit textures or even the simplest shaders on them.
The scene gets slower if I add Tile OBJs, but not City OBJs.
The only difference is that the Tile OBJ also create (empty) Nodes.
But not in a huge bizarre number. First picture has about 100 empty nodes (grouped under 1 node which is set to CULL AUTO, and lockBranch(). The second picture has about 25 empty nodes in the same setup.
The first picture is after a one-time setup, the second after a different one-time setup and manually adding meshes ("cities"). The framerate does not drop if I add the cities, which adds about a 20.000 tris/verts + 20 meshes/nodes.
Garbage collection is not an issue, the game runs on about 40-60mb vm and does not get larger.
I have 4GB RAM, so no paging-file issues.
The textures and model setup for the Tiles and Cities are the same:
Oh glorious jME, how could I ever have doubted thee :D :mrgreen:
I found the problem, and it seems the extreme drop in FPS is the fault of the Chat like TextField from FengGUI.
And when I mean extreme, the difference on scene 1 is around 160 FPS. (from 90 to 240-280 FPS)
But, because I thought the source was jME I applied every speed up I could think of, and gained an increase of around 90 FPS on the original version. So all the effort was not in vain…
I think it has to do with text rendering, but I'm not all too sure. Gonna look into it now.
The bigger the text within the TextArea, the larger the FPS drop.
And no, I am not updating it too often. Even an update every 20 seconds gives the drop.
The drop happens the moment the TextAreadisplays it's text, and is linearly connected to the amount of text within the TextArea.
I'll try to revert back to the FengGUI SVN to see if the drop is because of the TextAreaitself, or changes I made to the ContentFactory to support textstyles and emoticons.
(In theory they shouldn't be a problem, because the construction only takes place on text updates to the TextArea.)