-
Notifications
You must be signed in to change notification settings - Fork 0
Pipeline Overview
1. We receive obj file with vertices, faces and normals 2. We populate a MeshModel object, specifically, for each face, we populate a Face Struct. struct Face{ Vertex vertices[3]; Eigen::Vector3f FaceNormal; } With: struct Vertex {
Eigen::Vector3f PositionInLocaldSpace; // 3D position of the vertex
Eigen::Vector3f NormalInLocalSpace; // Normal vector for the vertex
Eigen::Vector4f VertexColor; // RGBA color of the vertex
Eigen::Vector4f PositionInViewSpace; // Transformed position in view space
Eigen::Vector4f NormalInViewSpace; // Transformed normal in view space
Eigen::Vector3f PositionInScreenSpace;
Eigen::Vector3f NormalInScreenSpace; // actually the position of the edge
// Default constructor
Vertex() = default;
// Parameterized constructor for easy initialization
Vertex(const Eigen::Vector3f& position, const Eigen::Vector3f& normal, const Eigen::Vector4f& color)
: VertexPosition(position), VertexNormal(normal), VertexColor(color) {}
};
3. Start Face Filtering, first we do back-face culling, and (possible clipping): vector cullBackFaces(vector faces, vec3 cameraDir?) Now we have a primitive (3D triangle that is inside the viewing volume, and we know its pixel-space coordinates). 4. Rasterization - "breaking" the primitive to fragments - a list of pixels inside the triangle that we need to draw. This can be done using Edge functions.
For each Fragment: 5. update Z-buffer if needed.
6. Depth-testing: we use the Z-buffer to test whether this fragment (of this primitive) should be colored.
7. Fragment Shader: Compute fragment color. This needs to be done in three ways: flat, Gourard, and Phong. Also send object color based on different ways - uniform / non-uniform, etc. Also deal with different light sources.