[SOLVED]Procedural generated side by side cubes without 'seams'?

(SOLUTION IS AT BOTTOM!)

I apologize if this has been answered somewhere else, but I have been searching for a few days now and can’t seem to find an answer to my problem. Here is my code and a picture of the results, and at the bottom I outline my issue I am trying to solve/wanting to achieve.

I am procedurally generating cubes with the code below:

private GameObject CreateBoxes(Vector3 startPos)
	{
		Mesh myMesh = new Mesh();

		Vector3 topLeftFront = startPos;
		Vector3 topRightFront = new Vector3(startPos.x+1, startPos.y, startPos.z);
		Vector3 bottomLeftFront = new Vector3(startPos.x, startPos.y+1, startPos.z);
		Vector3 bottomRightFront = new Vector3(startPos.x+1, startPos.y+1, startPos.z);	
		
		Vector3 topLeftBack = new Vector3(startPos.x, startPos.y, startPos.z+1);
		Vector3 topRightBack = new Vector3(startPos.x+1, startPos.y, startPos.z+1);
		Vector3 bottomLeftBack = new Vector3(startPos.x, startPos.y+1, startPos.z+1);
		Vector3 bottomRightBack = new Vector3(startPos.x+1, startPos.y+1, startPos.z+1);
		
		//Assigning vertices to the mesh
		Vector3[] verts = new Vector3[8] {topLeftFront, topRightFront, topLeftBack, topRightBack,
							bottomLeftFront, bottomRightFront, bottomLeftBack, bottomRightBack};
		myMesh.vertices = verts;
		
		//Assigning UV coordinates (Texture coordinates)
		myMesh.uv = tempChunk.Uvs;
		
		//Assigning triangles for faces from chunk tri array
		myMesh.triangles = tempChunk.Tris;
		
		//Calculating normals, adding Mesh to object, adding texture to mesh, and collider
		myMesh.RecalculateNormals();
		
		GameObject myBox = new GameObject("Block");
		myBox.tag = "Block";
		myBox.AddComponent("MeshFilter");
		myBox.AddComponent("MeshRenderer");
		myBox.GetComponent<MeshFilter>().mesh = myMesh;
		myBox.AddComponent("MeshCollider");
		myBox.renderer.sharedMaterial = new Material(Shader.Find("Diffuse"));
		return myBox;
	}

For the Triangles and UV’s, it is here:

private int[] tris = new int[36] {5, 1, 0, 0, 4, 5, 
								      6, 4, 0, 0, 2, 6,
								      7, 5, 4, 4, 6, 7,
								      5, 7, 3, 3, 1, 5,
								      3, 7, 6, 6, 2, 3,
								      3, 2, 0, 0, 1, 3};
	
	private Vector2[] uvs = new Vector2[8] 
						   {new Vector2( 0, 0 ),
							new Vector2( 1, 0 ),
						    new Vector2( 1, 1 ),
    						new Vector2( 0, 1 ),
    						new Vector2( 0, 0 ),
							new Vector2( 1, 0 ),
						    new Vector2( 1, 1 ),
    						new Vector2( 0, 1 )};

Using a for loop with proper increments, I am resulting in this cube generation (Which is exactly what I want):

alt text

THE PROBLEM: I want to have the cubes instead of looking like seperate cubic objects, look like a smooth singular surface (even though they are still seperate.) I have tried sharing normals among some vertices, and sharing vertices alone, but nothing I do seems to work, they always have that cubic ‘outline’ on them with seams.

If anyone could shed some light on this for me, I’d greatly appreciate it. Thanks in advance, guys!

THE SOLUTION: Taking the knowledge from Loius, and Fattie’s great advice and question/answer link in the comments, I stopped trying to fiddle with an 8 vertex cube and instead went to my original 24 vertex per cube setup. The cubes side by side this way appeared seamless and lit correctly.

What I took from it is, don’t share vertices between faces on a shape. It seems like it gave me nothing but trouble. I hope this helps someone in the future who might have the same issue!

Never share vertices when weaving mesh

articles on this

http://answers.unity3d.com/questions/417483/is-there-a-way-to-assign-meshverticesi-directly.html

Not 100 percent sure of this because i solved it a while back, i’m pretty sure however:

If you send mesh objects with different positions to the graphics card, unity’s precision is not high enough and the actual vertex positions in the graphics cards, the seams, will not be the same. hence you will see seams inside the graphics card.

If you put all your cubes on 0,0,0 and instead change their vertex positions to the positions you want, and send them all to the graphics card, they will not contain seams.

AFAIK i solved the issue after some time and puzzling, perhaps waster 50 hours to solve it, becaues i was told that my problem was inside the game engine not the graphics card.

So… keep all cubes on zero zero zero, edit their vertex positions, rewrite all the vertices to the new positions you want the cubes to be in, there should be no mesh, please confirm, ive done it with terrain and the seams completely vanished.

Its a weird error inside Unity that no one else than me knows about because i am a lame coder who never managed to code a game but i know so much about everything.