Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use ATF (wiki request) #92

Open
thejustinwalsh opened this issue Oct 25, 2013 · 4 comments
Open

How to use ATF (wiki request) #92

thejustinwalsh opened this issue Oct 25, 2013 · 4 comments

Comments

@thejustinwalsh
Copy link
Contributor

Anyone willing to write up how to use ATF textures and add it to the wiki.

Is it as simple as unzipping, running the atf conversion, replacing .png atlases with .atf, then zip it all back up? Do i need to reference the file extension of the atlas in the json file as well? Anything else I am missing?

@roguenet
Copy link
Contributor

There's one other minor step: you need to change a couple things in the library.json. This is the (mac bash) script I use to convert my UI Flump archive:

#!/bin/bash

unzip flump.zip -d tmp
pushd tmp
for png in *.png; do
    echo "Converting $png..."
    TexturePacker --data tmp.plist --sheet fixed.png --border-padding 0 --shape-padding 0 \
        --reduce-border-artifacts --trim-mode None --disable-rotation --disable-auto-alias \
        --max-size 4096 $png
    mv fixed.png $png
    png2atf -q 0 -n 0,0 -i $png -o `echo $png | sed 's/\.png/.atf/'`
    rm $png
done
rm tmp.plist
cat library.json | sed 's/{/{"textureFormat":"atf",/' | sed 's/\.png/.atf/g' > library-atf.json
mv library-atf.json library.json
zip -r flump.zip *
popd
mv tmp/flump.zip flump.zip
rm -rf tmp

exit 0

As you can see on the "cat library.json..." line, I'm adding a textureFormat property to the top level object in the json, and replacing all references of .png to .atf. That's all that's required to get ATF working in a flump zip.

The additional thing I do here is the TexturePacker bit. The important bit there is the --reduce-border-artifacts. The rest of it is just to keep it from mangling the image dimensions or orientation in any way. The border artifacts thing helps an atlas with components that have transparent edges from ending up with a black halo effect at runtime, which was noticeable in some of my flump usage. The black halo is caused by a difference in how Bitmap textures vs ATF textures are used in the Stage3D runtime, specifically premultiplied alpha. More info on that particular problem: http://www.pixelenvision.com/3273/texture-packer-the-tool-that-stands-the-test-of-time/.

At any rate, you might not see a problem in your own project, or you might decide it's not bad enough to spring for the $40 TexturePacker license.

I suppose it wouldn't take much to make this into a wiki article, but I'm just going to leave it here for now. Hopefully that answers your questions. Feel free to drop any more relating to ATF in here, I'm pretty well versed with it at this point.

@roguenet
Copy link
Contributor

Whoops, didn't mean to close it prematurely. Reopening in case there are more questions.

@roguenet roguenet reopened this Oct 25, 2013
@ghost ghost assigned roguenet Oct 25, 2013
@roguenet
Copy link
Contributor

Oh one other note: My UI was getting visible artifacts with the default JPEG XHR compression used by png2atf, which is why I went with -q 0. That means that the resulting .zip is actually larger than the .png version exported by Flump. It does load faster though, and it produces less junk during the library texture upload phase, which is important for my mobile project. I recommend just playing around with the -q setting to see what looks good for your project.

@CodeAndWeb
Copy link

Good news from my side: TexturePacker 3.5.0 now supports writing ATF directly. No need to use png2atf anymore. And you can also set the quality for PVRTC, ETC1 and DXT....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants