Ar mesh classification feathering mesh edges

image
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.

Unity doesn’t have any easy solution for you to smooth out meshes. What you are seeing here is the per-face classification given to you by the platform.

Have you considered using plane detection instead of meshing for this use case? Plane meshes are simplified by the platform and still contain classification information.

I’m planning to use vision pro to map the real environment in real time and apply materials on top of it.
The plane manager is good at processing boundary parts and is capable of classification, but it does not map as precisely as ar mesh.|

Therefore, when performing mesh classification using ar mesh manager, even if the boundary processing is not clean, there is no choice but to use ar mesh manager.

Is there perhaps a better way to map textures without using these two?
Or should I use Blender to process the boundaries of ar mesh manager??

If you know your boundaries in advance, you could certainly 3d model them in Blender and then load that model into your app. Otherwise it would be your responsibility to implement your own mesh simplification algorithm for this use case.

1 Like

Thank you so much!! I’ll try it!!
It was very helpful