Whinarn / UnityMeshSimplifier

Mesh simplification for Unity.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

multiple thread support

chaoslife opened this issue · comments

First of all thanks for such a great tool, will this be support multiple thread process future? It process big model to lod group cost so many times.

Best

I have considered this in the past, but not prioritized it. Turning the current simplification algorithm multi-threaded with parallelism to a level where it's worth it would be difficult. And while there are other algorithms out there designed for parallelism, that would mean rewriting this completely which I'm currently not interested in.

The result of me thinking about this in the past was that the more likely problem is multiple smaller models that needs to be simplified rather than few large ones. And in this case the algorithm should be fine with the simplification running on different threads for one model at a time, as long as the initialization of copying over mesh vertices and attributes over is done on the main thread due to Unity API limitations. It could potentially quite easily be possible to create a job utilizing the Unity job system. But no code has been written to deal with this, but it should be possible without having to modify the existing code, and just write additional code.

The initial goal of this project was actually doing mesh simplification at runtime, since pretty much nothing I could find at the time could support that. But I do realize that most people probably only use this in the editor using the components, and then you are likely to just want to simplify one mesh at a time. Which would then make my argument above irrelevant.

So the summary is that there are no current plans to do any of this. With my solution above being much easier to implement, but also possibly not a solution that would help you.

If you are a programmer and the above solution sounds like something that might benefit you, I could perhaps put down a few hours to make this easier to do for you. Otherwise I believe that your best option would be to find an alternative solution somewhere. But I do understand that there are not many free open source alternatives at that, unfortunately.

Let me know how you would like to proceed, if you would want further assistance.

I hope this helps!

FWIW, @chaoslife, what @Whinarn is describing is how AutoLOD makes use of UnityMeshSimplifier. A separate job is kicked off for each LOD that gets generated. I'm not sure how easy it would be to build a custom solution, but some of that code may be helpful. There's also a thread-safe WorkingMesh struct for passing meshes to jobs although depending on your Unity version you may just want to use Unity 2020's MeshData.

ok, thanks all. I will read this first.