Export Mesh

public Mesh ExportMesh(int vertexCountHorizontal, int vertexCountVertical, TerrainToMeshEdgeFall edgeFall = null, TerrainToMeshEnum.Normal normalReconstruction = TerrainToMeshEnum.Normal.CalculateFromMesh)

Converts TerrainDataarrow-up-right object into a mesh with required vertex count.

//Example of converting terrainData into a mesh with vertex resolution 100x100

Mesh mesh = terrainData.TerrainToMesh().ExportMesh(100, 100);

edgeFall - Adds EdgeFall to the generated mesh:

//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 TerrainDataarrow-up-right or the can be calculated from the generated mesh. In this case normals will be much smoother, but some terrain details may be lost.


Splits generated terrain mesh into multi-chunk 2D grid.

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:

Per chunk UV - False
Per chunk UV - True

Splits generated terrain mesh into multi-chunk 2D grid and exports one mesh with index of splitColumnIndex and splitRowIndex.

Last updated