
This project was made in collaboration with Cimex. He has uploaded it as his own repository as well!
MiniRT is a basic 3D ray-tracer that uses the MLX42 graphical library (OpenGL windows) to render a scene based off a scene file containing camera, light and object data.
It works by casting a ray for each screen pixel out of the camera and calculating intersections with objects in 3D space. The objects have surface normals that dictate how the ray should behave when bouncing back to the light source. The scene currently can only have one point light and all rays trace back to it. Shadows are calculated in two different ways; shadow rays and ambient occlusion. Shadow rays are generated where the ray hits an object and cannot continue, simulating how the shadow would be cast onto whichever surface it occluded. Ambient occlusion on the other hand is purely proximity-based between two very close objects and simulates how light gets trapped in tight spaces and diffuses into darkness. Both of these shading processes use samples and pseudo-random scatter to simulate diffusion. The higher the samples the less noisy the shadows look in exchange for computation time. Additionally, some extra visual features have been implemented, as well as basic run-time user controls. Memory is handled with a rudimentary garbage collection system and there is a robust logging and error handling system for convenience.
Despite being a project for 42, the latest and all future version will deviate from the norm. If you wish to see a fully norm-compatible version that we submitted, check the commit history for that point in development!
w - move forwards - move backwarda - move leftd - move right↑ - rotate up (until looking straight up)↓ - rotate down (until looking straight down)← and → - rotate left and right respectively (loops back around)+ and - - increase/decrease shadow samples by 16 (from a range of 1 to 112)make QUALITY=LOW or QUALITY=HIGH. If compiled without this flag it will default to standard quality.You can simply compile with make. To clean binaries use make clean or make fclean for a full wipe of the executable. You can also specify the quality as previously described.
To run miniRT on a scene you must use this command:
./miniRT "[scene file / path to scene file]"
The scene file must have the .rt extension and must follow a specific format:
A), a single camera (C) and a single point light (L).intensity from 0 to 1 as a float and color in RGB format as three values from 0 to 255. Color works this way for all assets.position x,y,z rotation x,y,z as values from -1 to 1 and focal length or FOV as a value from 1 to 180.position x,y,z as well as intensity and color in the same format as the ambient light.pl), spheres (sp) and cylinders (cy).position x,y,z rotation x,y,z and color.position like all other objects, no rotation as it has no effect on the a sphere, diameter as a float and color, as per usual.position and rotation in the usual format as well as diameter, height and color.roughness and reflectivity as floats from 0 to 1 in that order. If not added, these parameters will default to some preset values.# to the start of the line.An example scene would look like this:
#AST POSITION ROTATION LUM/FOV RAD HGT COLOR ROUGH REFLECT
A 0.1 240,255,255
C -50,40.5,50 1,-0.25,-1 62
L -5,10,60 0.84 255,196,240
pl 0,-10,0 0,1,0 0,255,0 0 0.4
pl 100,0,0 -1,0,0 255,0,0 0 0
pl 0,0,-100 0,0,1 0,0,255 0 0
sp 0,0,0 20 255,0,255 0.8 0
sp -10,20,0 5 10,20,30 0 0.8
cy 10,40,-30 .5,1,.5 10 20 255,255,0
cy 50.0,7,-8 -1,0,1 20 15.5 0,255,255
sp -5,0,-21 16 255,255,255 0
NOTE: The project depends on my libft utilities library as well as MLX42 for graphics. Both are added as submodules in the repository.

This project has undoubtedly been my favorite from the 42 core curriculum so far. I look forward to adding many advanced features, though no longer strictly following the 42 norm or project rules. Here is a list of the features I would like to add: