Use one atlas for the whole game to reduce draw calls?

I just want to know if you care about something like this and pack all the images in one atlas? If so, how do you manage animations? Using some prefixed name or some other solutions?

For example, I am using atlases for each character and monsters and all of them have a specified set of animations (idle, run, attack, hurt, etc) and it’s convenient to use always the same hashes to animate different objects, really generic approach. However I’m ending up with a lot of draw calls and was thinking about moving them into one huge atlas - nonetheless, such atlas could lengthen duration of loading, even if it’s pixel art. What are your tips and thoughts on this?

2 Likes

I’m struggling with this a bit myself right now. I’ve got a couple of atlases which are just shy of eighty 350 x 350 images, and changing anything in the atlas causes an irritating delay (about 2 seconds), even stuff like adding a new (empty) animation or changing the fps in an existing one. I’ve gotten into the habit of creating new animations in a different atlas and then copying them in a small batch.

And when testing the game on my work computer, it takes 10-20 seconds to load everything (though it’s working just fine after bundling the game).

I can and will cut the atlas size by quite a lot, but the slowdowns are just a bit of an annoyance for now, so I’m putting it off.

I guess what I’m trying to say is that a 3000 x 3000 atlas is too big., but from what I heard cramming everything in as few atlases as possible is generally a good approach.

1 Like

This has been the bane of our existence whilst working on Interrogation. We ended up making animations by editing the atlas file in Atom, because otherwise, even adding an image that already existed in the atlas to an animation would make Defold hang.

I see two solutions to this problem (on the PR bucket-list when I’ll finally get some chill weekends):

  1. The atlas shouldn’t get re-built if the set of used images doesn’t change.
  2. (Might be really hard to implement) Rebuilding the atlas should be done on a separate thread. Not having the latest texture and UV to work with is much better than having your editor become unresponsive on each change.
5 Likes

I didn’t considered that problem, because all my atlases are pretty small, but indeed, when I worked with a pretty huge atlas the Editor was running out of memory :confused:

@dapetcu21 are there issues on Github regarding this? Do you have already some implementation ideas? :wink:

1 Like

There is this: https://github.com/defold/editor2-issues/issues/2383

Regarding implementation ideas, I listed my two ideas above, but right now I’m swamped with work and I’m not yet familiar with Defold’s codebase.

2 Likes

Me too and alas I’m not familiar with Clojure and that’s why I try not to tinker with editor :confused: I think that two solutions you mentioned should be both implemented and what is to consider is a priority

I’ve made a note of this. We’ll investigate this as it does seem like a real annoyance.

4 Likes

Wow this was huge! I think only OpenGL 4 can handle this size :slight_smile:
You may consider to limit your atlases 4096x4096(or maybe 8192 according to your target OpenGL/platforms).

You can separate them something like this I guess (which I mostly did):

  • Level sprite sheet (level1-, level2-…) for all level specific backgrounds , sprites(maybe level characters and particles).
  • Generic (character anims, particles ) and maybe GUI(if you have space). You can seperate them by naming like hero_idle, enemy_spider_idle …
  • Tilemap
  • GUI (if needed)

This cause a 3-4 draw calls

I’m afraid loading and editing is still an issue as @dapetcu21 described :frowning:
It is better to edit it on text editor or maybe using some kind of python script to automate.

2 Likes

That separation is really great and that was also coming to my mind :smiley: that I could agree on for example drawing level, drawing objects and drawing npcs/mobs and GUI and it’s reasonable :wink:

And regarding that huge images - I wanted to create a Parallax effect on some HD images and that’s why I used Defold to quickly make it, and really, I removed one image and it was running, but yeah - I spotted a problem and Editor was really lagging and hanging, so I created the issue :sweat_smile: it was this:

4 Likes