vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
454 stars 72 forks source link

[Feature Request] Mesh Smoothing #185

Closed dale-personal closed 1 month ago

dale-personal commented 1 year ago

Perhaps this functionality already exists and i wasn't able to find it, but here goes:

Looking for the ability to "smooth" a mesh. Also also referred to as "force shared vertices" or minimize vertices.

Here is a link to the implementation in babylon.js:

https://doc.babylonjs.com/toolsAndResources/utilities/Minimise_Vertices

vpenades commented 1 year ago

To some degree, it's what MeshBuilder does... but you need to have the normals precalculated in advance.

Notice that BabylonJS es a full 3D framework whereas SharpGLTF is just a file format... So I try to avoid responsabilities that exceed importing/exporting glTF models.

Having said that, I did triy to calculate the normals of a meshbuilder that were missing them , but I couldn't complete the task because MeshBuilder also supports morph targets, and calculating normals for mopth targets is exceedingly complex.. so this feature is not available.

My suggestion is to calculate the normals beforehand (it's not too difficult) and then feed them to a MeshBuilder... and at that point, MeshBuilder does the vertex welding.