Best way to render flat surfaces (like roads)?

Hi everybody,

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.

    Thank you very much for your help.

Quat, as it is only 2d

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)


Thanks EmpirePhoenix!

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!

Look into hello terrain tutorial.

Either use it whole, or use material from it. It allow you to specify in one texture which other texture should be used to draw given pixels.

@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.

Hm thinking about how often I answerd a similar Question I suppose there is none. But there definitly should be one.

Well then…I took the liberty to create a starting point using the information I received in this thread. Please check whether it’s actually correct :wink:

Would be awesome if the list would be continued bit by bit.

EDIT: D’oh, forgot the link: