Hello Guest

Author Topic: Atlas optimization question  (Read 4015 times)

Lightja

  • Newbie
  • *
  • Posts: 3
    • View Profile
Atlas optimization question
« on: December 07, 2013, 11:34:38 am »
So... I know textures are best loaded in/out of memory in dimensions that are powers of 2. Given that ALL atlases are powers of 2, do all of the textures inside the atlas need to be powers of 2? Or can they be whatever size they want, since the atlas is already a power of 2?

so I have 2 options
1. Create all my atlases (which are powers of 2, like 1024x1024 usually) and put all of my textures inside these atlases as powers of 2 themselves (sprites 32x64, 64x64, 128x64, etc. depending on the sprite) This leaves a significant amount of unused space in the atlas.

2. Create all my atlases (which are powers of 2, like 1024x1024 usually) and pack my textures as tightly together as possible so that I don't have any waste (or very little) in the space of the atlas. If we did this, our artists could actually build atlases with the intention of fitting as many on one atlas at a time, because loading too many atlases at once is currently one of our major issues (we'll be looking into asset streaming, but that's a separate issue)

**one of my very common problems is that we have a 65x128 sprite, but because we want it to be powers of 2, we use it as a 128x128 sprite, and it's almost twice as big as it needs to be, creating about 49% waste for that sprite, increasing the wasted space for the atlas. In the worst of the worst situations, an atlas that forces power of 2 textures could have half the sprites that an atlas with NPOT (non-power of two) textures, meaning I would have half the memory load.

So do the advantages of having textures as a power of two outweigh the wastes space of the atlas? Or is that the whole point of the atlases being forced into powers of 2 in the first place, meaning sprites can be whatever size necessary?

sorry if this seems like a simple/obvious question, but I haven't been able to find anything about it. The technical director on my project enforces POT textures very strictly, but due to the way atlases are set up, I'm wondering if I should challenge that for the sake of efficiency.
« Last Edit: December 07, 2013, 11:36:41 am by Lightja »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Atlas optimization question
« Reply #1 on: December 07, 2013, 02:41:07 pm »
tk2d packs textures pretty tightly for you. Your source images don't have to be PO2, but the atlas should be. tk2d also trims and crops your texture, so even if there was a lot of 0 alpha space in there it will be fine. What you want to aim for is to utilise the atlas fully.

Lightja

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Atlas optimization question
« Reply #2 on: December 07, 2013, 04:36:19 pm »
so for the images that go inside the atlas, I should ignore trying to get them into powers of 2 and just try to fit as many textures into the atlas as I can so that there's as little waste as possible?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Atlas optimization question
« Reply #3 on: December 07, 2013, 10:22:02 pm »
You don't need the source images to be po2 at all. Try to fit related stuff in 1 collection as best as you can, ultimately you don't want completely unrelated images in the same atlas.