Fixes misaligned SDF grid#11
Open
Shardj wants to merge 1 commit into
Open
Conversation
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


This fixes an off-by-one alignment issue in the SDF grid coordinate mapping.
The API documents input vertices as being in
[-1, 1], and as a result the expected a grid ofsizesamples should span that same domain. However, the C++ binding useddx = 2.0f / sizewith origin(-1, -1, -1), so the sampled coordinates were:-1, -1 + 2/size, ..., 1 - 2/sizeThe positive
+1boundary was never sampled. In practice this makes padding applied to the mesh asymmetric: geometry aligned with the negative side of an axis gets the expected margin, while geometry aligned with the positive side is one grid interval short. When mapping the SDF grid coordinates back to world space it then also resulted in a misalignment between the position and size of the mesh and the position and size of the surface described by the SDF grid.This PR changes the spacing to
2.0f / (size - 1), treatingsizeas the number of samples rather than the number of intervals, so the grid samples now use the full[-1,1]range. Spanning:-1, -1 + 2/(size - 1), ..., 1The
fix=Truemarching-cubes voxel-coordinate normalization is updated the same way, keeping the reconstructed mesh in the same coordinate frame as the SDF grid.