1. 程式人生 > >關於Shader wants normals, but the mesh doesn't have them的問題

關於Shader wants normals, but the mesh doesn't have them的問題

問題很明顯,著色器需要網格mesh的法線值。但是mesh的法線值為空。即mesh.normals是空的陣列。如果mesh是程式碼例項化生成,則需手動給normals填充值:呼叫mesh.RecalculateNormals()就ok啦。此外,官方api的一句話需要注意:After modifying the vertices it is often useful to update the normals to reflect the change