计算法线时纹理模糊
我正在计算使用行进立方体算法生成的网格的法线,但是当我运行它时,对象看起来像图片中一样模糊。
变量: CurrentTri 是一个 Vector3int,包含每个顶点的索引 CurrentNorm 是具有当前法线的 Vector3 Verts 是顶点位置的 Vector3 数组 VertNorm 是顶点法线的 Vector3 数组
我计算法线的 C# 代码:
// Repeated for each triangle
CurrentNorm = Vector3.Cross(Verts[CurrentTri.y] - Verts[CurrentTri.x], Verts[CurrentTri.z] - Verts[CurrentTri.x]);
VertNorm[CurrentTri.x] += CurrentNorm;
VertNorm[CurrentTri.y] += CurrentNorm;
VertNorm[CurrentTri.z] += CurrentNorm;
标准化法线:
for(int i = 0; i < VertNorm.Length; i++)
{
VertNorm[i] = VertNorm[i].normalized;
}
mesh.normals = VertNorm;
I'm calculating the normals of a mesh that I've generated using the marching cubes algorithm but when I run it the object looks blurry like in the picture.
Variables:
CurrentTri is a Vector3int with the indexes of each vertex
CurrentNorm is a Vector3 with the current normal
Verts is a Vector3 array of the positions of the vertices
VertNorm is a Vector3 array of the normals of the vertices
The c# code where I calculate the normals:
// Repeated for each triangle
CurrentNorm = Vector3.Cross(Verts[CurrentTri.y] - Verts[CurrentTri.x], Verts[CurrentTri.z] - Verts[CurrentTri.x]);
VertNorm[CurrentTri.x] += CurrentNorm;
VertNorm[CurrentTri.y] += CurrentNorm;
VertNorm[CurrentTri.z] += CurrentNorm;
Normalising the normals:
for(int i = 0; i < VertNorm.Length; i++)
{
VertNorm[i] = VertNorm[i].normalized;
}
mesh.normals = VertNorm;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应该这样(我认为)。我是个白痴。
It's supposed to be like that (I think). I was a complete idiot.