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

Reduce normal tolerance for Weld #1035

Merged
merged 2 commits into from
Jul 29, 2023
Merged

Reduce normal tolerance for Weld #1035

merged 2 commits into from
Jul 29, 2023

Conversation

rotu
Copy link
Contributor

@rotu rotu commented Jul 21, 2023

Fix #1028
Chose 0.01 as a default tolerance which corresponds to ±arcsin(0.01)/2 = ±0.286°.

Chose 0.05 as a default tolerance which corresponds to ±arcsin(0.05)/2 = ±1.43°.

Fix donmccurdy#1028
Chose 0.01 as a default tolerance which corresponds to ±arcsin(0.01)/2 = ±0.286°.
@rotu
Copy link
Contributor Author

rotu commented Jul 21, 2023

Oops! I had forgotten to submit this PR.

I think it's a pretty good threshold, but I'm not sure if there's a more principled way to set these values!

@donmccurdy donmccurdy added this to the v3.5 milestone Jul 23, 2023
@donmccurdy
Copy link
Owner

donmccurdy commented Jul 23, 2023

Would you be able to share a model that reproduces the bug described in #1028?

One test case I've used before is this:

https://sketchfab.com/3d-models/sculpt-january-day-19-lovecraftian-34ad2501108e4fceb9394f5b816b9f42

gltf-transform optimize in.glb out.glb --verbose

The largest mesh in that scene has just under 900K vertices, and the normal tolerance makes a big difference when welding:

  • before: 873,244 → 228,453 (–73.84%) vertices
  • after: 873,244 → 802,173 (–8.14%) vertices

At least in this case, the more aggressive weld is preferable.

Aggressive welding is also an important step before simplifying a model. I'm hoping there's a "happy medium" value that can give us a better default here, but perhaps this option just needs to be exposed in the CLI too.

@donmccurdy donmccurdy added feature New enhancement or request package:functions labels Jul 23, 2023
@rotu
Copy link
Contributor Author

rotu commented Jul 23, 2023

https://wormhole.app/YO9Mr#-YSuDqBOBOySwiBYmNR7tA

The visible weld issue on my model goes away at a normal tolerance of about 0.3. So maybe 0.1 is a good threshold?

@rotu
Copy link
Contributor Author

rotu commented Jul 23, 2023

Here's a pathological example that's wrecked by optimize, though not by the weld step alone: https://sketchfab.com/3d-models/scifi-hexsphere-cb364832b9994b768dba6245e6b3f51b

edit: a weld threshold of 0.1 is almost enough to prevent the problem.

@donmccurdy
Copy link
Owner

Thanks! I think 0.05 seems about right. I'd recommend higher tolerance, closer to 0.5, when weld() is used as a pre-process before simplification for LODs. Simplification (for now, at least) cannot do much with disjoint topology.

@donmccurdy donmccurdy merged commit 9525344 into donmccurdy:main Jul 29, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New enhancement or request package:functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

weld has huge normal tolerance
2 participants