So I’m starting to build a 2d game engine using quads, so I’m building a tile base as the bg… I’ve created a tile class that holds the spatial and lets you set its material and texture… since i don’t want to make copies of the same tile and instead just reuse it… i was thinking of putting the tile into an empty node, and moving the node to the correct position but i don’t know what takes up more resources, cloning the geometry and changing it’s location, or adding the geomery to a node, and moving the nodes location…
- You can move the geometry no reason to create an extra node.
If you want speed :
- texture atlas: all tiles use the same material, which is a picture that contains all possible tiles.
- Convert Multiple quads into a single quad. If they are near and have same “tile”, e.g for the ground.
Ah, so i should be creating multiple tiles, but have all the tiles using the same texture share a material?
so like, quad1 would be at 0.0f,0.0f,0.0f
quad2 would be at 2.0f, 0.0f, 0.0f
quad3 would be at 4.0f, 0.0f, 0.0f
but they would all use the material with the “dirt” texture
as for number 2 of your suggestions… i’m fairly new at this, so i’ll stick with individual quads for now, but that’s a good thing to remember… Thanks!
Actually, if you want optimum performance you want to bundle your quads together into one geometry. That’s the point of using one material with a texture atlas. You’d have a single grid mesh that uses texture coordinates to show the right tile.
Otherwise, using multiple materials is fine. Even if you wanted to use one material for multiple tile quads you’d still have to mess with the texture coordinates of the quads.
You asked about which is better, node or geometry… which implies that you are looking for “best performance”. If you are not then the difference isn’t really important as it’s teeny tiny compared to everything else.
Put another way, sending 100 meshes (quads) to the graphics card is 100 times more expensive than sending just 1. A nanosecond here and there isn’t going to matter much.
good to know… so would it be possible to do the whole game on a single quad? like several layers and such… using the quad as a sort of “screen” where the tile images show up?
(obviously i’m very new to game programming, 2d or 3d)
If you are doing a 2D side-scroller with multiple layers then you could use a mesh (not a quad) per layer. This is presuming your tiles (for a layer) are all the same size. In this approach, you’d make a single mesh per layer that consisted of a grid of quads.
But you know, there are a thousand things to worry about that are way more important. If you are new to game programming then just use quads like you are. Maybe have a node per layer to hold all of the tile-placed geometries for that layer… so moving the layer around is just a matter of moving the node.
If you are doing this in the 2D guiBucket of some kind then you could do thousands and thousands of quads this way and your frame rates will still be interactive. The true 3D render buckets have a little more overhead but you could still get quite far with this approach before it would be necessary to come back and optimize. And by then you may have much more of your game already done.
good to know, the quads->node was going to be my approach, and I was working on a non-grid (therefore possibly not equal size) “objects”, tiles were just easier to explain… I think i’ll keep the direction i’m going since this is my first attempt in any rate. Thanks for all the help!
I would say as long as you stay below 3000 quads you will be safe on any machine.
also remember to use GeometryFactory.optimize(node);
on the stage to increase performance by 3000%.
thanks for the tips! i’m sure i’ll have many more questions along the way as i get going