Skip to content

Two-file implementation of a mini ray tracing engine for rapid prototyping via a C/C++ API

License

Notifications You must be signed in to change notification settings

kvarcg/crayengine_mini

Repository files navigation

Build Status License: MIT

CRay Engine Mini

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.

License

The license is MIT. Any acknowledgments/references are appreciated.

Required files

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.

Supported platforms

The project requires C++14 and has been tested with the following platforms/compilers:

OS Compiler Status
Windows MSVC 2017 and higher Build Status
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.

How to Use the API

View the Scenes document for examples.

Extra Utilities

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.

Screenshots

View the Screenshots document.

References and Helpful Links:

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:

The test models used have been downloaded and/or modified from the following sources:

About

Two-file implementation of a mini ray tracing engine for rapid prototyping via a C/C++ API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published