How many images can a single animation group hold?

Hello! I had 39 images that I wanted to add in a single animation group. I tried searching for the maximum amount of images a single animation group can hold in defold, but I couldn’t find an exact answer. I tried putting 69 images in a single animation group before, but instead defold crashed. How would I know how much images I can add in a single animation group, without the ‘not enough memory’ warning pops up?

There is no limit. It’s simoly an array of images.

What was the crash? We don’t want the engine crashing.

1 Like

Did you report this on GitHub? 69 images should not be a problem.

1 Like

Thanks for the reply. I think it said defold had no more memory space available (java.lang.OutOfMemoryError: java heap space). I had a search on Google and it also says yhe amount of images you can add is unlimited.

Thanks for the reply. Technically the amount of images I can add should be unlimited (at least thats what I found), but when I try to add the images, there was an error (java.lang.OutOfMemoeyError : java heap space).

I’m wondering about the dimensions of the images you are adding?

3 Likes

Yes, this will always be a part of choices for the developer: What’s a reasonable amount of memory I want this resource to take?

Sure, we can probably do a better job of oresenting a nicer “out of memory” message, but the fact remains that you put a lot of resources into an atlas that will then take up that amount of memory.

Furthermore, you’ll have a bigger problem once you ship your game to the end users, as they may have vastly different setups from your devloper machine.

In short, I wouldn’t create an atlas larger than 8kx8k. I’d more likely go with 4kx4k to be honest (that’s also very large for most cases).

2 Likes

Yes I agree the optimization is not the best and the file size of each images is large. I was wondering is there any way of avoiding this problem, instead of reducing the size of my atlas?

Approximately 1867 x 1044 for each

As you suggested, keeping the number of images in an atlas low is the recommended approach due to the suggested max texture sizes on each platform/GPU.

But, I think a better question is: What are you trying to do? What are these images used for?

1 Like

That is very large!

1867 * 1044=1,949,148 pixels
At 4 bytes per pixel you have 1,949,148 * 4 = 7,796,592 bytes
69 images of that size would be 7,796 592 * 69 = 537,964,848 bytes (0.5 GB)

Basically all GPUs on desktop will be able to handle 8k textures. That is 8192*8192 = 67,108,864 pixels or 268,435,456 bytes
Many GPUs can handle 16k textures or 268,435,456 pixels or 1,073,741,824 bytes (1 GB)

Images of size 1867 * 1044 pixels won’t be able to be packed perfectly into an 8 or 16k texture which means that the texture size you need for your 69 images will be even larger.

Conclusion: You need to come up with a different approach if you want people to be able to play your game.

You should answer this question first. There’s probably a better approach than creating a mega image. First of all, will you show all 69 images at once? Or one by one? If it is one by one then why not load and unload them as you go. You will save a ton of memory.

1 Like

It is for a animated background

It is an animation so I think the images are displayed one after the other. But I only have 39 images for my new animation, so it is still very large and tak s up a lot of memory, but I think it should be better.

Ok, 39 images is better, but it is still going to be a large texture. Some options:

2 Likes

Thanks for the links, I will check them out. I believe can narrow the images down to only 16, so it should work without any problems. Yes, the image is changing