# Voxels engine chunk mesh max vertices problem

Hey all,

I’m currently working on a voxel engine like minecraft in Unity.
Right now i have a chunk that contains creates a mesh based on the cubes inside.
The problem is that a mesh cannot contain more than 65000 vertices, this disallows the chunk to have more than somewhere like 12x12x12 cubes.

My question is if there is a way around this or if I have to take a different approach than having the entire chunk be one mesh (Mobs etc. will not be included in the chunk mesh, it’s just the cubes.).

The mesh creating part of the chunk looks as follows:

///
/// Creates the mesh.
///
public void CreateMesh()
{
int x;
int y;
int z;

for (x = 0; x < CHUNK_SIZE; ++x)
{
for (y = 0; y < CHUNK_SIZE; ++y)
{
for (z = 0; z < CHUNK_SIZE; ++z)
{
// If the block is inactive it should not be drawn.
if (blocks[x,y,z].IsActive == false)
{
continue;
}

CreateCube(x, y, z);
}
}
}

mesh.vertices = positions.ToArray();
mesh.triangles = indices.ToArray();
mesh.uv = uvs.ToArray();
mesh.RecalculateNormals();

Color[] colors = new Color[mesh.vertexCount];
for (int i = 0; i < colors.Length; i++)
{
colors *= new Color(1.0f, 1.0f, 1.0f);*
•   	}*

mesh.colors = colors;

•   }*

•   ///*

•   ///*

•   public void UpdateMesh()*

•   {*

•   	mesh.Clear();*

•   	CreateMesh();*

•   }*

•   ///*

•   /// Creates a cube.*

•   ///*

•   /// <param>*

•   /// X.*

•   ///*

•   /// <param>*

•   /// Y.*

•   ///*

•   /// <param>*

•   /// Z.*

•   ///*

•   public void CreateCube(int x, int y, int z)*

•   {*

x = (x * BLOCK_RENDER_SIZE) + chunkX * CHUNK_RENDER_SIZE;
y = (y * BLOCK_RENDER_SIZE) + chunkY * CHUNK_RENDER_SIZE;
z = (z * BLOCK_RENDER_SIZE) + chunkZ * CHUNK_RENDER_SIZE;

•   	Vector3 p1 = new Vector3(x - (BLOCK_RENDER_SIZE / 2), y - (BLOCK_RENDER_SIZE / 2), z + (BLOCK_RENDER_SIZE / 2));*

•   	Vector3 p2 = new Vector3(x + (BLOCK_RENDER_SIZE / 2), y - (BLOCK_RENDER_SIZE / 2), z + (BLOCK_RENDER_SIZE / 2));*

•   	Vector3 p3 = new Vector3(x + (BLOCK_RENDER_SIZE / 2), y + (BLOCK_RENDER_SIZE / 2), z + (BLOCK_RENDER_SIZE / 2));*

•   	Vector3 p4 = new Vector3(x - (BLOCK_RENDER_SIZE / 2), y + (BLOCK_RENDER_SIZE / 2), z + (BLOCK_RENDER_SIZE / 2));*

•   	Vector3 p5 = new Vector3(x + (BLOCK_RENDER_SIZE / 2), y - (BLOCK_RENDER_SIZE / 2), z - (BLOCK_RENDER_SIZE / 2));*

•   	Vector3 p6 = new Vector3(x - (BLOCK_RENDER_SIZE / 2), y - (BLOCK_RENDER_SIZE / 2), z - (BLOCK_RENDER_SIZE / 2));*

•   	Vector3 p7 = new Vector3(x - (BLOCK_RENDER_SIZE / 2), y + (BLOCK_RENDER_SIZE / 2), z - (BLOCK_RENDER_SIZE / 2));*

•   	Vector3 p8 = new Vector3(x + (BLOCK_RENDER_SIZE / 2), y + (BLOCK_RENDER_SIZE / 2), z - (BLOCK_RENDER_SIZE / 2));*

•   	int v1;*

•   	int v2;*

•   	int v3;*

•   	int v4;*

•   	int v5;*

•   	int v6;*

•   	int v7;*

•   	int v8;*

•   	// Front.*

•   	// Back.*

•   	// Right.*

•   	// Left.*

•   	// Top.*

•   	// Bottom.*