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

MROffset to keep sharp features #884

Open
MarcoWang1 opened this issue Jan 15, 2023 · 17 comments
Open

MROffset to keep sharp features #884

MarcoWang1 opened this issue Jan 15, 2023 · 17 comments

Comments

@MarcoWang1
Copy link

MarcoWang1 commented Jan 15, 2023

you use openvdb to do mesh offset. It is good. but the origin openvdb code can not preserve sharp features.
Do you have plans to optimize the code to keep sharp features?

@Fedr
Copy link
Contributor

Fedr commented Jan 15, 2023

Positive offset (outside of original surface) is a smooth surface with minimal convex curvature radius equal to offset distance (it can have sharp concave regions, but they are not in the same places where the original surface had them). Please clarify, what do you mean. If you have some samples (input and expected result), that will help us.

@MarcoWang1
Copy link
Author

MarcoWang1 commented Jan 16, 2023

I have a box with 8 vertices,12 triangles ,20mm20mm20mm, offset -1, the result doesnt have sharp edges as the input .like this
797edbe5869f259e3db7ea96a14b19a

@Fedr
Copy link
Contributor

Fedr commented Jan 16, 2023

Thanks, I see, you are interested in negative offset, which shall produce sharp edges. We will try to work on it later this year.

@MarcoWang1
Copy link
Author

MarcoWang1 commented Jan 16, 2023

you use openvdb core library to do offseting which may not keep sharp, but openvdb_houdini has functions to keep sharp,maybe it will help,
https://github.com/AcademySoftwareFoundation/openvdb/blob/master/openvdb/openvdb/tools/VolumeToMesh.h#L279
https://github.com/AcademySoftwareFoundation/openvdb/blob/master/openvdb_houdini/openvdb_houdini/GeometryUtil.cc#L568

I do not understand the code above,if you solve this problem ,please tell me thanks

@Fedr
Copy link
Contributor

Fedr commented Jan 24, 2023

Currently you can highlight sharp edges using post-processing with Decimate tool:
image
Please increase Max Error and decrease Stabilizer for more sharpness.

The result will be as follows:
image

Does it work for you?

@MarcoWang1
Copy link
Author

Decimation tool can sharpen features when Max Error is large enough ,But it will cause large deformation elsewhere, So I do not think it is a perfect solution

@MarcoWang1
Copy link
Author

@Fedr Will you solve this issue recently?I really expect this function。Thank you

@Fedr
Copy link
Contributor

Fedr commented Jan 28, 2023

Yes, we are working on it.

@Fedr
Copy link
Contributor

Fedr commented Feb 1, 2023

Please look at our latest release. It contains Sharpen Features option in Offset and Remesh tools to reproduce sharp edges and corners:
image
Blue - mesh with new option, grey - old offset mesh.

@MarcoWang1
Copy link
Author

If I use the function in MROffset.h ,it still can not keep sharp. So where is the function to offset mesh while keep sharp?

@MarcoWang1
Copy link
Author

image
dog.zip
Here is a bug

@Fedr
Copy link
Contributor

Fedr commented Feb 3, 2023

Thanks for you finding. The problem with Dog mesh is that it contains big self-intersecting areas:
image
And our sharpening method currently requires self-intersection free meshes on input. If this condition is not satisfied, you see the artifacts as on your picture.

We will think how to reduce the amount of damage from self-intersections.

As to single function for sharp offset, yes, it is a good idea and we will create it. Currently one needs to call several functions to get sharpened result: floatGridToVdbVolume, vdbVolumeToMesh, sharpenMarchingCubesMesh.

@Fedr
Copy link
Contributor

Fedr commented Feb 3, 2023

In the master branch of MeshLib, you can find and improvement. Now -1 offset of Dog with sharpening looks as follows:
image

And we introduced simple function for this operation:

// Offsets mesh by converting it to voxels and back
// post process result using reference mesh to sharpen features
[[nodiscard]] MRMESH_API tl::expected<Mesh, std::string> sharpOffsetMesh( const Mesh& mesh, float offset, const SharpOffsetParameters& params = {} );

@MarcoWang1
Copy link
Author

Thanks I ll do more tests recently,and will tell you if I find bugs

@MarcoWang1
Copy link
Author

1-2.zip
微信图片_20230222231603
I do not know how to choose parameters to generate a good mesh that keep sharp

@Fedr
Copy link
Contributor

Fedr commented Feb 22, 2023

I see your point. The best I could do with this input is to reduce voxel size to 0.3 and remove smaller connected components after offset:
image
Resulting mesh:
12offset.zip

The place highlighted on the picture is ragged because probably two surfaces join here at very acute angle. We will investigate and probably add another parameter to control it. Hope to return to you next week with an update.

@Fedr
Copy link
Contributor

Fedr commented Mar 2, 2023

In today release of MeshLib and MeshInspector we introduced several improvements in Offset tool and added one more setting in UI. And now the output looks as follows (with shown parameters):
image
Resulting mesh:
12offsetBetter.zip

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

No branches or pull requests

2 participants