-
-
Notifications
You must be signed in to change notification settings - Fork 253
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
Tiny hole in the mesh of VoxelLodTerrain #641
Comments
It appears to be caused by this: godot_voxel/meshers/transvoxel/transvoxel.cpp Lines 712 to 749 in 4187c63
The mesher eliminates triangles that are too small or degenerate, because that makes Jolt Physics spam errors. |
I see. Feel free to close the issue. |
Another option would be to snap/clamp edge interpolation factors so that vertices cannot be generated too close to corners of marching cube cells, which then tends to produce less thin/small triangles, at the cost of slightly biasing the resulting mesh. |
From the description and provided images in the post of your link, it sounds like if mesh vertices are very close to integer coordinates (which are corners of the cubes), then vertices get set to those integer coordinates. Something like this I'd assume: float epsilon = 0.05;
float rounded_pos_x = round(pos.x);
float rounded_pos_y = round(pos.y);
float rounded_pos_z = round(pos.z);
float diff_x = abs(pos.x - rounded_pos_x);
float diff_y = abs(pos.y - rounded_pos_y);
float diff_z = abs(pos.z - rounded_pos_z);
if (diff_x * diff_x + diff_y * diff_y + diff_z * diff_z < epsilon * epsilon){
pos.x = rounded_pos_x;
pos.y = rounded_pos_y;
pos.z = rounded_pos_z;
} |
No, you're only describing the result of it. Vertices are generated on edges of marching cube cells, and that depends on an interpolation factor between pairs of corners. That factor can be clamped/snapped, but the SDF values can also be clamped/snapped. I'm not sure which one they are referring to. One downside of doing it on the SDF is that it requires to know how gradients progress, which in turn depends on them being good gradients. On the other hand, the interpolation factor has no unit and is normalized, so is easier to clamp (however it is known after case selection so triangle count won't change) |
Considering the author of post there mentioned percentages, I can only imagine this working with the interpolation factor since it can be a fixed range of [0, 1], where 0 is starting point of the edge, and 1 is ending point. If SDF can be "infinitely large", then I don't see how percentages can be used to "snap" the SDF. |
I removed the code that was removing small triangles, replaced it with a margin property that clamps edge interpolation. |
Describe the bug
As title says, I found a case where the meshed SDF of VoxelLodTerrain contains tiny hole.
To Reproduce
Download project and run it. Upon launch you should see this which contains triangle shaped hole:
Expected behavior
There should be no holes in the mesh.
Environment
Test Mesh issue.zip
The text was updated successfully, but these errors were encountered: