How do I turn off "mip mapping"

Hi guys and gals,

I'm devleoping a simple 2D game for children and becuase I'm such a novice I'm using as much middleware as possible! In this case, both Sprite Manager 2 and iTween. They're very cool and there's no way I could have gotten as far as I have without them.

Now, I read somewhere that for optimisation reasons (I'm devloping for iPhone), I should turn off mip mapping. Since I have absolutely no idea what mip mapping is, I don't know where to look. I've got some sprites created in SM2 with sprite atlases generated from the PNG images I've imported.

Are there any other optimising steps I should consider taking? I understand that using SM2 is a good start since it allows you to put lots of images onto one texture/ atlas, whatever...!

As always, thanks to anybody who can help!

Judy x

Mipmapping can be found in the texture inspector. So go through all your textures one by one, select one in the project view and make sure you can see it in the inspector. Locate the 'Generate Mip Maps' option and disable it, then click on the 'apply' button.

You may also want to change the 'Filter Mode' to bilinear or point.

However 'Point' filtering often leads to something called 'Sparkles' when you move the camera view point. This is because 'point' sampling only maps the closest pixel from the texture to a single pixel in the rendered scene for that frame.

Now at 1:1 resolution this doesn't matter, but if the area the texture is being rendered to is smaller than the texture size then there could be several texture pixels that should cover a single pixel in the scene. Normally in these cases you'd take an average of all those pixels, but since we're just using the closest one, it often means that from frame to frame that a different one of those pixels will be chosen. Thus giving a sparkle effect as different pixels are shown on different frames.

The solution to this problem, which is highly effective is mip maps (which also greatly improve performance due to cache coherency). When using mip maps Unity generates a series of textures that are half the size of the previous texture. Effectively then this is downsampling and averaging. So if you have a 256x256 texture, mip maps will be generated for 128x128, 64x64, 32x32, 16x16,8x8,4x4 etc. The gpu can then use these as a quick look up to find the averaged pixel value. Obviously there is a 30% overhead in memory here as those mip-map textures need to be stored along with the original texture, hence the suggestion to disable them.

Since we have disabled them that route is no longer open to us. Luckily you can also specify that instead of the closest pixel you can do linear interpolation between the closest pixels, but this obviously requires more computation per pixel.

However i'm not yet familiar enough with Unity to know how you'd set that up. I can only assume (from testing) that keeping the filter mode set to 'bilinear' when you don't have mip-maps, will fallback to linear interpolation. So you'd probably want to use that.

Best advice is to turn off mip-maps and then run the program and test the different 'filter modes' of a texture and see which you prefer.

However be careful as whilst disabling mip-maps can save memory, it may end up taking more processing time. The reason being that mip-maps can often be more cache freindly, meaning the next pixel to be rendered is already in the gpu cache and will be faster to retrieve. For a full size texture being rendered far away, this is no longer the cases, thus more memory ends up being moved around to render the texture.

The only way to know for sure, is to test in your game. It may be you end up using a mixture of textures with and without mip-maps or you may find no decernable performance hit from not having them and using 'bilinear'