Sprite, Textures and Performance

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By thomas_laverne
:warning: Old Version Published before Godot 3 was released.

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?
Questions:

  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.

:bust_in_silhouette: Reply From: lukas

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.

Do you mean one big texture as a spritesheet for multiples sprites ?

DriNeo | 2016-02-29 17:36

I mean that it is better to have one sprite with “forest” than place multiple sprites with solitary tree on the screen.

lukas | 2016-02-29 17:45

@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 | 2016-02-29 21:47

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.

lukas | 2016-02-29 21:55

:bust_in_silhouette: Reply From: Nuno Donato

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.

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.

thomas_laverne | 2016-02-29 22:05