Dynamic mesh is black except up-close

I’m making a bunch procedural blocks in code ( no, not cloning minecraft just a good practice for learning ) and i’m mapping textures onto the block faces with the uv coordinates provided by texture2D.PackTextures().

the problem is the mesh is completely dark unless I get really up close ( and then the far parts are still completely dark. ) also a lot of seams and lines appear.
The material is using the Diffuse Legacy shader, though I’ve tried just about every shader and it doesn’t work.

If I remove the uv textures, and just put a blank color, the color appears from any distance.

I’ve been looking at this for over 5 hours and I can’t seem to fix it.

what it probably ISN’T:

the uv-coordinates are probably correct because when I go up close, the correct texture colors are all there.

the normals for the mesh are correct. ive both set them manually and used RecalculateNormals() and there is no difference.

there is lightning in the scene and other objects are lit properly.

the triangles all wend Clockwise and display correctly.

The GameObject has a MeshRenderer and a MeshFilter with both the atlas texture and the dynamic mesh supplied.

Some sample code:


uvRect = atlas.GetTexCoords( type );
// Custom class encapsulates an atlas and the uv-rect. returned values are verified correct.

vertexIndex = vertices.Count;

						vertices.Add( new Vector3( x, y+1, z) );
						vertices.Add( new Vector3( x, y+1, z+1 ) );
						vertices.Add( new Vector3( x+1, y+1, z+1 ) );
						vertices.Add( new Vector3( x+1, y+1, z ) );
						
						// triangles
						triangles.Add( vertexIndex );
						triangles.Add( vertexIndex+1);
						triangles.Add( vertexIndex+2 );
						//
						triangles.Add( vertexIndex+2 );
						triangles.Add( vertexIndex+3 );
						triangles.Add( vertexIndex );

						uvs.Add( new Vector2( uvRect.x, uvRect.y ) );
						uvs.Add( new Vector2( uvRect.xMax, uvRect.y ) );
						uvs.Add( new Vector2( uvRect.xMax, uvRect.yMax ) );
						uvs.Add( new Vector2( uvRect.x, uvRect.yMax ) );

Turning mipmaps off on the original textures (surprisingly) solves the far-lightning problem.

All that remains is the ugly-seams problem and some odd color effects at a distance.