February 14, 2016

Tips,use mipmaps!

Hello!

Today I will do a different post,I will give you a tip !

So mipmaps...? Mipmaps are representations of one texture viewed from different distances, they exist because,most of the time, the original texture wont be 100% displayed on the screen.



For example:we have a crate that uses a wonderful 2048x2048 full-hyper-hd-hires texture,but the player wont ever get close to it.The texture then will be rendered in a smaller portion of the screen (lets say 300x300).That means that the graphics card must do some magic to decide which pixels should be painted.


The result will be a random-like texture:


It is not only ugly,it also will decrease the performance,why?Because trying to paint a 2048 texture into a 300 spot will cause a lot of cache fails.
A cache fail is basically when, the system loads memory but it gets discarded and has to load it again.

Lets see what happens when we use mipmaps:


As you can see,it looks smoother and also, we increased the fps! (from 270 to 780!!!)

The only bad point could be that we need more space for each texture,but this is insignificant with the performance increase.


Hope you liked it!