MiniRT is a lightweight yet capable ray tracer inspired by classic graphics techniques. It explores the fundamentals of rendering, mathematics, and low-level programming by implementing a miniature 3D engine from scratch.
The project includes the core concepts used in real rendering systems: rays, intersections, lighting, shadows, reflections, and color blending.
Here are some images rendered using Minirt:
- Ambient, diffuse, and specular lighting (Phong model)
- Multiple light sources with colors and intensities
- Simple reflections
- Planes
- Spheres
- Cylinders
- Cones
- Triangles
- Cubes
- Pyramids
- Squares
- Anti-aliasing (custom sampling factor)
- Multi-threaded rendering
- Texture mapping
- Bump mapping
- Procedural patterns:
- Checkerboard
- Waves
- Skybox support
MiniRT combines several key disciplines:
- β¨ Computer graphics fundamentals
- π§ Vector mathematics and geometry
- βοΈ C programming and memory management
- π Numerical precision and debugging
- π¨ Scene construction and visualization
MiniRT demonstrates how light interacts with objects in 3D space and how mathematical equations translate into visual output. Although minimal compared to full-scale ray tracers, MiniRT captures the essential mechanisms used to build 3D worlds and provides full control over each step of the rendering pipeline.
This project illustrates how theoretical graphics concepts become a functioning rendering system.
The program reads a .rt file containing:
- A camera definition
- One or more lights
- Basic geometric shapes (sphere, plane, cylinder)
For each pixel:
- A ray is generated from the camera
- The ray is tested against all scene objects
- The closest intersection is selected
- Lighting, shadows, and surface color are computed
- The pixel is displayed through MiniLibX
MiniRT uses MiniLibX, which has different requirements depending on the operating system. Below are the steps for Linux and macOS.
MiniLibX for Linux depends on X11, Xorg extensions, and zlib. Install them with:
sudo apt-get update && sudo apt-get install xorg libxext-dev zlib1g-dev libbsd-devClone the repository, then compile using the Linux flag:
make linuxThis will:
- Build MiniLibX from
minilibx_linux/ - Compile MiniRT with the
LINUX=1flag - Produce the
miniRTexecutable
Run it with:
./miniRT scenes/example.rtFor macOS, MiniLibX uses Cocoa and comes with its own .dylib.
No extra packages are needed.
Simply run:
makeThis will:
- Build the macOS version of MiniLibX from
minilibx_macos/ - Compile the final
miniRTbinary
Run MiniRT:
./miniRT scenes/example.rtStandard cleanup:
make cleanFull cleanup (binary + MLX):
make fcleanLinux-specific cleanup versions are also available:
make clean_linux
make fclean_linuxmake re
make re_linuxMiniRT supports interactive exploration of 3D scenes using the keyboard and mouse. Users can select cameras, lights, objects, and apply transformations or filters in real time.
| Key | Action |
|---|---|
C |
Select the first scene camera |
N |
Select next camera in the scene |
P |
Select previous camera in the scene |
Once a camera is selected, it can be rotated or moved:
Rotation:
| Key | Axis |
|---|---|
1 / 7 |
Rotate around camera's v axis |
2 / 8 |
Rotate around camera's u axis |
3 / 9 |
Rotate around camera's v axis |
4 / 6 |
Rotate around camera's w axis |
Translation:
| Key | Direction |
|---|---|
UP |
Move forward |
DOWN |
Move backward |
LEFT |
Move left |
RIGHT |
Move right |
+ |
Move up |
- |
Move down |
| Key | Action |
|---|---|
L |
Select the scene first light |
N |
Select next light in the scene |
P |
Select previous light in the scene |
Lights can be translated using the same arrow and +/- keys as the camera.
Selecting Objects: Click on objects with the mouse to make them the current active object.
Rotation & Translation: Use the same rotation (1-9) and translation (arrow keys, +/-) controls as the camera.
Special Object Modes:
| Key | Object | Action |
|---|---|---|
O |
Cylinder | Toggle caps (open/closed) |
M |
Sphere | Toggle static / interactive mode, updating texture mapping |
Filters:
| Key | Action |
|---|---|
S |
Toggle sepia filter |
A |
Select anti-aliasing (AA) as active object for adjustments |
Anti-Aliasing (AA): After selecting AA with A:
| Key | Action |
|---|---|
+ |
Increase AA factor |
- |
Decrease AA factor |
The factor is clamped between 1 and MAX_AA_FACTOR.
Changing the factor triggers automatic re-rendering.
- Left click: Select objects in the scene.
- The closest intersection to the camera determines the selected object.
- Parent objects (e.g., squares or triangles that belong to cubes/pyramids) are automatically selected when clicking their subcomponents.
| Key | Action |
|---|---|
ESC |
Exit MiniRT and close the window |
For detailed information on the input files, scene format, and texture configuration, please refer to the man pages included with this project:
minirt(6)- Complete guide to using the minirt program and keyboard/mouse controls.scene(5)- Specification of the scene input file and entity syntax.texture(6)- Detailed explanation of texture types, their fields, and usage examples.
These man pages provide all the necessary information to correctly configure your scenes, textures, and object properties.
Please note that this repository is relatively large. This is due to the inclusion of high-quality texture images, bump maps, and skybox images used for rendering in minirt. These assets are essential for achieving realistic visuals in the rendered scenes.
This project is licensed under the MIT License - see the LICENSE file for details.









