Scaling Problem: Generating a Triangle Mesh in a Non-Regular NxN Mesh

Good afternoon, I have a question about triangle mesh rendering. I have a problem with my triangle mesh generation. I am generating a non-regular NxN mesh (when I test with an NxN point cloud, it gives the same result), but the mesh is generated from a point cloud. When the point cloud is not very large, the mesh rendering is very good (First image), as seen in the image. However, when the number of points is extended, the mesh rendering becomes distorted or deformed (Second image). I thought it was a problem with my mesh construction, but I debugged and drew the mesh (Third image), and everything seems to be correctly connected, so I don’t understand how I could fix it to render correctly. If you have any ideas or suggestions to fix this problem, I would greatly appreciate it. Im using gradients for colors.

Observations:

  • For the mesh construction, I use Delaunay triangulation.
  • The rendering code is:
// Create Mesh
Mesh unityMesh = new Mesh();
unityMesh.vertices = vertices.ToArray();
unityMesh.triangles = triangles.ToArray();

if (uvsO)
  unityMesh.colors = colors;

*For calculating the triangles, I am using (although based on the debug, this is not causing the error):

using TriangleNet.Geometry;
using TriangleNet.Meshing;

GameObject meshObject = new GameObject("DelaunayMesh", typeof(MeshFilter), typeof(MeshRenderer));
meshObject.GetComponent<MeshFilter>().mesh = unityMesh;
meshObject.GetComponent<Renderer>().material = meshMaterial;

Sorry for the quality of the images, but as a new user on these forums, I can only upload one image.

I was able to solve it by reading a limit of 65k vertices per mesh as a maximum (Max of Unity). Therefore, I divided the irregular mesh into submeshes of 65k each, which allowed me to render the entire terrain.