Using PyriteCLI to Overcome Unity’s 64k Vertex Limit

1 Sep

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.

  1. Grab the latest PyriteCLI binary, which runs on 64-bit Windows Machines here.
  2. 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.
  3. 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.
  4. 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

Tweet about this on TwitterShare on Google+Share on FacebookShare on RedditEmail this to someoneShare on LinkedInShare on StumbleUpon

2 thoughts on “Using PyriteCLI to Overcome Unity’s 64k Vertex Limit

  1. I downloaded the binary files of PyriteCLI and tried to create tiles/slices. My OBJ file has several texture files. How do I pass the argument to use multiple texture files.

    Here is the exception message:

    ——-
    ハンドルされていない例外:
    System.IO.FileNotFoundException: -u
    場所 System.Drawing.Image.FromFile(String filename, Boolean useEmbeddedColorM
    anagement)
    場所 PyriteLib.Texture..ctor(Obj obj, String texturePath) 場所 C:\Users\keir_
    000\Documents\PyriteCli\PyriteLib\Texture.cs:行 21
    場所 PyriteLib.CubeManager.GenerateCubes(String outputPath, SlicingOptions op
    tions) 場所 C:\Users\keir_000\Documents\PyriteCli\PyriteLib\CubeManager.cs:行 57

    場所 PyriteCli.Program.Main(String[] args)
    ——-

    System.IO.FileNotFoundException: -u at System.Drawing.Image.FromFile(String filename, Boolean useEmbeddedColorM
    anagement)
    at PyriteLib.Texture..ctor(Obj obj, String texturePath)
    at C:\Users\keir_000\Documents\PyriteCli\PyriteLib\Texture.cs:line 21
    PyriteLib.CubeManager.GenerateCubes(String outputPath, SlicingOptions op
    tions) at C:\Users\keir_000\Documents\PyriteCli\PyriteLib\CubeManager.cs:line 57

    at PyriteCli.Program.Main(String[] args)

Leave a Reply

Your email address will not be published. Required fields are marked *