This project has been created as part of the 42 curriculum by qvan-der, mshulgin
miniRT is a minimal ray tracer written in C using the MLX42 graphics library. The goal of this project is to introduce the fundamentals of ray tracing by rendering simple 3D scenes.
The program reads a scene description file (.rt) and generates a computer-rendered image using the ray tracing technique. It supports essential rendering features such as object intersections, ambient and diffuse lighting, and hard shadows.
- Window rendering with MLX42
- Scene parsing from
.rtfiles - Camera with configurable FOV
- Ambient and diffuse lighting
- Hard shadows
- Supported objects
- Sphere
- Plane
- Cylinder
- Cube (bonus)
- Cone (bonus)
- Proper memory management
- Error handling
- Configurable multithreaded rendering (bonus)
- Configurable anti-aliasing (bonus)
- Multiple light sources (bonus)
- Checkboard pattern on objects (bonus)
- Live progress bar and rotating 3D cube during rendering (bonus)
The program reads custom .rt files. Each element is defined on a single line.
To apply the checkerboard pattern to any object, append the ch flag to the end of its definition.
| ID | Origin | Orientation | Intensity | FOV | Diameter/Size | Height | Color | *Optional |
|---|---|---|---|---|---|---|---|---|
| Essentials | ||||||||
| A | 0.2 | 255,255,255 | ||||||
| C | 0,0,-10 | 0,0,1 | 70 | |||||
| L | 0,10,10 | 0.75 | 255,255,255 | |||||
| Objects | ||||||||
| sp | 0,1.25,0 | 2.5 | 129,22,90 | ch | ||||
| pl | 0,0,0 | 0,1,0 | 129,22,255 | ch | ||||
| cy | 1,2,-2 | -0.2,0.3,1 | 3 | 10 | 129,255,90 | ch | ||
| cu | 0,0,0 | 6 | 220,20,20 | ch | ||||
| co | -12,8,-5 | 0.7,-0.7,0 | 6 | 10 | 20,100,255 | ch |
- C compiler (e.g.,
cc) - MLX42 library
- Make
- Math library (
-lm)
~$ makeAvailable Makefile rules:
~$ make # Build the project.
~$ make clean # Remove object files.
~$ make fclean # Remove object files and binary.
~$ make re # Rebuild everything.
~$ make norm # Run norminette without checking the tests etc.Simply run the program with a scene file:
~$ ./miniRT <scene_file.rt>Running the program with additional options:
~$ ./miniRT <scene_file.rt> [options]
Options:
--threads=<threads> # Number of threads to use for rendering (default: 1)
--spp=<samples> # Number of samples per pixel for anti-aliasing (default: 1)
--help # Display this help message
--debug # Enable debug mode (prints additional information during rendering, and allows clicking on objects to print the ray information)ESC: Exit the programWindow close button: Exit the program
AI tools were used for clarifying and debugging, including:
- Brainstorming project structure
- Clarifying mathematical formulas
- Debugging graphics issues
- Creating complex scenes









