automatic spritesheeting weirdness

Discussion and feedback on Construct 2

Post » Sun Oct 26, 2014 7:39 pm

I noticed that automatic spritesheeting on export something behaves very strangely.

For example: I have two sprites
Sprite1 have 3 animation frames with 57x36 size and after export it creates 3 separate files with same size.
but for Sprite2 which have two 258x17 sized frames it export one 512x512 spritesheet ?! Leaving ~80% of this image empty.

and I have a lot of similar sprite sheets with over half space wasted.


Not sure why it is doing this way, but logically It could easily fit those three 57x36 frames on a single 128x128 texture, and make two separate ones for 258x17.
But for some reason "it" choose differently, making probably 70% of my all images in that strange almost half empty sprite sheets :/
ImageImageImageImage
B
157
S
66
G
42
Posts: 2,603
Reputation: 35,343

Post » Sun Oct 26, 2014 8:53 pm

yeah i noticed the same problem, often it is like all the small images together could just go in the blank space of the bigger ones :/
B
38
S
11
G
5
Posts: 485
Reputation: 5,340

Post » Sun Oct 26, 2014 11:52 pm

Right now there are (for all I know) no "real" sprite texture atlases, the sheets get only created per sprite.
So frames from 2 different sprites currently won't end up on the same sheet, even if there was space left.
B
77
S
28
G
32
Posts: 481
Reputation: 19,763

Post » Tue Oct 28, 2014 6:13 pm

Yes I'm aware of that. I'm not talking about different sprites but Sprites with multiple animations frame.

It looks like this.
Sprite1 with 3 animations frames - each 57x36
sprite 1.png

As you can see these three animation frames, which are exported as three separate images could easily fit on one 128x128 image


Sprite2 with 2 animations frames - each 266x52
sprite 2.png

But for this sprite it puts all frames into one 512x512 image. Leaves almost entire image empty! And about 90% of my images looks like that after export :/
You do not have the required permissions to view the files attached to this post.
Last edited by shinkan on Mon Nov 10, 2014 1:12 am, edited 1 time in total.
ImageImageImageImage
B
157
S
66
G
42
Posts: 2,603
Reputation: 35,343

Post » Tue Oct 28, 2014 6:34 pm

266x52, if you will see, fit only in a 512x512 square shaped spritesheet, yes, they are square shaped, which I found weird but there may be a reason for that.

Unless you meant that there were more than 2 frames and they did not get fitted into it.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Tue Oct 28, 2014 6:59 pm

Yes, I understand that.
But if 266x52 fit only in a 512x512 then 57x36 should fit in a 64x64, right? and they also should fit to 128x128.

What I meant was, why after export some sprites are put into a sheets and others are not.

If those three 57x36 frames and two 266x52 frames after export end up respectively on three 64x64 and two 512x512 then I would now what is going on and try to improve that. But currently I have no idea how C2 is deciding which sprites export as a sheets and which ones as a single files.

I made some more test, and I still don't know how it works
3 sprites, every one have 3 frames

test 1
sprite1 - 3 frames 48x48
sprite2 - 3 frames 32x32
sprite3 - 3 frames 64x64

- every frame is exported separately - 9 images after export

test 2
sprite1 - 3 frames 42x66
sprite2 - 3 frames 76x44
sprite3 - 3 frames 57x23

- every frame is exported separately - 9 images after export

test 3
sprite1 - 3 frames 120x99
sprite2 - 3 frames 258x258
sprite3 - 3 frames 160x160

- every frame is exported separately - 9 images after export

test 4
sprite1 - 3 frames 42x66
sprite2 - 2 frames 32x32, one frame 64x64
sprite3 - 3 frames 57x23

- Sprite1 and Sprite 3 - every frame is exported separately - 6 images after export
- Sprite2 - this one exports to one 128x128 file and one 64x64 - 2 images after export

It looks from these very simple tests that only frames which differ in size are sprite sheeted. But in tests only, In my game I have lots of frames with different size and they are still randomly exported as single images or sprite sheets!
ImageImageImageImage
B
157
S
66
G
42
Posts: 2,603
Reputation: 35,343

Post » Mon Nov 10, 2014 1:54 am

Could it be that sometimes separate sprites actually take less memory than the larger single image sprite sheet?

I also wonder if instead of 3 frames you used 4 if more images would be combined as a sprite sheet instead of seperate.
B
28
S
8
G
1
Posts: 226
Reputation: 2,865

Post » Mon Nov 10, 2014 1:15 pm

@shinkan That is because Construct uses power of 2 for spritesheeting. So, in your case, 3 64x64 images are smaller than one 128x128 image. Also, two 258x17 can`t be on a sheet that is lower size than 512, because 512/2 = 256, your image is 2 pixels too wide. And considering that Construct uses 1 pixel each side for sheeting, the max size for a 512x512 sheet would be 254.

Hope I could help you, and sorry for my "engrish", I am Brazilian.
B
37
S
5
G
2
Posts: 46
Reputation: 3,854

Post » Mon Nov 10, 2014 1:34 pm

CleitonEldron wrote:@shinkan That is because Construct uses power of 2 for spritesheeting. So, in your case, 3 64x64 images are smaller than one 128x128 image. Also, two 258x17 can`t be on a sheet that is lower size than 512, because 512/2 = 256, your image is 2 pixels too wide. And considering that Construct uses 1 pixel each side for sheeting, the max size for a 512x512 sheet would be 254.

Hope I could help you, and sorry for my "engrish", I am Brazilian.


I'm all aware how C2 uses power of 2 texture, you don't need to explain that to me.

I'm not complaining, C2 does a great job with sprite sheets, but occasionally it's hard to predict what results you will get.

And it still does not explain why textures make with proper size are sometimes sprite sheeted and sometimes not.
In my current project I have a sprite with 14 frames, each one is 1022x254 - made them like that so they can be all placed in nice sprite sheets after export. And again sometimes it will make 1 sprite sheet 2048x2048 (which fits all frames all together), sometimes it will make 2 sheets 1024x1024, and rarely it makes 14 separate images 1022x254. and even more very rarely i got few 1024x1024 sheets with only two images inside.

So yeah. I only try to understand how C2 decides what and when will be sprite sheeted.
ImageImageImageImage
B
157
S
66
G
42
Posts: 2,603
Reputation: 35,343

Post » Mon Nov 10, 2014 3:42 pm

Spritesheeting is subject to various options like the project downscaling quality setting, the image format of each frame, and a few other things. I could not say why this is happening unless you provide a .capx demonstrating it.
Scirra Founder
B
398
S
236
G
88
Posts: 24,428
Reputation: 194,625

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 15 guests