I’m working on a small strategy game based on a simple grid. The player can build roads just the way you might know it from games like SimCity (Click → Drag → Click again → road built).
Right now, basically as a proof of concept, I’m doing this by placing flat boxes along the path the player has selected, each the size of one tile. While I’d like to keep the tile-size as the common denominator (makes it easy to delete single tiles later-on) I figure that using “boxes” is a waste of resources, since the height of the boxes doesn’t matter (visually, a road is flat) and only one side is visible (the top one). When placing several hundred such tiles, frame rates drop considerable when watching the area from a distance.
So my question is:
What should I use instead of boxes?
What else can be done to optimize this? I’m worrying about this since these tile-boxes - although many - are the only thing rendered right now and the framerate already drops well below 30fps.
Background info: I’m using jME3 and this is my first step into 3D-dev, hence the simple setting for now and the possible lack of correct terminology.
Optimise eitehr by batchcreator (Combine all tiles from start to end)
Or by useing streached Quat’s
1x2 road 1 tile with repeating texture
For this a texture atlas might be a good Idea, so that all roadparts share the same texture, only different texturecoordinates. That way you should be ablot to combine them more easily. I suggest also a look at batchGeometryCreator class (or similar) it should provide a easy way to combine multiple geometrys into one, so that the object count decreases.
Basic tips for performance
→ as less object instanciatons for updating and rendering as possible. (So not create every update a new vector if a static vector wich you just fill the values in could do the job without much other problems as well
→ as less Geometries as possible (though up to 3000 is pretty save on modern graficcards)
After some fiddling to get the quad placed right this was exactly what I was looking for, although the frame rates remained almost equally poor after switching to quads instead of boxes. Afterall, GeometryBatchFactory did the trick and framerates remain high unless I place enormous amounts of tiles.
In the future, further optimization will probably be required. But for now it works like a charm. Thanks again!
@Alpedar: I think this is not what I’m looking for in this case. Thanks anyway!
@All: Is there a general “cheat-sheet” on JME3 optimization on the wiki? I suppose there are many tricks that one simply has to know about, be it JME-specific or related to 3D graphics in general. It might make for a nice reference and could avoid a lot of newbie questions like mine.