I know this has been asked many times before, and I have read many of the same post, but I have never seen an actual definite answer. Is it possible to bypass / increase the limit of Unity’s meshes , I am making a procedural minecraft clone type game and with a limit of 65000 vertices, each chunk is very limited, Thinking about it this way,
I have an mesh what is made up of all the blocks in the chunk, looking at the vertices of the chunks, one fully rendered block results in 4 * 6 vertices , 4 per face dependant on whether there are any blocks next to it. However say if you were to diagonally align the blocks in the chunk, you would end up with 50 % of all the chunks blocks being rendered, all faces, meaning I am technically limited to : 5416.666666666667 blocks per chunk. Any more than that and it has the " possibility " of giving a " mesh out of bounds " exception. This limitation is well, very bad for people who want to make a minecraft type game because I can only simulate 1/16th of minecrafts terrain height, ofcourse i COULD use higher values but it gives the chance of the terrain being possibly out of range at one point.
This is why I am asking, is there any way possible to change the way unity uses meshes, increasing the vertex limit at all?
If you generate the mesh yourself, you could set the index format to 32 bit… Making the mesh double in size, but allow you to have a gigantic amount of vertices.
Mesh mapMesh = new Mesh();
mapMesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
mapMesh.SetVertices(vertices);
mapMesh.SetTriangles(triangles.ToArray(), 0);
...
I had the same problem and I just solved it today. I will give more details on my problem but its kinda long so feel free to skip to the next paragraph for the solution. I needed to send MRI scans over an encrypted tcp channel to android devices running a unity app, so I made my own mesh data serializer in a new unity project to be used for model prep. It worked great to save the object and I could clear the meshdata after it saved, and rebuild it on the same object, but when I would try to load and build it on a different game object than the one I used to save, It would look like mom’s spaghetti. When I used simple objects like sphere or capsule, it could load on new objects, but not the MRI’s with 2 million + vertices, so I new it had to do with the size and indices. I guess it would roll over and reassign the vertices and faces leading to major mom’s spaghetti. I researched the problem and couldn’t understand how Unity could have such a low mesh size and how was my mesh I wanted to modify and save able to load and display in the first place if that were true? It turns out that the mesh limit comes from a mesh property called indexFormat, which defaults to 16 bit to save space, but can easily be changed to 32 bit to support more vertices. When unity loads models from other file types like obj and fbx, it uses the 16 bit unless there are too many vertices, then it uses 32.
Anyways, the quick fix is to do this on your mesh object which I call mesh:
mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
Just make sure you do it before you write all the mesh data or your model will quickly turn into mom’s spaghetti.
Also, this will not work on all devices. From the Unity docs, “Note that GPU support for 32 bit indices is not guaranteed on all platforms; for example Android devices with Mali-400 GPU do not support them. When using 32 bit indices on such a platform, a warning message will be logged and mesh will not render.” In the case that your program will run on devices with these limitations, I would rather fall back to a highly compressed low poly model in the catch of a try catch to set the indexFormat, but that is your call. The other way would be to break up the meshes as described above, but if the device has these limitations, I would guess it probably wouldn’t handle so many huge meshes. Don’t take my word on the last part though. I’m a mechanical engineer who taught myself software engineering, and that’s just my guess. Maybe it will handle them fine.
You cannot have more than 65,534 vertices in a mesh. If you want more vertices, just make more meshes. There is no real limitation; it’s more optimal this way anyway instead of having huge chunks with millions of vertices (primarily because of culling).
Hey bunny, good to see you are working with your project. (I’m working on mine too.)
Having only X, Z chunks will force you to make a chunk shape to be like a tall stick,
and they’ll only make your world with more draw calls.
Having x,y,z chunks should reduce the draw calls and increase the performance of your world after all!
With x,y,z chunks, your world is really limitless!!