5
\$\begingroup\$

I searched on the Internet but couldn't find the way to use mipmaps with libGDX TextureAtlas. I want atlas instead of normal textures because as far as I know mipmap supports only 2^n width and height and my single textures have other width and height but atlas have 2048x1024.

I can use mipmaps with Texture using

TextureParameter param = new TextureParameter();
param.minFilter = TextureFilter.Linear;
param.genMipMaps = true;
manager.load("data/mytexture.png", Texture.class, param);

but it's not working with TextureAtlas, I tried to change TextureParameter to TextureAtlasParameter but this class don't have genMipMaps field and can't be passed to load method, too.

\$\endgroup\$
1
\$\begingroup\$

If you've a pack file along with the image, like text or json file, there probably is a line that specifies the filter used in that atlas. For example the file may be like this:

pack3.png
format: RGBA8888
filter: Linear,Linear
repeat: none
image1
  rotate: false
  xy: 2, 2
  size: 484, 484
  orig: 484, 484
  offset: 0, 0
  index: -1
image2
  rotate: false
  xy: 488, 2
  size: 484, 484
  orig: 484, 484
  offset: 0, 0
  index: -1

Just change the filter in there to the one you like (in the order min,mag) and save the text/json file.

\$\endgroup\$
0
\$\begingroup\$

As far as I am aware, the setting genMipMap for TextureAtlas is not available. If you're packing your images using TexturePacker to create your atlas, you can pass it Settings:

TexturePacker.Settings settings = new TexturePacker.Settings();

settings.combineSubdirectories = true;

settings.filterMin = Texture.TextureFilter.MipMapNearestLinear;
settings.filterMag = Texture.TextureFilter.Linear;

// Packs all textures inside your "textures" folder into a folder named "pack"
// "pack.atlas" and "pack.png" will be created.
TexturePacker.process(settings, "textures", "packs", "pack");
\$\endgroup\$
  • \$\begingroup\$ So maybe do you know any other way to avoid textures distortion while moving? More info here stackoverflow.com/questions/31311915/… \$\endgroup\$ – bpawel10 Jul 10 '15 at 5:34
  • \$\begingroup\$ @bpawel10 Try setting filterMin to Texture.TextureFilter.MipMapNearestLinear and filterMag to Texture.TextureFilter.Linear. I edited my answer to reflect this. \$\endgroup\$ – driima Jul 10 '15 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.