Quantcast
Channel: Answers by "Noise crime"
Viewing all articles
Browse latest Browse all 90

Answer by Noise crime

$
0
0

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'


Viewing all articles
Browse latest Browse all 90

Latest Images

Trending Articles





Latest Images