You have a beautiful landscape mesh you’d like to add into your Unity game, but when you import the mesh file you are presented with an error that you have exceeded the 64k vertex limit.
Unity uses 16bit indexes on mesh data, which creates a boundary around 2^16-1 for mesh vertices.
The first thing you should be asking yourself is whether you really need all these vertices – or if you should be simplifying your model before importing it. But for now, lets assume that you know what you are doing, and you do indeed want this mesh in Unity.
If you can save your mesh in Wavefront OBJ format (*.obj), along with a jpeg texture file – and your mesh is composed entirely of triangular faces – PyriteCLI can process it into smaller chunks that you can import into unity.
Hint: Use Meshlab to open your mesh and save it as OBJ to get a compatible input file.
PyriteCLI is able to slice your mesh into chunks of any size you need, and simultaneously partition the texture into smaller pieces associated with each chunk. It is up to you if you prefer to have all the chunks reference the original texture, or generate new smaller textures.
- Grab the latest PyriteCLI binary, which runs on 64-bit Windows Machines here.
- Decide how to slice your mesh in the X, Y and Z dimensions. For this example lets just cut it into 4 vertical columns with slicing parameters of X=2, Y=2 and Z=1.
- Run PyriteCLI on your data e.g.
PyriteCli.exe -x 2 -y 2 -z 1 -u 2 -v 2 -o --writemtl -t [path to jpg] [output path] [path to obj]or see full usage details.
- You now have four objects, which maintain the world space of the original, and can be imported individually into Unity3D!
Below is a video walkthrough of the process described above