Unity 2D and Texture Memory.

I’m making a digital storybook, and I’ve got some very happy artists with some very large and CPU expensive textures (like, 4 background textures that are each 1024 x 512). So far, my advice for keeping it performant has been to:

  1. make sure they’re allowing unity to keep things as a power of two,
  2. combining layers where possible
  3. avoiding having images with lots of empty space
  4. Making things static where possible.

But there’s still no way it’s going to look sharp on any iOS Retina screen, and have a good framerate. A friend suggested that making everything – the characters, the backgrounds, everything – into Unity 2D sprites – would be vastly better. Is that true? Why?

Is there any other major performance-increasing thing I could do? Because right now Unity is seeming pretty slow for this kind of thing. I understand that Unity 2D will batch draw calls, but putting all my textures into one gigantic draw call wouldn’t help, right? It’s just putting all the eggs in one basket.

some very large and CPU expensive textures (like, 4 background textures that are each 1024 x 512)

That has nothing to do with the CPU; textures are drawn by the GPU.

A friend suggested that making everything – the characters, the backgrounds, everything – into Unity 2D sprites – would be vastly better. Is that true?

Nope. Sprites aren’t magic and they’re not even really 2D, they’re the same 3D objects that everything in Unity is…textures on meshes. Having 4 background textures on quads vs 4 sprites is going to be pretty much the same, performance-wise. Using sprites makes sense simply because that’s easier to work with, but won’t significantly increase performance. Depending on what you’re doing with the characters and what Unity license you have (Unity Pro can use tight meshes that save on fill rate), you can see some moderate performance improvements.

Anyway, 4 1024x512 textures is not very intensive even on mobile devices and will run quite fast. Just make sure to use a non-transparent shader (i.e., not the default sprite shader) on any textures that don’t actually need transparency, to save on fill rate. Use compression where possible. It’s usually better to use, say, a compressed 512x512 texture rather than a non-compressed 256x256 texture…you can visually scale down the compressed texture to make it look better and it will still use less RAM and be a little faster.