[Unity]自行创建Mesh无法正确接受DirectionLight的Bug

2019/09 01 17:09
Unity创建Mesh:
 
Mesh mesh = new Mesh ();
mf.mesh = mesh;
mf.normals = new Vector3[]{ new Vector3(0,0,-1), Vector3(0,0,-1), Vector3(0,0,-1), new Vector3(0,0,-1)};
 
表现为, 使用标准的Unity Surface Lambert光照, 无论怎么调节Direction Light 的颜色/强度, 均不受影响
 
最后查出是Normal错误导致,修正后为:
 
new Vector3[]{ new Vector3(0,1,0), new Vector3(0,1,0), new Vector3(0,1,0), new Vector3(0,1,0)};
 
或者, 把 mf.normals 删除; 修正为:mesh.RecalculateNormals(); 也可

--转载请注明: http://blog.coolcoding.cn/?p=203