unity-game-enginenormals

Blurry Textures when calculating normals


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. Image of a mesh generated using the code

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;

Solution

  • It's supposed to be like that (I think). I was a complete idiot.