0 votes

My Google search on this topic hasn't given me a straight answer so I'll just ask it here.

Suppose I have many sprites of varying size, such as background elements for a stage. The images are unrelated to each other in terms of animation, but will almost always show up together. How badly will it impact performance if I kept each of these sprites in separate files instead of a spritesheet? Does it matter?

Someone on Reddit claimed Godot Engine can be set to automatically generate spritesheets on export but I haven't seen an option for that.

in Engine by (113 points)
edited by

Just to comment, i found this website that combine all sprites into one sprideSheat:
https://codeshack.io/images-sprite-sheet-generator/

3 Answers

+1 vote
Best answer

Use spritesheets for big projects. By big projects I mean anything you really want to optimize. Sprite sheets are great at critical load times but the lading of them is barely seeable (below 8ms for 250x250 sprite). Benefit of sprite sheet Is that It loads data once only so the loading spike is only at the beginning while an individual sprite animation would require loading dynamically, spikes at each frame. A workaround i found was to have a persistent object handle loading sprite via c#.
TL;DR
If your not making high res textures use individual sprite and preload them.

by (200 points)
selected by
0 votes

Using a spritesheet is more manageable as development proceeds. Individual sprites would require naming each and every file of a single sprite(NPCs and PCs alike but specially if you have many NPCs/enemies which will get more and more time consuming.).

As for the performance issue I think it might not be a healthy practice in case where 'sprite animation' is concerned .I'm still combing through the docs(and came here looking for an answer for my own problem) but having some background in pixel art animation believe me when I say managing individual sprite images is a mess.

Although some spritesheets might require you to specifically work with individual images in case you decided to give your players some shapeshifting powers. But that can also be managed by multiplying the size of the canvas in accordance with the final transformation but what if you want the newly transformed sprite interacting with the environment in some different way I mean what if him being a human deals him more damage by some environmental trap than being an abominable monster.

by (14 points)

The naming of every sprite isn't really an issue for me, since I'm already naming every sprite in the drawing software I'm using. I can easily export every sprite I created and automatically named. The names don't show up in my game though because I'm trying to use spritesheets, but I was wondering if spritesheets even matter. For example, I have a tree, a bush, and a cloud, all different shapes and not going to animate into each other, but will almost always show up together. Should these be placed in a single spritesheet? Putting these in a spritesheet is a hassle for me, the developer, but I currently do it because I believe it'll help performance. I wanted to know if it significantly impacts performance or if I'm wasting my time. File reads are often one of the slowest operations in a program, but maybe Godot does something clever with sprites?

Well of course placing different elements of a scene into only one spritesheet is not advisable and I don't think using independent sprite images would result in performance slack off. After all game engine's have been built from ground up with optimization of different game elements in mind. And if you are familiar with importing spritesheet animations remember how those softwares ask us to allocate the the type and width(aseprite). Even though if you have many sprites in a single spritesheet the engine will break it down into individual and then save them(and you can confirm this by taking a peek inside the project folder of your game).

So now it boils down to this if you are wasting time making Spritesheets (which from your second comment is clear) stop it but man if you are comfortable with this then carry one no one's gonna stop you.

So I should not use spritesheets then. That will make my workflow much easier.

I'm unsure where the broken down images are located. Is it the StreamTexture file in the .import folder? I only see 1 file for my spritesheet in here if it is.

0 votes

Just as an additional note to anyone else who happens upon this thread, there's a ResourcePreloader node where you can add textures to preload. This should solve the file loading issue if it ever becomes one. Of course if you have too many files in the preloader, then it would take a long time to load and will probably also hog a lot of memory, so don't go overboard.

by (113 points)
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.