Texture Resolution Problems

I have been having problems getting proper texture sizes in my game to look the way they were made but also not have such a large size in memory. Inside my project I have some textures that are 2mb-8mb large and look great inside the Editor. But when I try to lower the max size so I can reduce the file size, the resolution becomes very choppy/blurry (obviously).

How exactly do I get the images to look the way they were designed to be without being SO large in memory? I have looked around quite a bit and I really can’t find any proper information regarding this topic. I really need help on this.

Thanks in advanced.

PS: I really don’t know what other information I need to add to this question so please ask me anything else that can help you help me figure this out. Thanks!

You can use compression on the textures. And that’s pretty much it. More data takes more memory.

There are a few more advanced tricks like this great one:
http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf
But that only applies to specific textures and requires some very specific treatment to the textures. I use that approach for traffic signs myself with the reflector pattern added separately. A 192x192 RGBA texture (that can not have compression) can then render a traffic sign at pretty much any resolution being perfectly sharp. But, again, this can only be applied to specific textures.

For the pics or it didn’t happen section. Here’s the result of a 192x192 RGBA texture for a traffic sign:

What kind of compression can I use? I just feel like my 2D game with not so much content should not be 100mb installed on the device.

Well, that all depends on the target platforms and hardware. Note that Unity does apply compression on textures by default.

If you want it in the Play Store, it actually should be less than 100 MB. (You do have the option for expansion packages.) It’s a bit tricky these days. Mobile devices have massive screen resolutions, which really doesn’t make it easy to fit all that high quality content in a small space.

If you really want to go oldschool, you can generate the textures using a shader in runtime. And make an editor for that, like the old 64k demo The Product was made. (These demo’s might be small in file size, but they can be pretty demanding.) Everything in there is generated from code. Models, textures, music…

How does that work?? How exactly do you generate these things through code? Especially if I’m using things through the interface I don’t see how it would work through code

I wouldn’t focus too much on it. It really takes a lot of time to do something like this. The tool they use for textures essentially consists of layering a number of effects. Sort of like in photoshop. Instead of storing the final result, they just store the parameters of all layers, which is a lot smaller. (Just blur(4) for example.) Then at start up, they rebuild the textures. But again, this takes a lot of time and effort to make and it is absolutely not easy. It would be technically possible to recreate something like this in Unity though.

Getting into the demo scene 64kb stuff is kind of silly. That’s not compression so much as a completely different way of creating content. The above example is pretty good, but to extend that imagine only using many Photoshop / Gimp filters for everything, no painting allowed, possibly not even shape tools beyond circles and boxes. Same with modelling for those, everything is either a sphere, or a box, or a cylinder, or a mathematical representation of a surface. No hand modelling.

Texture compression is, as @jvo3dc mentioned, on by default in Unity. There are tricks for reducing the size of your textures by doing things like channel packing or using signed distance fields (ie: the Valve paper). There’s a paper that just came out on using an alternative compression scheme for UI textures that uses a single channel texture with the first mip being the luminance, and the next two mip levels storing hue and saturation (at lower resolution).

These all require some manual work either using custom scripts in Unity or using external tools, and custom shaders.

The only stuff built into Unity is what you can see when selecting the texture in Unity, adjusting the max texture size and format, and really the only thing you can do to make a real impact is to reduce your texture sizes since the textures are already basically maximally compressed by default.

Yes, but the second I lower the texture size, the texture loses a lot of its quality

Yep.

There is one last trick that some larger games use. They reduce the download size to something small (like 50mb back when that was the max size) by not actually including all of the content in the app download. Instead the app you download from the asset store only has enough in it to show a loading screen, or maybe the main menu, and then download the rest of the game content when you start up the application. A variation on that is have low quality versions of all of the game assets in the initial app download, and then download higher quality assets depending on your device / internet connection. However this requires a lot of work and paying for your own servers to host content from, and it adds significant friction to first time players’ experiences.

Really though there is no magic bullet here to reduce app sizes once a game has been made. Even big titles of the past (like some of the Angry birds games) have had horribly low res textures for random things because they likely ran into the same problem. If you’re trying to get your app size lower you have to make the choice to reduce the quality someplace.

Starting over from the beginning if your game style is vector art based you could have used an SVG importer that generates meshes or textures at run time, which is kind of similar to the demo scene 64kb demos approach. Or you could have built in a lot more content reuse early on (like the now famous clouds & bushes of the original Super Mario Bros being the same sprite with different color palettes).

If it’s not vector art, there are some tricks left, but that also requires a change of assets:

  • Detail textures, combining two different small textures on different scales can replace one big texture in some cases.
  • Projectors, adding projected details in the scene to break the repetition of a small texture.

I’m not sure if I mentioned yet that I am working on a 2D game. Also, all the art that I am getting IS Vector art (saved as PNG) . I looked into an SVG importer for Unity but read that this is not a good way to go for images. Is this true?

I’m confused by that statement, I feel like there’s some context missing there as SVG files are vector image files, so the whole point of SVG is to use them “for images”.

It’s possible the info you found was referring to using embedded bitmap images inside SVGs and as best I know the various SVG importers for Unity don’t work with embedded bitmap images, they just draw the SVG paths. If someone was using SVGs to make textures for 3D models that might also be problematic as some importers work by converting the SVGs into meshes, but others work by generating sprite sheets or texture assets from the SVGs at runtime.

So if I were to use an SVG importer to import SVG for all my scene objects would that be ok for my game? Would the performance get messed up?

Also, I have another question about something I keep noticing. Inside the Unity Editor I drag in a sprite which looks pretty decent but as soon as I hit the play button, the quality of the image drastically changes to a lower resolution. What could be the reason behind this?

Edit: Apparently if I use Packing Tags on my sprites, the sprite quality becomes crappy when in Play Mode. Why would this happen??

Performance will change, for sure. You’d have to try to see how. Using the mesh-based SVG will require playing with the various quality settings as the poly counts can get quite high. The runtime SVG to texture methods mean uncompressed textures which might have performance impacts.

No idea, I don’t use sprites. You might try asking in the 2D forum. https://forum.unity3d.com/forums/2d.53/