Texture Import Settings for GUI & 2D Games

I’ll try to describe the best import settings for GUI textures and 2D games in Unity3D. I’m assuming that you are familiar with the options in the texture import settings window and techniques like mip mapping and filtering modes etc.

If you would like to skip the long reading, here is a brief version;

  • Turn off Non Power of 2
  • Turn off Generate Mip Maps
  • Set the Wrap Mode to Clamp
  • Set the Filter Mode to Point
  • Set the Aniso Level to zero
  • Set the Max Size to something equal or greater than your texture

In most games, GUI textures have no perspective and we are using orthographic cameras to render them. Their distance to the camera never changes. So the first thing we should do is to get rid of the mip maps.

Mip mapping is a technique where it automatically generates smaller versions -in quarters of the texture for each mip to be exact unless you use anisotropic filtering- of the given texture to match the amount of pixels it will cover on the screen thus it can adjust the best mip level on the mapped 3D geometry based on the distance of the geometry to the camera. It is used because when you map a 1024 x 1024 texture on an object that covers only 20 pixels on a screen, no matter what type of filtering you use, it will have poor visual quality.

Another thing we should do is, if we are working on a project that will run on more advanced devices like a desktop PC with a dedicated GPU, is to turn off the Non Power of 2 option. Most of the current generation GPU’s support npot textures. If you are working on a project for iOS or Android then it’s not an option. What you can do there is, use a square canvas for your texture with an alpha mask for your gui item. While it’s the easiest solution, it’s not the best idea because you will run into fillrate problems with such transparent geometry especially if your gui covers most of your screen. You can model an outline of your gui item instead of using a plane there to minimize the transparent areas if you are having performance issues.

We should also change the Wrap Mode to Clamp so our texture will be clamped to the uv limits of our geometry. It solves the single pixel row/column of repeating texture problem.

Filter Mode should be set to Point, Bilinear mode interpolates the colors of the four nearest texels to the pixel center so while it solves most of the mapping problems like blockyness it results in a kind of blurry rendering. (Our source texture and the amount of pixels it will cover on the screen should be equal so we won’t have any problems that bilinear filtering solves) And Trilinear filtering is just a technique where additional mips are generated between the default mip levels to remedy the problem where it is possible to see the quality change when the mip levels are changed from one to another. Point mode doesn’t apply any interpolation and if we did create our art assets in the pixel values they will cover on the screen, they should render crystal clear.

You can set the Aniso Level to zero if you are going to use anything other than Point filtering. Anisotropic filtering generates additional mip levels in rectangular or trapezoidal format to be used when the applied geometry is rendered from oblique angles. Imagine you are mapping a square texture to a rectangular geometry like a road. As we are using non mipmapped textures here, we don’t need anisotropic filtering. (It also makes me wonder why this option is still active after turning off mipmapping, any ideas? It obviously has something to do with Bilinear and Trilinear filtering. Let me know with a comment please!)

And finally Max Size should be set to something where it is equal or greater than our source texture’s dimensions.

So above information applies to all 2D game GUI and all the textures in a 2D game where the camera is orthographic and it’s distance is fixed. Hope it helps, and let me know if I have any misinformation there so I can learn and also edit the post!

3 Comments Texture Import Settings for GUI & 2D Games

Leave a Reply

Your email address will not be published. Required fields are marked *