Lighting in Managed Direct3d
I am making this small little engine for my needs. I have implanted lighting lights, the lights seem to work 100% sence they where fallowed by the microsoft tutorials. But than I made a cube from triangles. My engine auto calculated the normals of each face like this:
It is a pretty simple function. It takes 4 arguments, the first 3 being the points of the triangle than the fourth being a color. The aproach for finding the normals is what most people use and I belive works correctly but here is my problem:
public static Face ConstructFace(Vector3 vec1, Vector3 vec2, Vector3 vec3, Color color)
ShapeVertex verts = new ShapeVertex;
//Normal is caluclated here
Vector3 v1 = vec2 - vec1;
Vector3 v2 = vec3 - vec1;
Vector3 norm = Vector3.Cross(v1, v2);
verts = new ShapeVertex(vec1.X, vec1.Y, vec1.Z, norm.X, norm.Y, norm.Z, color);
verts = new ShapeVertex(vec2.X, vec2.Y, vec2.Z, norm.X, norm.Y, norm.Z, color);
verts = new ShapeVertex(vec3.X, vec3.Y, vec3.Z, norm.X, norm.Y, norm.Z, color);
return new Face(verts);
The face is lit by the light. But if ANY part of the face (no matter how small or big) is out of the screen, the face becomes unlit and black.
I am using a simple point light that does reach the object fully, it has a large range. I have a big feeling this has nothing to do with my lights or normals at all, but rather somthing else. Anyone know anything on this?