Is it possible to customize the max size of an ArrayMesh?

Godot Version

4.2.2

Question

Is it possible to customize the max size of an ArrayMesh? I’m curious because I’m trying to generate a 100x100x100 grid of cubes using a SurfaceTool and then storing each cube in the ArrayMesh and it works until I get to array number 256 then it gets maxed can I remove the cap? or change it to be higher?

The max surface count is capped at 256 which is already a ridiculous high amount.

Each surface is its own draw so at that point you might as well just create a mesh for each cube because you are beyond caring about performance.

So what your saying is that a surface isn’t a mesh in and of itself? but is a draw? Oh whoops.

A surface is not a mesh, it is a part of the mesh triangles assigned to a material slot and each extra material slot causes a draw.

If you just need simple cubes you can create a cube mesh and use that mesh resource on all your mesh instances to share it, then add your unique color material on each cube instance material slot (NOT the mesh surface slot).

I’m making a voxel engine. just using an unoptimised cube mesh will not work.
I have to manually code in the rendering of each and every cube. otherwise it won’t work.

Quick question, how do I tell the SurfaceTool what ArrayMesh surface to add my mesh to?

The SurfaceTool works only on one ArrayMesh and the “edited” surface is the current surface index. So if you already added 2 surfaces at index 0 and 1 you are editing index 2 if you add another surface. If you want to edit index 0 again you can only update existing data with the RenderingServer region update API, but you can not change the size or most of its properties. You need to delete and start over.

So If I have green meshes that I want to be on surface 0, I have to add all of them at once, and if I have white meshes on surface 1 I have to add them all at once next?

Yes, you need to commit each surface data all at once yes.