Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplifySloppy doesn't have a way to specify the target error #112

Closed
gjaegy opened this issue Feb 27, 2020 · 3 comments · Fixed by #217
Closed

simplifySloppy doesn't have a way to specify the target error #112

gjaegy opened this issue Feb 27, 2020 · 3 comments · Fixed by #217

Comments

@gjaegy
Copy link

gjaegy commented Feb 27, 2020

Hi,

I'm playing a bit with your great library in order to decimate some over-detailled 3D models, before using the result as basis for a collision mesh.

The input I have is therefore basically a list of vertex positions, and a list of indices (not other vertex attributes).

I'm first running meshopt_generateShadowIndexBuffer() in order to have all vertices with a similar position to be collapsed.

Basically, my issue is that I haven't managed to get a result that's simplified enough using meshopt_simplify(). The initial mesh has 345k triangles, the output has 285k triangles, whatever parameters I've tried.

I've set the target indices count to something very low (50) and even tried to increase the error to its maximal value (1.0f), however, that doesn't make a big difference.

Using meshopt_simplifySloppy(), results are much better (basically reaching the indices target count), however, I'm want to use an error threshold rather than a target indices count (since I don't want the artists/user to have to enter a target indices count, moreover, the input meshes are really variable, some are too detailled, some are not, so an error threshold makes much more sense to me).

So, I'm stuck with meshopt_simplify() I think, appart in the case you have an idea how to use meshopt_simplifySloppy() with an error threshold as input ?

meshopt_simplify:
simplify

meshopt_simplifySloppy:
simplifysloppy

What puzzles me a bit is that meshopt_simplify() doesn't modify the topology, despite having the error threshold set to 1.0f and the target indices count set to 10. You can clearly see that when looking at the windows of the building in the foreground. Despite the significant threshold, the windows are not simplified.

Is that normal ? Can I improve that ? Or is there a way to use meshopt_simplifySloppy() with an error threshold as input, rather than a target indices count ?

Thanks a lot for your help !!

@zeux
Copy link
Owner

zeux commented Feb 28, 2020

So I think there's two parts here.

  1. Should meshopt_simplifySloppy be able to simplify towards a target error? I think the answer is "yes". It was implemented the way it is right now originally to be able to guarantee a target triangle count, but in some usecases you may want to simplify as much as possible and if other attributes aren't important (which is precisely the case for physics geometry), it's a reasonable option.

  2. Should meshopt_simplify be able to simplify this mesh further? I feel like the answer might be "yes" but I'm not 100% sure, it might be hitting some of the limitations on the topology that can only be relaxed by adding options to the algorithm.

I plan to spend more time on the simplification algorithm after the next release (where I'm trying to finalize geometry compression), so I'll definitely look into this but not immediately. Would you be able to share the model in quiestion in an .obj format to be able to investigate pt 2?

@gjaegy
Copy link
Author

gjaegy commented Feb 28, 2020

Thanks for your answer, very appreciated.
You're right in your analysis. I've spent some more time on that yesterday afternoon.

My issue is that the source models used as basis to construct the collision mesh are provided by the users, and therefore have a huge variety as far as the level of details/quality/triangles density are concerned. Some are simply light pole, some are representing a complete airport terminal.

Some of them could be used as they are, since very optimal, some others are over-tesselated. Therefore, using a triangles count target is basically not an option (there is no way to define a proper rule because of the issues mentioned above). An error tolerance threshold is the solution I think.

  1. I think meshopt_simplifySloppy is indeed what we need in our case. We can accept some topology change (like we can accept the windows to be flatten out and merged with the walls for instance). However, it only accepts a triangle count target.
    Looking at the source code, I found some part of the algorithm that compute errors (fillCellRemap()) but being honest with you, I haven't been able to understand what's going on exactly :). I understood you build some quad/cells and compute the error between the original vertex and the quad. But I haven't been able to figure out how to parametrize the error (it seems the target triangles count has an impact earlier when defining the number of cells).

  2. I also think the meshopt_simplify is indeed stopping because of some topology respect rules (further simplification is clearly not restricted by the 1.0 error and 10 target triangles count).

I will extract some of the meshes as obj (remember I first remove all attributes other than the position and collapse similar vertices using your meshopt_generateShadowIndexBuffer() function) and attach them in that thread later today.

Thanks a lot for your help, it's really appreciated. Also let me know if I can help.

@zeux zeux changed the title issue getting enough decimation using simplify simplifySloppy doesn't have a way to specify the target error Dec 28, 2020
@zeux zeux closed this as completed in #217 Jan 1, 2021
@gjaegy
Copy link
Author

gjaegy commented Jan 5, 2021

Hi Zeux, thanks a lot for that update, really appreciate. I'll try to have another go with these changes in a couple of weeks, I'll let you know the outcome !
Thanks again !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants