Optimizing SimplifyModifier

Hello community!

I recently stumbled upon SimplifyModifier when I needed to dynamically reduce the face count of loaded geometries in my application.

In the end I rewrote the module completely to suit my needs. Part of this exercise resulted in an optimization of the collapsing code. I achieved >65% performance improvement overall.

So I decided to modify the original file and share the critical change. It is really minor - see lines 80 to 97.

I drive the collapsing of vertices with an array containing the desired number of lowest cost vertices to be removed.

https://github.com/WhaleTalon/SimplifyModifier.js

Hope this is of interest.

4 Likes

Awesome! Have you considered making a PR into three.js to fix the original implementation?

2 Likes

@gkjohnson thank you!

There are a few smaller tweaks that I would like to apply. If there is interest I can apply those and make a PR.

Are there any related requests or suggestions while I am at it?

3 Likes

Please note that my changes to the SimplifyModifier was somewhat naive.

Using a sorted array to drive the collapsing of vertices is a good way to remove the problem of exponential complexity . However, my implementation does not take into account the changing “collapseCost” as vertices are removed, and the impact of this grows worse as more vertices are chosen to be removed.

I intend to publish an update next week, once my current project is done. I believe the answer lies in making a more efficient data-structure to hold the vertex and face data.

How about adding other attributes of the BufferGeometry?

Right now the Simplifier only maps the position attribute, and I would like to support other attributes as well.

I’m interested in keeping normals and materials in a way after simplifying.

1 Like