How to "Simplify" a Mesh in unity?

I’m wondering how to reduce a mesh’s tri/vert count while still keeping it’s general shape. I know there are assets that can do this but I want to be able to do this in code at startup from my own script. In the end I want to just have a Mesh class object and be able to make a simplified version of it.

For instance I have this mesh:

Which has 1588 verts and 826 tris. But I want to make a simplified version in a new Mesh object that retains the shape without the needless tri detail.

How would I go about achieving this? Is there something that can do this already?

Thanks

There are a few solutions in the Asset Store that allow you to simplify the meshes, but I am not using any of them on a regular basis and as such I can’t give you more details.
In case you didn’t check the Asset Store yet, it is definitely worth a try.

Thanks Dantus, though afaik the assets on the store are editor based and I need one that can do it at runtime/startup. I can’t find one that I can guarantee will do what I want.

Do you want to retain the “high res” version as well?
Sounds like the LOD system would be the best built in path to follow.

Seems like a pretty simple 3D game object, if you’d like to use LOD and need assistance getting the LOD’s drop me a PM and I’ll help you out. :slight_smile:

Thanks theANMATOR2b, just started a convo with you :slight_smile:

Guess what I’m looking for is an algorithm for simplifying a mesh. I’ve found some papers online but I’m not very good at translating it to something usable with a mesh in unity.

That is enormously complex. In fact, most ‘mesh simplification’ functions in professional 3D packages they really suck, and they have specialized teams working on it. Few are the mesh simplification programs that provide decent quality out there. I’m afraid this is a very huge project, if you really want to come up with something decent, you’ll be spending months writing countless lines of boring code, rewriting it all over again, and debugging the result against a multitude of different models which will prove that what worked in one case simply won’t work for another slightly different one.

I had to make a runtime LOD generator recently for complex objects created at runtime, in this case of voxels, and I ended up using billboards (not camera aligned). The efficiency wasn’t very great because the distance to swap the actual mesh can’t be too short or it’s clearly visible, but in the end it was by far the best solution. I was going to create an intermediary LOD using particles or something efficient (point sprite perhaps), but I don’t know how I would do that in Unity. The fact is, it took ONE day to put it together so even though it wasn’t the best LOD system in the world, the ROI was simply unmatched.

If you need something more sophisticated, I highly recommend using the solutions that already exist. If the mesh were mostly convex and evenly triangulated, you could do something like is shown in an Overgrowth development video. Sorry but I don’t have a link, but in any case I’m pretty sure it won’t work for that model.

1 Like