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
All checks were successful
Gitea Actions Demo / Scan the project (push) Successful in 51s
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user