Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Sprite animation using atlas image plays differently on mobile device.

Author
Message
JohnnyMeek
11
Years of Service
User Offline
Joined: 23rd Apr 2013
Location: Slovenia
Posted: 3rd May 2016 10:00
I have some sprite animations created with png images inside an atlas image. They work perfect on mac/windows, but on ios and android the images wobble slightly, like their position have been offset somehow.

I'm wondering if this is due to image resizing that takes place per device. I have disabled mipmapping but the problem still occurred. I've also tried aligning the images in the atlas on an even boundary and that also failed.

Has anyone come across this before?
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 3rd May 2016 14:38
I haven't used atlas images. But here are some things you can try:

SetDefaultMagfilter( 0 ) and SetDefaultMinfilter( 0 )

Make sure the atlas image, and all images that are part of it, are power by 2 on both sides (64, 128, 256 etc).
JohnnyMeek
11
Years of Service
User Offline
Joined: 23rd Apr 2013
Location: Slovenia
Posted: 3rd May 2016 16:25
Thanks, but those settings didn't make any difference.

My atlas image is a power of 2, but my images are not. That's one of the best things about using an atlas, they don't need to be. I did try making sure that the x/y of each image was divisible by 16 but that also made no difference.

I probably need to extract some test code and share it here.

Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 3rd May 2016 16:56
I think each image on the atlas needs to be power of 2 also.
JohnnyMeek
11
Years of Service
User Offline
Joined: 23rd Apr 2013
Location: Slovenia
Posted: 4th May 2016 07:30 Edited at: 4th May 2016 07:30
Not according to the documentation.


Quote: "If you have lots of non-power of 2 images you could combine them into an atlas texture that is a power of 2 to make best use of memory."
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 4th May 2016 07:56
"to make best use of memory"

But I wonder if that can still affect scaling. It's the only thing we can think of that might help you
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 4th May 2016 08:13
What size is the atlas image? Is it larger than 1024x1024?
Using AppGameKit V2 Tier 1
JohnnyMeek
11
Years of Service
User Offline
Joined: 23rd Apr 2013
Location: Slovenia
Posted: 4th May 2016 08:25
The atlas is 2048x2048. I can very quickly scale it to 1024 to test it as I'm using texture packer, though I doubt it's that as I have a lot of 2k textures which work fine.
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 4th May 2016 08:48
For backwards compatibility it's good to stick with 1024x1024. Older Android units cannot handle larger images. Unless you don't want to design for those units.
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 4th May 2016 17:38
Thanks, fixed for the next version. This one was tricky to track down, turns out using medium precision for the UV coordinates in the shader wasn't quite enough when using large atlas images like 2048x2048. Desktop platforms tend to use high precision for everything. For now you can work around it by reducing the atlas image to 1024x1024, or by using this shader for your sprites

vertex


pixel


It still won't work on devices that don't support high precision variables in shaders, but those tend to be quite old now.
JohnnyMeek
11
Years of Service
User Offline
Joined: 23rd Apr 2013
Location: Slovenia
Posted: 5th May 2016 08:14
Thanks for the prompt service!

In my day job we use a Unity license which we pay a lot of money for every year, and we don't get fixes the same day.
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 5th May 2016 11:34
You haven't got a fix in the same day here either.
You've been offered a work-around with the promise of a fix some time in the future.
AGK V2 user - Tier 1 (mostly)

Login to post a reply

Server time is: 2024-11-25 08:52:09
Your offset time is: 2024-11-25 08:52:09