An experimental CPU based rasterizer, which contains basic features and is inspired by OpenGL.
Below is a list of the different features available in this project :
Given a list of 3 points in Normalized Device Coordinates (NDC) space, the standard transformation pipeline (model, view, projection, viewport) is applied and the triangle is rendered in screen space while being filled with its color.
A simple camera can be used to view the scene, its position and center can be changed, as well as its FOV and near/far clip planes. The corresponding view and projection matrices based on these values are forwarded to the renderer.
The colors between the points are linearly interpolated inside of the triangle, thus resulting in a blend between the colors.
Textures can be loaded from a file (either PNG or JPG) and applied to any triangle by using texture coordinates. The texture is merged with the interpolated color showed previously.
The depth buffer allows triangles that should be rendered behind other triangles to be partially discarded (on a fragment basis), which allows correct 3D order rendering and overlap.
3D models using the Obj format can be loaded and rendered.
Each object has its own position, rotation and scaling and they can be modified independently.
The support for 8 simultaneous lights is currently in place, each light uses the Phong illumination model (ambiant, diffuse, specular).
The lights also support attenuation (linear, quadratic and radius).
Each object can have its own material, which is used to impact how light reflects off of it.
Blending makes use of the alpha component, it can blend multiple colors together, allowing for transprency.
I used the same operations and equations as OpenGL for this, at least what this page says about it.
Also most of them aren't tested, since the only one that's really useful is srcAlpha, 1-srcAlpha, Add.
A very basic stencil buffer was implemented, it supports writing to the buffer when the color buffer is written to, and discarding fragments based on the value of the buffer.
It's currently used to create a simple outline effect on the models.
Perspective correction is implemented in the renderer, allowing for correct texture and color interpolation.
Back face culling is technically implemented, however it doesn't fully work properly (it discards faces that it shouldn't)
SudoMaths is a 3D oriented Maths library that I made myself, currently used to handle all the Vector/Matrix maths.
Glad is a C binding for the OpenGL APi, I use it in conjuction with ImGui to render.
Glfw is an API used to handle native Windows.
ImGui is a graphical user interface library, I use it for the UI parts of the application.
Stb image is image loading library, currently used to load the textures.
Stb image is a 3D model loader library, currently used to load the obj models.
Here's a few of the resources and documentations I used for this project :