simplifier: Evaluate attribute error for both edges for seam collapses #801
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When collapsing seam->seam or seam->locked edges, we were assuming that the attribute error on both the primary edge and the seam pair is about the same. There are cases when this is not true; that leads to the collapse with an ostensibly low error significantly changing attribute appearance.
To evaluate the error, we need to use the same logic as we use during perform() to discover the seam pair, and use the accumulated error of the two for the attribute component. The earlier notes in the comments suggested max/avg would be appropriate, but accumulation is actually correct: each error is weighted in proportion to the adjacent triangle areas, and if the seam didn't exist at all, these errors would be naturally accumulated through quadrics accumulation. So even on seams where the edges align in their respective attribute deviation, this change improves the "fairness" of seam collapses as it comes to attribute errors.
This fixes issues like this with normal shading on Bistro (LOD selection exaggerated to a ~16px threshold):
Since we evaluate slightly more edges now, this makes simplification of complex models a little slower; on models with few seams, like Buddha, this is neutral on performance; on Bistro it's ~2% slower. This performance delta is mitigated by skipping reverse evaluations for unidirectional edges, as it doesn't look like this is actually helpful - the reduction in branch misprediction is not worth the extra ALU cost.
This contribution is sponsored by Valve.