I confirmed that the function was implemented well in vision pro, but there was one problem.
As shown in the photo above, when mesh classification is performed, the boundary is sharp.
I tried to solve the problem by referring to the article above, but I have no idea how to use feathering mesh edges.
public void LaplacianSmoothing(Mesh mesh, int iterations)
{
Vector3[] vertices = mesh.vertices;
Vector3[] smoothedVertices = new Vector3[vertices.Length];
for (int i = 0; i < iterations; i++)
{
for (int j = 0; j < vertices.Length; j++)
{
Vector3 average = Vector3.zero;
int neighborCount = 0;
foreach (int neighbor in mesh.GetTriangles(j))
{
average += vertices[neighbor];
neighborCount++;
}
average /= neighborCount;
smoothedVertices[j] = Vector3.Lerp(vertices[j], average, 0.5f);
}
vertices = smoothedVertices;
}
mesh.vertices = smoothedVertices;
mesh.RecalculateNormals(); // Smooth한 후 normals 재계산
}
I’ve been thinking about code like this, but would it be applicable? I would like to know if there is another way. Thank you.