2

I have a stack of transparent PNGs that I'd like to use in a SKSpriteNode animation with SKTextures. I'd need to adjust the memory usage of SKTextures by reducing texture quality down from RGBA8888 to RGBA4444.

How would I initialize SKTexture with RGBA4444 texture format?

Edit: IOS Swift Game Development Cookbook: Simple Solutions for Game Development suggests that SKTexture would support PVRTC files as follows:

enter image description here

However, I couldn't get a SKSpriteNode to display a texture generated this way.

Markus Rautopuro
  • 7,997
  • 6
  • 47
  • 60
  • 1
    See https://stackoverflow.com/questions/39106245/how-to-change-texture-format-to-rgba4444-for-sprite-atlas-created-in-assets-xass/39928198#39928198 – MoDJ Dec 15 '16 at 21:05

2 Answers2

2

I just tried and in Xcode 8 the option Output Texture Atlas described here is no longer available into Build Settings.

I suspect (but I could be wrong) the control has been now moved inside Compression as you can see in the following image.

enter image description here

Community
  • 1
  • 1
Luca Angeletti
  • 58,465
  • 13
  • 121
  • 148
  • I guess the only option to have `SKTexture` compress the texture data *in memory* is to use texture atlases? I didn't find any `SKTexture` initializer options that would point out to texture compression. – Markus Rautopuro Dec 12 '16 at 11:49
  • @MarkusRautopuro: Yes probably. However you should use a Sprite Atlas also for a faster CPU-GPU communication. – Luca Angeletti Dec 12 '16 at 11:52
  • 1
    The problem is that I have large PNG files and a lot of them. The only option would be to create the sprite atlas programmatically. However, I didn't find a way to set the compression to `SKTextureAtlas`. – Markus Rautopuro Dec 12 '16 at 12:26
1

I circumvented this by using TexturePacker to generate a texture atlas (.atlasc) file. With TexturePacker you can set adjust the compression and then access the texture atlas in your project as follows:

let atlas = SKTextureAtlas(named: "Atlas") // Atlas.atlasc in your project
let texture = atlas.textureNamed("original_texture_001.png")
Markus Rautopuro
  • 7,997
  • 6
  • 47
  • 60
  • As MoDJ pointed out in this answer http://stackoverflow.com/a/39928198/2155985, that all textures in Sprite Kit will be loaded into memory as RGBA8888. I need to confirm this also. – Markus Rautopuro Dec 17 '16 at 09:21