Introduction
Features
Rendered Scenes
Dependencies
Installation
Usage
Controls
Scene file format
Assets
This project started out as a team project at 42 Heilbronn Coding School together with nmihaile. While the original subject asks for a simple CPU Raytracer, we wanted to learn more about graphics programming and try to create something more complex with openGL for the GPU.
After concluding the team project, I continued to work on making it more physically accurate using Blender Cycles as a reference, restructure things, add more features and create new scenes. I probably spent the most time on my multiple importance sampling implementation for the HDRi environment maps. It's capable of rendering nice looking scenes, but it's very much a naive and hacky implementation. The same goes for many of the more complex parts of the program, but I'm happy with how it turned out in the end and looking forward to learn more in the future.
- HDRi Enviromnemnt Maps illuminate the scene using multiple importance sampling.
- Material properties (Roughness, Metallic, Base Color) can be values or textures
- Normal Maps
- Point Lights (with radius)
- Primitives: Sphere, Cylinder, Hyperboloid and Plane
- Reflections and Bounce Light (glossy/diffuse bounces)
- AgX color mapping (I created my own 3D LUT using Blender)
- Viewport Shading Modes: Render, Solid and Normal (with Blender-like Gizmo)
- Adaptive renderscale during viewport navigation to ensure smooth FPS
caleidoscope.rt
( hold ↑ to animate )
left is Cycles, right is miniRT
sudo apt update
sudo apt install build-essential libx11-dev libglfw3-dev libglfw3 xorg-dev
sudo pacman -S glfw-x11
sudo pacman -S glfw-wayland
brew install glfw
git clone https://github.com/bewerner/miniRT.git
cd miniRT
make
./miniRT path_to_scene_file.rt
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀Key⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀Description⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ |
---|---|
W, A, S, D | Move around |
E or Space | Move up |
C or Shift | Move down |
Right Mouse Button and drag | Look around |
Scroll Wheel up/down | Increase/decrease movement speed |
M | Toggle mouse input (if there are issues) |
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀Key⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀Description⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ |
---|---|
F | Toggle depth of field |
R | Reset camera view |
Numpad 1, Numpad 3, Numpad 7 | Axial view |
P | Print camera info |
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀Key⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀Description⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ |
---|---|
Tab | Cycle through shading modes (Render, Solid, Normal) |
V | Cycle through color view transforms (AgX, Standard, Raw) |
G | Toggle gizmo in render mode |
I / K | Increase/decrease render scale |
O | Save screenshot |
Esc | Quit |
The .rt
scene file format describes the scene with identifiers followed by their specific parameters.
Parameters and sections marked with *
are optional.
Positions and directions are specified as vec3
. (X/Y/Z values as floats)
Colors are generally specified as u8vec3
(R/G/B values beween 0-255).
Some color parameters can alternatively be mapped to a texture
.
Others are specified as float
or int
.
ID position view-direction field of view (horizontal) f-stop* focus-distance*
C vec3 vec3 float float float
Single color ambient or HDRi environment map
ID strength color
A float u8vec3/filepath_to_environment_map.hdr
ID position power (in watts) color radius*
l vec3 float u8vec3 float
ID max diffuse bounces max glossy bounces max_samples*
R int int int
ID width height
W int int
There are two types of textures: image texture and 3D checkerboard texture.
Images textures are limited to 10 per scene and overall textures are limited to 100 per scene.
Textures are defined with the tex
identifier and can be referenced by their name
in any material
.
ID name type path
tex any_name image filepath_to_image_file
ID name type scale color_1 color_2
tex any_name checker float u8vec3 u8vec3
Materials are defined with the mat
identifier and can be referenced by their name
in any object
.
Materials are limited to 100 per scene.
Transmission is not implemented. It does nothing, but a value has to be provided.
Emission is not really properly implemented but it has an effect.
ID name base color metallic roughness IOR transmission emission_strength emission_color
mat any_name u8vec3/texture u8vec3/texture u8vec3/texture float float float u8vec3
If a primitive has no material, a default material will be used. If a primitive has no color, it's material color will be used. UV-scale takes one float to uniformly scale the UV or a vec2 to scale width and height individually.
ID origin normal color* material* uv-scale*
pl vec3 vec3 u8vec3 material float/vec2
ID origin diameter color* material* uv-scale*
sp vec3 flaot u8vec3 material float/vec2
ID origin orientation diameter height color* material* uv-scale*
cy vec3 vec3 float float u8vec3 material float/vec2
ID origin orientation height a b c shape color* material* uv-scale*
sp vec3 vec3 float float float float float u8vec3 material float/vec2
I also included the Blender Python Script I used to create these scenes in Blender and export them into the .rt file format. It's incomplete though and still requires some manual edits and additions. To use it, change the output_file_path
on top.
from Poly Haven:
- Brown Photostudio 02
- Evening Road 01 (Pure Sky)
- Shanghai Bund
- Sunflowers (Pure Sky)
- Syferfontein 18d Clear
from ambientCG:
from 3D Textures:
from cgbookcase
from Free PBR