//Example of converting terrainData into a mesh with Edge Fall
bool saveInSubMesh = true;
TerrainToMeshEdgeFall edgeFall = new TerrainToMeshEdgeFall(-20, saveInSubMesh);
Mesh mesh = terrainData.TerrainToMesh().ExportMesh(100, 100, edgeFall);
//If edgeFall is saved as a submesh (saveInSubMesh = true) inside the main mesh,
//then MeshRender have to use 2 materials, one for the main mesh and another for the edgeFall.
normalReconstruction - For generated mesh normals can be read directly from the TerrainData or the can be calculated from the generated mesh. In this case normals will be much smoother, but some terrain details may be lost.
Mesh[] ExportMesh(int vertexCountHorizontal, int vertexCountVertical, int splitCountHorizontal, int splitCountVertical, bool perChunkUV, TerrainToMeshEdgeFall edgeFall = null, TerrainToMeshEnum.Normal normalReconstruction = TerrainToMeshEnum.Normal.CalculateFromMesh)
Splits generated terrain mesh into multi-chunk 2D grid.
//Example of converting terrainData into a multi-chunk 2D grid (16x16) meshes array,
//with vertex resolution 100x100 for each mesh there.
bool calculateUVsPerChunck = true;
Mesh[] meshes = terrainData.TerrainToMesh().ExportMesh(100, 100, 16, 16, calculateUVsPerChunck);
If perChunkUV property is enabled, each mesh inside 2D grid array has normalized UVs in the range of [0, 1]. This is necessary if for each mesh rendering will be used separate material with its own Basemap textures:
Mesh ExportMesh(int vertexCountHorizontal, int vertexCountVertical, int splitCountHorizontal, int splitCountVertical, int splitColumnIndex, int splitRowIndex, bool perChunkUV, TerrainToMeshEdgeFall edgeFall = null, TerrainToMeshEnum.Normal normalReconstruction = TerrainToMeshEnum.Normal.CalculateFromMesh)
Splits generated terrain mesh into multi-chunk 2D grid and exports one mesh with index of splitColumnIndex and splitRowIndex.
//Example of generating mesh (with vertices 100x100) from multi-chunk 2D grid (of size of 16x16) at position [4, 7]
bool calculateUVsPerChunck = true;
Mesh mesh = terrainData.TerrainToMesh().ExportMesh(100, 100, 16, 16, 4, 7, calculateUVsPerChunck);