1
votes

I implemented a top view camera which moves with the player, only a bit slower using camera.position.lerp. The problem is that the textures are flashing (flickering) a little because i have scaled my textures. If I use normal size of textures the flickering stops. Does anyone have any ideas on how to move the camera with zoom (or textures scaled - same thing) without getting the textures to flicker (or flash)? I use linear filtering and load every asset from an atlas. I saw this problem on multiple forums, but no answer. I wanted to load higher resolution textures and resize them in code, that's why I am asking this question.

1
Your min filter for the texture should be MipmapLinearLinear or at least MipmapLinearNearest. That should help quite a bit. Is the flickering happening everywhere, or only on the edges of sprites?Tenfour04
Yes, that was the problem. The filtering Linear was different from MipMapLinear. I switched it and now I have no flickering.Andrew
Also changing the filter to MipMapLinearLinear blurs the textures. Is this a side effect?Andrew
If your problem is what I am thinking, that flickering is actually high-frequency noise. This happens when the sampled image has too many possible texels to select from at a certain location. The slightest difference in camera angle will change the cluster of 4 texels that are averaged together for linear texture filtering. Mipmapping changes this by creating lower-resolution images for minification at greater distance. You might consider it blurring, but it is technically a form of anti-aliasing.Andon M. Coleman
Thanks for the help. I fixed 2 problems with the help I got from these 2 posts. But i have one more (I hope this is the last one). As you know I am using lerp to move the camera, but for the alpha value 0.5 or lower, which gives the slow effect to the camera, when the view gets very close to the target it trembles. I know this is from the alpha value being too small, but if i make it bigger the camera moves too fast. Is there any way to make a better interpolation to move the camera a little slower than the player? EDIT:The tremble is far more visible on Y axis.Andrew

1 Answers

0
votes

You need to extrude the borders of your sprites in the atlas. The Extrude option tends to be close to the Padding ones.

Extrude in TexturePacker

Most texture packers support that feature and Libgdx will pick that information up from the atlas file straight away.

This way you get to use the filter you want.