+2 votes

Hi guys !

My question is about how to make the best use of sprites or texture to get the best performance, in particular when targeting mobile platform.

For the moment most of my game assets are based on large 1024 by 1024 sprites which may contains many different objects. They are loaded once (if I got it correctly) and do not use too much RAM space I guess. However is it the best way to proceed?
1) Is it affecting way too much the CPU to have one file per sprite so my approach makes sense, or is it useless to gather all objects sprites on a single BIG image?
2)Is it better to use atlas of different sprites than a single sprite gathering the different objects images? Or is it unimportant in terms of performance/loading-unloading?

Thank you very much.

in Engine by (101 points)

2 Answers

+2 votes

This blog post answers your questions http://robotinvader.com/blog/?p=438,
especially 1. (Macrotexture everything) and 4. (Watch out for transparency) in second paragraph.

In general it is better and more GPU efficient to have one big sprite with everything than place multiple smaller sprites on the screen.

by (679 points)
edited by
Do you mean one big texture as a spritesheet for multiples sprites ?
I mean that it is better to have one sprite with "forest" than place multiple sprites with solitary tree on the screen.
@lukas no, its exactly the opposite, I dont think you understood what was written in the blog. Like @DriNeo said, its good to have one big texture to act as a sprite sheet, and then draw parts of it. Its not good to have big-ass textures to use as a "map of a whole level".

So, you would use a big texture with all kinds of sprites used in that level, and draw them as necessary. The sprite texture would only be loaded into memory once and then parts of it used when necessary. With this you avoid the loading/unloading of different textures
Nuno Donato + DriNeo, I am not sure if we understand each other and if you want to understand what I mean ;). I really don't talk about "big-ass textures" as you called it.
+1 vote

Spritesheets (images containing many sprites) and Atlas are the same thing, the nomenclature changes depending on the context you are using them, but essential they are both big images with smaller images inside.

Check my comment reply to the other answer as I dont believe the answer itself is correct. Its better to use big images with all the sprites inside than smaller images.

by (281 points)
edited by
Thank you for your answers!

However I thought that atlas were more optimized than hand-made spritesheets, but I guess this optimization is probably minor.
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.