Automatic materials sorting on a mesh.

Some kind of doubleposting, here is main thread:

Delete if posible plz.