This is a mini CPU-based ray tracing engine, consisting of two files and with a minimum of dependencies. It started as a side project to be used for educational purposes that I decided to make public.
The main idea was to be able to quickly render an image through simple API calls for rapid prototyping, that could be easily integrated and exploited through a larger engine. Since other, usually heavy utilities, responsible for image loading, logging, geometry I/O, etc. are either already present as part of larger tools or exist as separate projects (see dependencies of the extra utilities provided below), the provided engine is responsible only for the pure rendering part, i.e. it is agnostic on how images and external models have been loaded.
List of features:
- C/C++ API
- Multithreaded tiled rendering
- BVH for storing the scene primitives
- Two integrators: ambient occlusion and path tracing
- Cameras: perspective, thinlens and orthographic
- Primitives: spheres, rectangles, triangles
- Multiple materials for modelling the typical matte, glass, plastic surfaces, etc (see the list of supported materials here). In more detail:
- Support for diffuse/specular components and smooth/rough reflection/transmission
- Diffuse surfaces are modelled as pure Lambertian and specular using isotropic GGX.
- Light sources: diffuse area lights, point spot/omnilights and directional lights
- Multiple importance sampling
- Basic texturing: box and bilinear filtering
- Support for hierarchical transformations
- Interactive (progressive) rendering, to be integrated in a GUI for navigation
- Internal logger mechanism as well as rendering progress functionality
For more information, the API reference is available in PDF or HTML formats.
The license is MIT. Any acknowledgments/references are appreciated.
The renderer consists of these two files:
Files | Description |
---|---|
CRay.h | Main header API file with C/C++ interface |
CRay.cpp | The API implementation |
These files can be obtained and used by directly downloading the code. The only (not necessarily needed, but extremely convenient) dependency is GLM, included in the 3rdParty folder.
The project requires C++14 and has been tested with the following platforms/compilers:
OS | Compiler | Status |
---|---|---|
Windows | MSVC 2017 and higher | |
Linux | GCC 5.0 and higher | |
Linux | Clang 4.0 and higher | |
macOS | Clang 3.9 and higher |
For more details, see the latest tests on Travis CI. I am not able to get MinGW and 32-bit GCC/Clang to work at the moment on Travis, but compiles fine on my local machines, thus I claim it works :).
The C++ version can be easily downgraded to C++11, by simply including the Compatibility.h that contains the reference implementation for make_unique.
View the Scenes document for examples.
I have created a number of utilities on top of the ray engine, model, texture and external scene loader utilities, a console tool written in C, a Qt GUI application and a testing kit. View the Build document for instructions if you wish to compile and use them.
View the Screenshots document.
Parts of this project have been influenced and in some parts, heavily-based, on the theory, algorithms and available code provided by the books and papers below:
- Advanced global illumination, Dutre, P. et al.
- Physically based rendering: From theory to implementation, Pharr, M. et al.
- Global illumination compendium, Dutré, P.
- Real-Time Rendering, Akenine-Möller, T. et al.
- Microfacet models for refraction through rough surfaces, Walter, B. et al.
The test models used have been downloaded and/or modified from the following sources: