# Textures quality issues with Libgdx

I have drawn several vector objets and characters ( in Adobe Illustrator ) for my game on Android. They are all scalable at any size without any quality losses ( of course it's vector ^^ ).

I have tried to simulate my gameboard directly on Illustrator just before setting my assests on libdgx to implement them in my game.

I set all the objects at the good size, so that they fit perfectly on my XHDPI device I am running my test on.

As you can see it works great ( for me at least ^^ ), the PNG quality is good for me, as expected !

So I have edited all my PNG at this size, set my assets on libgdx and build my game apk.

And here is a screenshot of my gameboard ( don't pay attention at the differences of placing and objects, but check at the objets presents on both screenshot ).

As you can see, I have a loss of my PNG quality in the game. It can be seen clealry on the hedgehog PNG, but also ( but not as obvious ) on the mushroom ( check at the outline ) and the hole PNG. If you really pay attention, on every objects, you can see pixels that are not visible on my first screenshot.

And I just can't figure out why this is happening Oo If you have any ideas, you are very welcome !

Thanks.

PS : You can check more clearly the 2 gameboard on this two links ( look at them at 100%, display at high resolution ) :

Good quality link, from Illustrator

Poor quality link, from the game

Second phase of tests :

We display an object ( the hedgehog ) on our main menu screen to see how it looks like. The things is that it looks like he is suppose to, which means, high quality with no pixels.

The hedgehog PNG is coming from an atlas :

layer.addActor(hedgehog);


No loss of quality with this method

So we think the problem is comming from the method we are using to display it on our gameboard :

blocks[9][3] = new Block(TextureUtils.hedgehog, new Vector2(9, 3));


the block is getting the size from the vector we are associating to it, but we have a loss of quality with this method.

• I guess you're talking about the aliased outlines? It looks to me that the good set has been drawn using alpha-blending and the bad set has been drawn using alpha-testing. I'm not familiar with libgdx. Can you set a blending mode? – GuyRT Jan 29 '14 at 16:41

## 2 Answers

I'm assuming that libgdx had to scale the images up for you to fit your xhdpi device. If this is the case, then there are two options that come to mind that you could try in your case:

1. Make the original images at the highest resolution possible. If you can achieve to have one large image, suitable for the largest screen size you're targeting, then you're fine, libgdx will only have to scale it down on smaller screen sizes and no quality would get lost.

2. Apply a TextureFilter on your textures. I would start with a Linear-Linear filter like this texture.setFilter(TextureFilter.Linear, TextureFilter.Linear). But I would also suggest you check out this article http://www.badlogicgames.com/wordpress/?p=1403 which explains in detail the aspects (especially performance ones) of applying different combinations of texture filters. Applying the right texture filter on your texture will make it look smooth on an upscale, making sure you don't get into performance troubles.

• Thanks for your answer VictorB. The point is, libgdx has not scale the images. I have created my PNG the exact size they should have and check this by putting them on my phone screen. My partner ( we are a team of two for this game development ) and I, run differents tests to see where the problem can come from. I have edited my first post to explain it. Thanks again. – user1876708 Jan 28 '14 at 18:44

I just had this same problem and managed to solve it. If your issue was the weird checker-board pattern, it turns out some(all?) android devices cause those artefacts when you take a screenshot.

I was having the same issue and spent some time trying to fix it and ended up looking at my device with a magnifying glass to see the individual pixels and it seems to be fine. I may be misunderstanding your problem though.