Made normal calculations to work and added diffuse lighting (TODO: get rid of seams)
All checks were successful
Gitea Actions Demo / Scan the project (push) Successful in 51s

This commit is contained in:
2024-01-23 12:22:37 +01:00
parent 8f1fadd473
commit 5de28c7d7c
3 changed files with 56 additions and 12 deletions

View File

@ -30,18 +30,18 @@ namespace Nebulix.Rendering
// normals[j] = Vector3D<float>.Zero;
// }
return;
// return;
for (int i = 0; i < indices.Length; i += 3)
{
Vector3D<float> a = vertices[indices[i] - 1];
Vector3D<float> b = vertices[indices[i + 1] - 1];
Vector3D<float> c = vertices[indices[i + 2] - 1];
Vector3D<float> a = vertices[indices[i]];
Vector3D<float> b = vertices[indices[i + 1]];
Vector3D<float> c = vertices[indices[i + 2]];
Vector3D<float> normal = Vector3D.Cross(b-a, c-a);
normal = Vector3D.Normalize(normal);
normals[indices[i] - 1] = normal;
normals[indices[i + 1] - 1] = normal;
normals[indices[i + 2] - 1] = normal;
normals[indices[i]] = normal;
normals[indices[i + 1]] = normal;
normals[indices[i + 2]] = normal;
}
}