why create dynamic mesh with shadows ?

[18002-qq截图20131116204516.jpg|18002]

When i create mesh and uvmap with script, there is some shadows when playing game.
But if i use a plane and textured it , it works great.

[18004-qq图片20131116205536.jpg|18004]

How can i create mesh with no shadows?

Here is the code blew:

using System;
using System.Collections.Generic;
using UnityEngine;

public enum Blocks : byte
{
    Dirt=0,
    Stone = 1,
    coal_ore = 2,
	iron_ore = 3,
	gold_ore = 4,
    Air = 255
}

public class Main : MonoBehaviour {
		
	public WorldMain worldMain;
	
	public bool isPause = false;
		
	public Texture2D[] worldTextures;
        
	List<Vector3> vectices = new List<Vector3>();
	List<Vector2> uvs = new List<Vector2>();
	List<int> triangles = new List<int>();
	int drawRectIndex = 0;
	
	private Chunk m_chunk;
	
	void Start()
	{		
		worldMain = new WorldMain( this );
		worldMain.init();
		
		System.Random ra = new System.Random();
		
		int areaSize = 32;
				
		for( int i=-areaSize;i<areaSize;i++)
		{
			for( int j=-areaSize;j<areaSize;j++)
			{	
				drawRect( i , 0 , j , (int)ra.Next( 0 , 5 ) );	
			}	
		}
		
		renderDraw();
	}
				
	void drawRect( float x , float y , float z , int blockType )
	{
		vectices.Add( new Vector3( x, y , z ));
		vectices.Add( new Vector3( x, y , z + 1 ));
		vectices.Add( new Vector3( x + 1, y , z ));
		vectices.Add( new Vector3( x + 1, y , z + 1 ));
		
		BlockUVCoordinates blockUV;
		worldMain.m_BlockUVCoordinates.TryGetValue( blockType , out blockUV);
		
		float u = (float)blockUV.data[ (int)BlockFace.Top ].x;
		float v = (float)blockUV.data[ (int)BlockFace.Top ].y;
		float w = (float)blockUV.data[ (int)BlockFace.Top ].width;
		float h = (float)blockUV.data[ (int)BlockFace.Top ].height;
		
		uvs.Add( new Vector2( u, v ));
		uvs.Add( new Vector2( u, v + h ));
		uvs.Add( new Vector2( u + w, v ));
		uvs.Add( new Vector2( u + w, v + h ));
		
		triangles.Add( drawRectIndex + 0 );
		triangles.Add( drawRectIndex + 1 );
		triangles.Add( drawRectIndex + 2 );
		triangles.Add( drawRectIndex + 3 );
		triangles.Add( drawRectIndex + 2 );
		triangles.Add( drawRectIndex + 1 );
		drawRectIndex += 4;
		
	}    	
  
	void renderDraw ()
	{
		GameObject world = GameObject.Find( "world" );
		
		MeshRenderer meshRenderer = (MeshRenderer)world.GetComponent<MeshRenderer>();
		MeshFilter meshFilter = (MeshFilter)world.GetComponent<MeshFilter>();
		MeshCollider meshCollider = (MeshCollider)world.GetComponent<MeshCollider>();
		Mesh mesh = meshFilter.mesh;
		
		meshRenderer.material.mainTexture = worldMain.WorldTextureAtlas;
			
		mesh.vertices = vectices.ToArray();
		mesh.uv = uvs.ToArray();
		mesh.triangles = triangles.ToArray();
		mesh.RecalculateNormals();
		
		meshCollider.sharedMesh = mesh;
	}
}

I’m not sure what exactly you mean, but i guess you mean the black area in the distance?

Well that’s not a shadow. Is it possible that you have anisotropic filtering enabled on your texture? That’s the only thing that come to my mind. Without more information on

  • what shader you use
  • what texture import settings you use
  • how the texture atlas looks like

We can’t say much about that. Does the black area change when you move around or move up?

As far as i can tell your code looks correct. You should play with the settings and see if something changes. btw do you have a pro license? Just asking since “true” shadows are a pro feature.

pps: What’s your target platform (windows/linux/mac/iOS/Android/web/…)?