This is a 3D graphics engine built entirely from scratch in C++ without using external graphics libraries (like OpenGL or DirectX).
The goal of this project is to learn 3D computer graphics through practical application by implementing everything from rendering pipelines to lighting models manually.
✅ Wireframe Rendering → Real-time rendering of wireframe models with smooth performance.
✅ Flat Shading → Per-triangle lighting calculations with efficient shading.
✅ Gouraud Shading → Per-vertex lighting with color interpolation across triangles for smoother shading.
✅ Phong Shading → Per-vertex lighting with color interpolation across triangles for smoother shading + Specular Refletion.
✅ Multiple Light Source → Multiple Light Source Support, each light can be anywhere, any colored, any intensity.
✅ Deapth Buffer/ Z-Buffer → Accurate hidden surface removal using depth comparisons, ensuring correct visibility of objects.
✅ OBJ File Support → Load and render external .obj 3D models.
✅ Frustum Culling → Optimized rendering by culling triangles outside the camera’s frustum.
✅ Gamma Correction & Color Saturation → Improved color accuracy and visual quality.
✅ Efficient CPU Rendering → Entire rendering pipeline runs on the CPU, with smart optimizations for better performance.
- Efficient Rendering: Renders
.objmodels with thousands of triangles at 100+ FPS even on a low-spec machine. - Optimized Culling & Lighting: FPS boost achieved through culling and optimized shading.
- Scalable Performance: On higher-end CPUs, it will perform significantly faster due to better processing capabilities.
- Vertex Transformation:
- Transforms model vertices using translation, rotation, and scaling matrices.
- Backface Culling:
- Removes triangles facing away from the camera to reduce unnecessary rendering.
- Lighting & Shading:
- Implements Additive and Multiplicative lighting models with adjustable light intensity and position.
- Frustum Culling:
- Eliminates triangles outside the screen frustum to boost performance.
- Color Correction:
- Applies gamma correction, exposure, and saturation for better visuals.
-
Clone the repository:
git clone https://github.com/Anubhav-Mondal/Graphics-Engine.git cd 3d-graphics-engineclone the project then go to the project folder.
-
Make
/buildfolder:mkdir build cd build -
Build the Project:
cmake .. cmake --build . --config Release -
Run the Project:
./Release/engine.exe
The executable will be in
/build/Release.
cmake ..→ Generates the build configuration files using the parent directory's CMakeLists.txt.cmake --build . --config Release→ Compiles the project in Release mode with full optimizations../Release/engine.exe→ Runs the compiled executable.
- CMake 3.10 or higher
- Visual Studio 2022 with the Desktop development with C++ workload (provides MSVC compiler)
- Place Your Model:
- Add your custom 3D model (
.objfile) to themodels/folder.
- Include the Model in Your Code:
-
Open
main.cppand add the following line anywhere before themain()function:Model modelDetail("../models/YourModelName.obj", baseColor, offset);
-
Replace the parameters with your desired values:
-
YourModelName.obj: The name of your model file. -
baseColor: The base color of the model, usingColor(r, g, b)format. -
Example:
Color(255, 255, 255) // White Color(255, 0, 0) // Red
-
offset: The distance from the camera. You’ll need to tweak this value to avoid performance issues.- Guidelines for offset:
-
If all vertices are within the range
[-1, 1], use an offset of around50.0f. -
If the range is larger, increase the offset (e.g.,
1000.0f,2000.0f, etc.) for proper rendering.
-
- Guidelines for offset:
-
Current Controls:
0→ Wireframe (WF)1→ Flat Shading (FS)2→ Gouraud Shading (GS)3→ Phong Shading (Specular + Gouraud)
← (Left Arrow): Switch to the previous rendering mode (cyclic).
Example: GS → FS → WF → Phong ...
→ (Right Arrow): Switch to the next rendering mode (cyclic).
Example: WF → FS → GS → Phong → WF ...
↑ (Up Arrow): Decrease the model offset (model moves closer to the camera).
↓ (Down Arrow): Increase the model offset (model moves further from the camera).
Left Click + Drag Horizontally : Rotate model around Y-axis.
Left Click + Drag Vertically : Rotate model around X-axis.
Left Click + Drag Diagonally : Adds slight Z-axis rotation.
R: Reset all rotations to default position.
esc: Exit the application.
- Name: Anubhav Mondal
- Github: https://github.com/Anubhav-Mondal



