blog games developers documentation portfolio gallery

More in this category:

Simplifying a mesh

Sometimes you download a model from a website that looks awesome, but the number of triangles is just ridiculous. This is especially the case if the model was not designed for games. I downloaded simple curtains with 1M vertices once. Simple LOD would not have helped me since you can't import 1M vertices into Unity. But when the number of vertices per mesh is below 64K, you can do a lot with Simple LOD to reduce the mesh to acceptable levels. Of course you may have to sacrifice a bit of quality, but when you experiment with the compression level a bit, you can probably find a good compromise.

As an example I have taken that brilliant Sky Car that Unity offers as a free asset.

It consist of 13 meshes, 25 sub meshes, 96942 vertices and 153118 triangles. Bloody hell, but it sure looks good.

So the first step is too merge all those meshes together. When you need it to drive and fly, you can't merge all the parts (like the wheels that need to spin and steer), but for this demo we simply merge everything together.

The number of vertices is too big for just 1 mesh, so we divided the child object in to 4 parts. You can also let SimpleLOD do this for you automatically. But for best results we do it manually and make 1 mesh for the body, 1 mesh for the windscreens etc., 1 mesh for the bottom of the car and 1 mesh for the wheels. The reason for this is that the car body uses a reflective shader that will show even the slightest changes, whereas the other parts can have a more compressed mesh before you see any differences.

Note: The time it takes to simplify a mesh increases exponentially with the number of vertices. It is therefor much faster to simplify 2 meshes of 30K vertices each and then merge them to 1 mesh afterwards, than to join the meshes beforehand and then simplify 1 mesh of 60K vertices.

Now to reduce the triangles we will start by simplifying the body mesh with a very low compression value. This will only allow the slightest changes to the appearance of the model. Even the smallest change will immediately be visible because this model uses a reflective shader. With diffuse shaders, the compression can be much higher before you notice the difference. So we use a compression of only 0.015. (This took a bit of experimenting and some patience. I started at 0.05, then went to 0.025 and finally to 0.015)
Even this small value reduces the mesh from 33351 vertices, 58106 triangles to 26673 vertices 45256 triangles. A reduction of 20% and you can hardly notice the difference.

For the windshields and body parts we use a compression of 0.025. This reduces it from 18228 vertices 31493 triangles to 10695 vertices 17260 triangles. A respectable reduction of 41%

For the wheels of the car we use a compression of 0.05. (simply experiment until you get the best result) This reduces them from 12160 vertices, 17016 triangles to 10865 vertices 15165 triangles. A reduction of 10%.

And finally for the remaining parts we use a compression of 0.25 since they are hardly visible anyway and because they have far less smooth surfaces. (Smooth or shiny surfaces show little bumps and dents much easier). This reduces the mesh from 33203 vertices 46503 triangles to 16401 vertices 19007 triangles.

We now have a total of .. vertices which is just under 64K, so we can combine everything into 1 mesh.

And here's our end result. 1 mesh, 10 submeshes, 64274 vertices, 96688 triangles.
A total reduction in triangles of 37% and 60% in drawcalls. And it still looks fantastic. How's that?

You could get even better results by simplifying each mesh separately before combining them. That way you can use the optimal compression for each mesh. But that's a bit more work.
Simplifying Unity Sky Car. From 25 submeshes, 153,188 triangles to 10 submeshes, 12,788 triangles with SimpleLOD

Simplifying Unity Sky Car

From 25 submeshes, 153,188 triangles to 10 submeshes, 12,788 triangles with SimpleLOD







follow us