A minimal raytracer built in C as part of the 42 school curriculum
miniRT renders 3D scenes defined in .rt files using raytracing techniques. The project implements basic geometric primitives, Phong lighting, and an interactive scene editor.
Mandatory
- Geometric primitives: spheres, planes, cylinders
- Ambient and point lighting
- Camera with configurable FOV
Bonus
- Cones
- Full Phong reflection model with specular highlights
- Bump mapping via XPM textures
- Checkerboard patterns
- Multiple colored light sources
We wanted it
- Real-time scene editing with GUI, keys and mouse
make # Build mandatory version
make bonus # Build bonus version./miniRT scenes/example.rt
./miniRT_bonus scenes/example.rt
./miniRT -h # Display helpor simply
make demo
make demo_bonus(see below the screenshots from the demo scenes)
Scenes are defined in .rt files with the following elements:
| Element | Syntax |
|---|---|
| Ambient | A <ratio> <r,g,b> |
| Camera | C <x,y,z> <dir_x,dir_y,dir_z> <fov> |
| Light | L <x,y,z> <ratio> <r,g,b> |
| Sphere | sp <x,y,z> <diameter> <r,g,b> |
| Plane | pl <x,y,z> <normal_x,y,z> <r,g,b> |
| Cylinder | cy <x,y,z> <axis_x,y,z> <diameter> <height> <r,g,b> |
| Cone | co <x,y,z> <axis_x,y,z> <diameter> <height> <r,g,b> (bonus) |
| Key | Action |
|---|---|
N / P |
Select next/previous object |
I/J/K/L |
Move object (forward/left/back/right) |
U/H |
Move object (up/down) |
↑/↓/←/→ |
Rotate object |
V/B |
Decrease/increase radius |
X/C |
Decrease/increase height |
0-9 |
Quick color presets |
Space |
Snap to grid |
Left click |
Select object |
Right click |
Point camera |
Esc |
Exit (saves to snapshot.rt) |
- MiniLibX (cloned automatically)
- X11 development libraries
# Debian/Ubuntu
sudo apt install libx11-dev libxext-dev- bduval — Github profile
- rarangur — Github profile
42 School Project — 2025
Colored spheres, cylinders and planes. Shadow casting from a single spot light.
The interior of shapes is also calculated. This is the camera and the light inside a cylinder that is inside a blue sphere, with yellow spheres as decoration.
The same three simple shapes aligned to form interesting artistic compositions.
A blue light illuminating a white cylinder and a red sphere. The sphere appears totally dark.

Phong reflections are correctly calculated; note how 3 lights reflect on the cylinder but only 2 on the sphere.

These 5 light sources reflect off the plane and the base of the cylinder, creating an interesting shadow gradient.

This demonstrates how light composition works naturally, with blue, green, and red lights creating white, magenta, cyan, and yellow.

A white sphere with a yellow light on top and a blue light below, with a bump map of the continents of the Earth.

Bump maps and phong effects work correctly with multiple spot lights.

