miniRT is a small but feature-rich ray tracing engine written in C. It renders realistic 3D scenes by simulating the physics of light — tracing rays from the camera through each pixel and calculating their interactions with objects in the world.
Developed as part of the 42 school curriculum, it focuses on mathematical precision, object transformations, and physically inspired lighting models, including reflections, refractions, shadows, and textures — all built from the ground up using the MiniLibX graphical library.
- Installation
- Running miniRT
- Features Overview
- Rendering Engine
- Antialiasing & Multithreading
- Objects & Geometry
- Materials & Lighting
- Textures & Skyboxes
- File Parsing
- Project Structure
- Gallery
- Author
miniRT depends on:
- MiniLibX (graphics library)
- libft (custom C utility library)
- X11 libraries (
Xext,X11) - zlib
To install dependencies on Linux:
sudo apt-get update
sudo apt-get install build-essential xorg libxext-dev libx11-dev zlib1g-devgit clone --recurse-submodules https://github.com/mdomnik/miniRT.git
cd miniRTIf you see a warning about MiniLibX, run:
git submodule update --init --recursivemakeTo rebuild completely:
make reTo launch a scene:
./miniRT scenes/example.rtor open your own .rt file describing the scene.
Example:
./miniRT scenes/castle.rtExit the window with ESC or by closing the window directly.
| Category | Features |
|---|---|
| Mandatory | Plane, Sphere, Cylinder, Window management, Transforms, Object intersection, Lighting (ambient + diffuse), Shadows |
| Bonus | Phong specular reflection, Color disruption, Colored lights, Multi-light scenes, Cone & Hyperboloid, Bump mapping |
| Extra | Skyboxes, Material system, OBJ import, Multithreading, Pattern textures |
Implements ambient, diffuse, and specular components for realistic shading.
How it works:
-
Each ray intersection computes a surface normal.
-
The color is determined by summing the Phong components:
color = ambient + diffuse + specular -
Shadows are computed via secondary shadow rays.
miniRT supports a full range of analytic primitives and transformations.
- Plane — infinite plane via normal equation
- Sphere — implicit quadratic surface
- Cylinder — bounded and capped version
- Cone, Hyperboloid — second-degree extensions
- Cubes(AABB) — Axis-Aligned Bounding Boxes
Objects can be translated, rotated, and scaled through transformation matrices.
To reduce jagged edges and produce smoother images, miniRT implements supersampling antialiasing. Instead of casting a single ray per pixel, multiple rays are distributed across subpixel offsets and averaged together.
Each pixel is subdivided into a configurable number of samples (e.g. 4×, 8×).
Rays are randomly jittered or evenly distributed within the pixel boundaries.
The resulting colors are averaged to produce the final pixel color.
This approach greatly enhances visual quality, especially around edges, small geometry, and high-contrast regions.
Rendering is fully parallelized to take advantage of multi-core CPUs. The image is divided into tiles or horizontal slices, each processed by a dedicated worker thread.
Linear performance scaling across available cores.
Independent rendering of each region for optimal CPU utilization.
Thread-safe accumulation and synchronization at frame completion.
By combining multithreading with supersampling, miniRT achieves smooth and efficient rendering — even for complex scenes with reflections, refractions, and texture mapping.
Supports multiple colored light sources with adjustable intensity and falloff.
Specular reflection and refraction enhance realism.
Includes:
- Checkers
- Stripes
- Gradient maps
- UV-mapped images (PPM)
Enables realistic world reflections and ambient lighting.
miniRT parses .rt scene description files that define:
- Camera position and orientation
- Light sources
- Object definitions
- Material and texture properties
It also supports .obj model imports for complex meshes.
miniRT/
├── src/
│ ├── lighting/ # Phong, reflection, transparency
│ ├── intersection/ # Geometry intersections
│ ├── matrix/ # 2x2, 3x3, 4x4 operations
│ ├── textures/ # Procedural and PPM textures
│ ├── parse/ # .rt and .obj parsing
│ ├── render/ # Multi-threaded renderer
│ └── view/ # Camera & transformations
├── lib/
│ ├── libft/ # Custom standard library
│ └── minilibx-linux/ # Graphical backend
└── readmeAssets/ # Screenshots and README images
















