My mesh is spagetti??!

Hey! So I decided to calculate noise on a compute shader for my infinite terrain. My issue is when I get the data the mesh I get in return is spaggetti. Like they arent connecting to the correct vertices. What I do is give the shader the vertices and it returns the vertices with the height data. I know that it wont return the vertices in order so I made a triangle struct to make sure they return correctly but it doesn’t seem to work. Is there something I’m missing that I need to take in to account while working with compute shaders? Thanks

Unity can change the order of the vertices when importing. You might be able to fix that by turning off optimize mesh.
Another option is to generate the mesh yourself. That way you will know for sure the order of the vertices.