- Edited
Do you prefer to use multiple sprites with individual textures, or a single sprite and swap its texture and frame parameters during runtime?
Do you prefer to use multiple sprites with individual textures, or a single sprite and swap its texture and frame parameters during runtime?
Well, for the purposes of performance, it is usually considered better to bundle up as many of your sprite images as possible into a single image/texture. When textures get swapped out in memory for rendering on the GPU, it affects performance. The smaller the number of texture swaps, the more efficient the rendering. So having multiple sprites using the same texture image would be the more performance-friendly approach, even if it can make things a little harder to keep track of.
There is however one extra thing to keep in mind: Different cards have different limits in regards to maximum texture resolutions supported.<br><br>So figure out the lowest common denominator for the range of hardware you intend to support.<br>
It's not as common as it used to be, but yes, this is something to consider.<br id="null"><br id="null">For instance, the old Voodoo line of cards (3Dfx) had a limitation where the only textures they would support would be ones whose dimensions were a power of 2. So if you tried to feed a texture into them that was 512px to a side, you'd be good to go. But if you tried to use a 480x320px image as a texture, they would choke on it and it wouldn't display correctly.<br id="null"><br id="null">Today, these limitations take the form of ridiculous mega-texture style resolutions, and the Voodoo power of 2 limitation is pretty much gone. So as long as you aren't using some absolutely insanely high-resolution images, you should be fine.
Yeah, the limitations for textures are pretty big on modern cards, I figured it's worth a mention because someone might be making a say diablo style isometric top-down game in which case the per tile sprite resolutions could be pretty high so cramming everything in the game into a single texture would likely not be a good idea, especially if older HW support is a goal. :)<br>
If I recall correctly, specially on mobile, some texture optimization/compression techniques only work on power of 2 textures, so all in all this sort of thing is still relevant today.<br>I'm not sure how Godot handles any of that though. I'll use an unity answer and docs as a reference:<br>"Non power of two texture sizes generally take slightly more memory and might be slower to read by the GPU, so for performance it’s best to use power of two sizes whenever you can."<br>Docs <br>does unity care if a texture is a power of 2? <br><br>Considering a series of things listed above, specially on mobile, I would pretty much always use POT.<br>
I do still always use power of 2, even though I know I don't have to anymore. It became a habit. And yes, it can still be an issue on mobile, so there is still some merit in sticking to that convention. What you are targeting is a big part of how to address this issue. If you are strictly going for desktop systems, you won't have to really worry about it. Having separate textures isn't really a big deal for any standard computer sporting a GPU. If you are planning having a mobile platform be your primary target, than it might be more significant. Mobile is all about optimization, and whatever you can do to squeeze more power for less battery life will be worthwhile.