libgdxtexturepacker

Images with transparent pixels packed with Texture Packer are black


I tried creating texture atlas with transparent images for animation. Instead of my texture, I end up with black square image, matching the size of the first texture I wanted to pack into texture atlas. I used this texture packer https://www.codeandweb.com/texturepacker because libgdx's gui can't pack it for some reason(it says error has occured).. Before transparent images, i used it for normal, non-transparent images and it worked fine. It seems I am getting black images because of transparency involved. Had anyone similar problem with transparent textures?

code:

mainCharAtlas= new TextureAtlas("Sh/mainChar.txt");
        mainCharRegions= new Array<TextureAtlas.AtlasRegion>(mainCharAtlas.getRegions());
        mainCharAnim= new Animation(1f/31f,mainCharRegions);

        mainChar= Decal.newDecal(mainCharRegions.first(),true);
        CameraGroupStrategy cameraGroupStrategy = new CameraGroupStrategy(camera);
        decalBatch=new DecalBatch(cameraGroupStrategy);
        mainChar.setPosition(0.14f, 0f - 1.83f, 0.64f);
        mainChar.setWidth(7f);

        mainChar.setHeight(7f);
        mainChar.setRotation(0, 90, 20.5F);

this is sample from txt file:

mainCharacter.png
size: 4849, 4069
format: RGBA8888
filter: Linear,Linear
repeat: none
01
  rotate: false
  xy: 571, 1
  size: 568, 568
  orig: 906, 906
  offset: 168, 167
  index: -1
02
  rotate: true
  xy: 1141, 1
  size: 568, 572
  orig: 906, 906
  offset: 166, 161
  index: -1
03
  rotate: true
  xy: 2922, 1
  size: 577, 606
  orig: 906, 906
  offset: 161, 144
  index: -1

mainCharacter.png created with texture packer contains transparent areas so that is good.


Solution

  • The problem here is most likely the texture size:

    size: 4849, 4069

    You must stay below 4096 and even this might not work on all devices. I recommend staying below 2048x2048.

    It's a hardware restriction - you can't do much about this.