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 / Atlas and sprite scaling questions

Author
Message
TDavid
11
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 15th Jun 2013 14:57
Hi,

I ran into a small problem while atlasing my images (I'm using 1076). It's quite difficult to explain so excuse me if it doesn't make any sense.

My program is tile based. The tiles I use are all atlased. When the app runs on my phone, which means close to the designed resolution, everything looks fine.

However, when the window is scaled up, every edge of every tile has a line which belongs to the nearby atlas tile.

For instance, in my atlas one frame features grass, and the frame on its right in the altas is fully red. When my app runs on my computer screen, which means it's scaled up, it draws the grass frame with a red line on its right edge.

The issue is more pronounced the more I scale up a sprite. I made an atlas with two pixels, one white and one black. When I use the white pixel and scale it to cover the whole screen (480*800), both sides are shaded in black.

It's as if agk scaled up the whole atlas with a blurry filtering method which blended both pixels and then cut the frames to draw them onscreen.

Is this behaviour intended? Is there a way to prevent this problem or turn the filtering off or something?

Thank you for reading and congratulations if it made sense to you.
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 15th Jun 2013 16:33
Always leave at least one blank pixel around your atlas cells. This saves problems with scaling and also if you use min/mag filter enabled (which it is by default). Also, if you scroll the sprite in any direction, it may use 0.5 of the adjoining pixel to achieve smooth transition.

If you just want a simple 1 colour sprite then create a sprite like this:



If you really need to keep your actual image crisp and "pixelly", then you need to set the min/mag filters for that image to 0. Unfortunately, this is a command that affects the image not the sprite, so I am sure your entire atlas would have to be in either/or modes.

I have started making separate tiles lately and using the imagejoiner tool that comes with AppGameKit to generate an atlas. Sometimes I have to be careful to place only images where their purpose is suitable for atlases.

I recently went through an exercise to tile up about 8192x360 worth of scrolling backdrop. The original is 2048x90 and it was scaled x4 on the screen when rendered.
The individual frames didn't join together properly if I scaled the sprite after picking it from the atlas and after a lot of experimentation, found that I had to pre-scale the original graphics, chop them up into pieces (leaving 1 blank pixel top and bottom in this case) and "sprite" them at the x4 size.

A lot depends on the actual images and what you are using them for.

TDavid
11
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 15th Jun 2013 17:11
Oh Gosh, I must be tired, I didn't even think about browsing the image command list to find the mag filter. Sorry for your trouble.

Thanks for your tips. The pixel thing will be most helpful.

I set the filtering to "nearest" for every image and I didn't notice any blocky sprite, even when downsizing. I guess as long as I don't rotate low resolution images I'll be fine. It seems to have improve my framerate by 1 ips. It might be my imagination as well

Login to post a reply

Server time is: 2024-04-28 04:19:13
Your offset time is: 2024-04-28 04:19:13