• Editor
  • Textures and resolutions

msm :

Using images of different dimensions than the one exported from the Spine editor with the unmodified atlas file exported from the editor would not work.

This is a little confusing. If you have images of a different size, you'll need to pack them into an atlas of a different size. You can use the same skeleton file with the different size atlas. Scaling up/down is separate from the size of the images.

Related Discussions
...

I think I am still confused.
I have 3 files that are exported from Spine, skeleton.png, skeleton.atlas, and skeleton.json

I am scaling the exported skeleton.png to different sizes, in cocos2d/cocos2dx this is typically 25%, 50% and 100% scaled images.
I want to use all 3 scaled versions of skeleton.png with the same unmodified skeleton.atlas and skeleton.json files exported from Spine.

Using the runtime skeleton->scale doesn't do that. I was only able to do it with my changes in my previous post.
If that skeleton->scale was never intended to do that, is it possible to export to different scales from the Spine editor, or would I need to create 3 separate skeletons?

I think part of my confusion stems from the documentation, the part that describes Scale in this way:

This can be useful when using different sized images than were used when designing the skeleton in Spine. For example, if using images that are half the size than were used in Spine, a scale of 0.5 can be used. This is commonly used for games that can run with either low or high resolution texture atlases.

I can see now that it only refers to the json skeleton file exported from Spine, and not .atlas file

Personally i had to create different atlas files for each of my 3 resolutions using TexturePacker for my cocos solution. So in summary i have the master json file in my master folder, and a copy of the atlas and png scaled appropriately in each of the SD,HD,HDR folders.

Nice, so the TexturePacker atlas data file is compatible with the Spine runtime?

Sorry for the confusion, msm. Currently the Spine texture packer doesn't pack multiple resolutions. I'd like to add this feature, but haven't got to it yet. You'll need 3 copies of all your images (eg 100%, 50%, 25%) and then run the packer 3 times to get 3 atlases. Use the appropriate atlas and JSON loader scale at runtime. You can use a script (ImageMagick, Photoshop, Java, python, etc) to scale your 100% images down to the other sizes.

An alternative is to use Texture Packer Pro which does have the automatic multi atlas feature, though this is a paid application. Choose the "libgdx" export option for Texture Packer Pro.

I'm also having problems here. I animated in Spine with the hd version of my character. Then exported that. To make the non hd I reduced all images to 50% in photoshop and opened the same spine file. It had all the animations but the images where too small. So I needed to scale those images to 200% inside Spine before export.

I dont think you can just scale the images and be done with it. Your animations would still be made for a higher size images.

Nate :

Sorry for the confusion, msm. Currently the Spine texture packer doesn't pack multiple resolutions. I'd like to add this feature, but haven't got to it yet. You'll need 3 copies of all your images (eg 100%, 50%, 25%) and then run the packer 3 times to get 3 atlases. Use the appropriate atlas and JSON loader scale at runtime. You can use a script (ImageMagick, Photoshop, Java, python, etc) to scale your 100% images down to the other sizes.

An alternative is to use Texture Packer Pro which does have the automatic multi atlas feature, though this is a paid application. Choose the "libgdx" export option for Texture Packer Pro.

No worries Nate, thanks for clearing this up for me.

Erebar :

I'm also having problems here. I animated in Spine with the hd version of my character. Then exported that. To make the non hd I reduced all images to 50% in photoshop and opened the same spine file. It had all the animations but the images where too small. So I needed to scale those images to 200% inside Spine before export.

I dont think you can just scale the images and be done with it. Your animations would still be made for a higher size images.

Nate can probably correct me, but Erebar, in your case I think this where you want to use the runtime json scale
http://esotericsoftware.com/spine-using ... s/#scaling

msm is correct.

24 天 后

Nate, would you consider always adding the original dimensions of the page used to compute the "xy" and "size" of each region in the atlas? With this, normalized texture coordinates could be computed and the texture dimensions wouldn't matter.

tex_matrix.identity();
tex_matrix.scale(1.0 / page.w, 1.0 / page.h); // region in page pixel units
tex_matrix.translate(region.x, region.y); // from atlas.region.xy
tex_matrix.scale(region.w, region.h); // from atlas.region.size

What would be the purpose of storing the page size? Currently the page image size doesn't change. If you have a smaller atlas, you have a different atlas file and different page images. The images might be packed differently and the pixel size of the regions could be slightly smaller or large depending on how they were scaled.

If I had the dimensions of the image used to compute the regions, I could swap out the atlas image (example.png - 1024x1024) with a low-res version (example-low.png - 256x256) at runtime and use the same atlas (example.atlas) by scaling the "xy" and "size" fields by 256/1024 (normalized texture coordinates) without needing to load example.png to see what the dimensions were.

var atlas_png = atlas.page.name;
if (low_res)
{
    atlas_png = basename(atlas_png) + "-low.png"
}

I think you might have off by one pixel issues doing that, depending on how the downscaled images are rasterized. If the packer could create multiple atlas sizes I don't think it is much of an issue to swap both the atlas file and images.

Yeah, that makes sense. For this to work, the higher res images would need larger gaps between the regions. Not exactly ideal. Thanks for hearing me out.