Smoothing edges

Anything libgdx related goes here!

Re: Smoothing edges

Postby ruben01 » Wed Jun 06, 2012 10:26 pm

Hi we had some problems with sprites, where the borders where looking ugly so we made a tool that bleeds the colors of the opaque pixels into the transparent ones, the pixels that are not 100% transparent are not changed, but the transparent pixels get the color of the neighouring pixels. This fixes the interpolation error that usually happens in those pixels.

The tool does this Image the left image is the original one rendered over a red background, the middle one is the result with alpha disabled, and the right one is the result image rendered over a red background with alpha enabled.

The projects is available here: and there is a runnable jar in the downloads section.

If you have any question feel free to ask.
Posts: 5
Joined: Wed May 25, 2011 9:07 pm

Re: Smoothing edges

Postby billbo » Wed Jun 06, 2012 10:57 pm

Very nice. Looks similar to a bicubic interpolation. The linear interpolation goes a long way, but this looks like a pretty viable option. Thanks for the contribution.
Posts: 11
Joined: Wed Jun 06, 2012 8:47 pm

Re: Smoothing edges

Postby jasmyn » Fri Oct 05, 2012 7:28 am

@ruben01 Thanks a million for that utility, it's exactly what I've been needing. Such a chore to do this manually every time. :)
Posts: 1
Joined: Fri Oct 05, 2012 7:24 am

Re: Smoothing edges

Postby vidjogamer » Mon Oct 08, 2012 3:36 pm

Does anybody know how to set the TextureFilters on a TiledMap?
Posts: 8
Joined: Wed Aug 29, 2012 6:44 pm

Re: Smoothing edges

Postby vidjogamer » Tue Oct 09, 2012 12:22 am

Ok, I figured it out. Heres the solution for anyone else whos looking as well.

In the atlas packfile ouput from the modified texture packer from here: (Let me know if this is what I should be using btw). The 3rd line in the file is the filter mode "filter: Nearest,Nearest". Just change it to "filter: Linear,Linear" for example.

Still cant find a way to do in in code though.

On that note, does anyone know the order of filters... least to most cpu costly?
Posts: 8
Joined: Wed Aug 29, 2012 6:44 pm

Re: Smoothing edges

Postby Evile » Fri Oct 19, 2012 10:38 pm

This is what we call premultiplied or unclamped alpha. A trick I use as an artist is to make 4 layer copies of the sprite, put all of them behind the sprite then nudge each layer 1-3 pixesl in NESW directions so that the alpha fringe is the same colour as the edge of the sprite.
Posts: 18
Joined: Wed May 16, 2012 10:16 pm


Return to Libgdx

Who is online

Users browsing this forum: Google [Bot] and 1 guest