A high-performance, CPU-based 3D rendering engine built entirely from scratch in C++. This project bypasses external graphics APIs (such as OpenGL, Vulkan, or DirectX) to directly implement bare-metal mathematical calculations for recursive global illumination, ray-geometry intersection, and spatial rendering.
Hardware-Level Concurrency (OpenMP) The rendering pipeline is fully multithreaded. By leveraging OpenMP compiler directives, the engine dynamically schedules ray calculations across all available CPU cores. To prevent thread-write collisions during concurrent execution, the engine utilizes a pre-allocated RAM-based vector framebuffer, drastically reducing render times across heavy workloads before performing a single sequential disk write. Spatial Sorting via AABB To optimize rendering dense manufacturing-grade meshes, the engine implements Axis-Aligned Bounding Boxes (AABB). This spatial culling algorithm wraps complex geometries in an invisible mathematical boundary. Rays that fail to intersect the bounding box instantly bypass the internal geometry, reducing computational load by over 99% on standard renders. Mathematical Foundation
- Intersection Math: Implements the Möller–Trumbore intersection algorithm to solve complex multi-variable linear algebra for rapid ray-triangle collision detection.
- Global Illumination: Utilizes a recursive ray-scattering limit to simulate realistic light bouncing, energy absorption, and metallic reflections.
Dynamic Pipeline & Auto-Normalization Built a custom file I/O parser to dynamically ingest standard
.obj3D meshes at runtime. The engine features an autonomous normalization algorithm that calculates the center-of-mass and scales raw vertex coordinates into a unified 1x1x1 mathematical space, eliminating the need for manual file-specific scale adjustments.Prerequisites
- A C++ compiler with C++11 support (e.g., GCC, Clang).
- OpenMP enabled.
Compilation Compile via GCC with maximum hardware optimization (
-O3) and multi-threading flags (-fopenmp) enabled:g++ main.cpp -o raytracer -O3 -fopenmpUsage Run the executable by passing any standard
.objfile as a command-line argument:.\raytracer <path_to_model.obj>The engine will automatically parse, normalize, and render the model, outputting the final image to a local
image.ppmfile.
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
