A simple cross-platform ray tracing engine for 3D graphics rendering.
the cube room (reflection version)
A real life application for office rendering
A real life application for office rendering (top view)
The following build script or projects are available from this respositry.
Platform | Folder | Build tool |
---|---|---|
macOS | build/mac | GNU make |
macOS | projects/raygen.xcodeproj | Xcode |
linux | build/linux | GNU make |
Windows | projects/raygen-win32/raygen.sln | Visual Studio |
Example to use GNU make on linux and macOS platform:
cd build/<platform>
make
$ ./raygen <command> <sceneFile.json> [output_image] [-options]
e.g.:
$ ./raygen render ../../resources/scenes/cubeRoom/cubeRoom.json -s 100
option | description |
---|---|
-r, --resolution | resolution of the result image |
-s, --samples | number of samples (rays from camera) |
-c, --cores, --threads | number of the threads to render parallelly |
-ds, --dofs, --dof-samples | number of samples used on the depth of field calculation |
-enaa, --enable-antialias | enable ray-sample-based antialias (default: on) |
-encs, --enable-color-sampling | enable sample colors from texture (default: on) |
-enpp, --enable-postprocess | enable post-processes (bloom and gamma correction) |
-d, --shader | shading system (see below) |
--focus-obj | automatically make camera look at a specified object (by name) |
--dump | dump scene define |
Shading system: (specified by -d or --shader argument)
value | name | desc. |
---|---|---|
0 | Simple Shading | the simplest and fastest shading using Lambertian reflectance (no lighting and texture sample) |
1 | Ambient Occlusion | Only render the ambient occlusion |
2 | Lambert Shading | Lambert shading with directional lighting and texture sample |
3 | Lambert Shading + AO | Lambert shading with directional lighting, texture sample and ambient occlusion |
4 | (Reserved) | |
5 | BSDF | BSDF Shading with global illumination (the default shading system) |
Shading system comparison:
value | name | D. lighting | Ind. lighting | AO | GI. | Transparency | Reflection and Refraction |
---|---|---|---|---|---|---|---|
0 | Simple Shading | No | No | No | No | No | No |
1 | Ambient Occlusion | No | No | Yes | No | No | No |
2 | Lambert Shading | Yes | No | No | No | Yes | No |
3 | Lambert Shading + AO | Yes | No | Yes | No | Yes | No |
4 | (Reserved) | ||||||
5 | BSDF | Yes | Yes | Yes | Yes | Yes | Yes |
Raygen scene is described by a JSON file using the following structure.
scene.json:
{
obj1: {
location: [x, y, z],
angle: [x, y, z],
scale: [x, y, z],
mesh: "path/to/mesh.mesh",
mat: {
color: [r, g, b] or "#d0d0d0",
tex: "path/to/texture.png",
glossy: 0 ~ 1,
roughness: 0 ~ 1,
transparency: 0 ~ 1,
refraction: 0 ~ 1,
...,
}
},
obj2: {
...
},
...
}
The several samples for rendering scene can be found inside resources/scenes
folder as following:
- Cube Room - A well-known two cubes scene that is usually used to benchmark a ray-tracing engine
- Sphere Array - A scene which has five spheres to demo the different materials
- suzanne - A model suzanne used to demo the transparency and refraction materials
The following modules are required to build this software. They can be found inside /inc
folder as git submodules.
- C++ Common Module (https://github.com/jingwood/cpp-common-class)
- C++ Graphics Module (https://github.com/jingwood/cpp-graphics-module)
Released under MIT License.
Copyright © Jingwood, unvell.com, all Rights Reserved.