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

Simplification should prefer more uniformly tessellated meshes #664

Open
marwie opened this issue Mar 15, 2024 · 6 comments
Open

Simplification should prefer more uniformly tessellated meshes #664

marwie opened this issue Mar 15, 2024 · 6 comments

Comments

@marwie
Copy link

marwie commented Mar 15, 2024

Hello, below is a video of a 100 vertices plane simplified with ratios [0.5, 0.25, 0.125, ...] and an error of 1

It seems like the simplification is suddenly stopped once a threshold is reached where areas of the mesh then stay untouched.
We also observed this on a relatively high density sphere where it resulted of dense islands

Expected behavior
Simplification is uniformly applied

assets.zip

20240315-101103_Min_-_Google_Chrome-logo.mp4
@zeux
Copy link
Owner

zeux commented Mar 15, 2024

I can't reproduce this in gltfpack. I get the following mesh with simplification factor 0.006 (going lower than this triggers a safety check in gltfpack code that should probably be reworked somehow, so the mesh stays in its original form):

image

In theory this should have gone all the way down to one quad, but I think there's some tricky edge conditions that might be preventing this from happening.

On the sphere file, with the error threshold of 1e-2 gltfpack simplifies down to 82 triangles:

image

@hybridherbst
Copy link

hybridherbst commented Mar 15, 2024

To clarify: the issue outlined here is that decimation in some cases doesn't lead to a somewhat uniform simplification (as would be expected), but instead leads to a weird state where some part of the mesh is aggressively reduced while other parts stay at original density: (e.g. this is "ratio: 0.5" from 0:02 in the video)

image

It almost looks like decimation goes vertex by vertex and "stops" once the target ratio is reached; expected would be a more uniform approach that leads to somewhat similarly sized triangles.

@zeux
Copy link
Owner

zeux commented Mar 15, 2024

similarly sized triangles

This is not a criteria that the simplifier takes into account. The appearance of a tessellated plane is the same regardless of which interior edges you collapse. The error of every version on this video is close to 0.

@hybridherbst
Copy link

hybridherbst commented Mar 15, 2024

Interesting! I wasn't aware that meshoptimizer doesn't optimize for similarly sized triangles, which to be best of my understanding are another property that is important for efficient GPU utilization (avoiding small triangles and aiming for a uniform triangle distribution on screen).

We noticed this issue on other meshes (e.g. spheres in some cases exhibit "nests" of lots of non-optimized triangles) and also in production meshes where in some areas nothing was optimized and other areas got optimized aggressively. A plane was just the easiest to demonstrate. Sounds like we'll need to provide a better mesh that shows the issue if you say that this is essentially by design.

@zeux
Copy link
Owner

zeux commented Mar 15, 2024

All things being equal, more uniform triangle density is definitely preferred for efficiency; the simplifier right now is predominantly concerned with appearance. I was considering some sort of edge length metric addition which becomes more important for better attribute treatment but right now the metric is purely "distance from the original surface", which is invariant to density. Introducing additional non-critical factors like this is difficult because they distort the original quality metric, so careful tuning is critical.

My experience has been that on production meshes you mostly don't run into this problem - you can still have areas where nothing is optimized of course, but when that happens that usually happens because of topological constraints, not because of error constraints. I'd welcome examples where that's a problem, with exact values of error & target count so that I can reproduce this more easily.

@zeux zeux changed the title Simplification seems to stop suddenly once error/ratio is reached resulting in partially simplified mesh Simplification can result in non-uniform tessellation Mar 15, 2024
@zeux zeux changed the title Simplification can result in non-uniform tessellation Simplification should prefer more uniformly tessellated meshes Mar 15, 2024
@dbs4261
Copy link

dbs4261 commented May 28, 2024

Based on the papers, this could be helped by adding a pointwise quadric that is the distance to the original point. A=I, b=-p c=p*p, all multiplied by the weight. I don't think this would solve the issue with getting rid of the last few edges down to one quad or triangle. But it would probably help in the intermediate stages.

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

No branches or pull requests

4 participants