My meshes arent loading properly.

I have a script that puts meshes onto chunks of blocks, it works perfectly fine until I increase the number
of chunks or the height variation. Then the meshes disappear in lines, turn black, or large chunks of meshes just disappear. I have checked my RAM and it works fine, I have a 2080 ti and ryzen 3700x so my problem isn’t hardware.



edit: I have done some extra testing, and this bug occurs only when the height variation of the terrain is set to a large number, even on smaller scales, I tested it on one chunk and it still did this.

edit: I have added a few videos.

Well we can barely see anything in those images and what the issue actually is. Though if you’re just missing triangles you may have missed to set the indexbuffer format.

By default Unity uses a 16 bit index buffer and in the past this was the only index format it supported. Though you can now set the index buffer to 32 bit. A 16 bit index buffer only supports vertex indices up to 65k (so you can only have 65k vertices). You can have as many triangles you like as long as you don’t have more than 65k vertices. With a 32 bit index buffer you can now address indices up to 2 billion.

Make sure you set the indexFormat before you start filling any mesh data.