This project has been created as part of the 42 curriculum by sgadinga, zsalih
miniRT is a ray tracing engine built from scratch in C as part of the 42 school curriculum. The goal is to render 3D scenes described in .rt scene files by simulating the physical behavior of light rays — tracing each pixel's ray from the camera into the scene, computing intersections with geometric objects, and applying lighting models to produce a realistic image.
The engine supports a full set of geometric primitives, advanced lighting with the complete Phong reflection model, and several bonus features including cone rendering, checkerboard patterns, multi-spot colored lights, and bump map texture support.
- Linux OS
ccandmake- X11 development libraries (required by MiniLibX)
Install the required dependencies:
sudo apt update
sudo apt install build-essential libx11-dev libxext-dev zlib1g-devRequired for MiniLibX linking: -lXext -lX11 -lm -lz
Clone the repository and compile with:
makeTo clean object files:
make cleanTo fully clean (including the binary):
make fclean./minirt scene/<scene_file>.rtExample:
./minirt scene/15_earth.rtScene files describe the camera, lights, and objects in the scene. They must follow the .rt format defined by the project specification (see Scene Format documentation)
- Support for geometric primitives: sphere, plane, and cylinder
- Accurate ray–object intersections, including correct handling of object interiors
- Object properties:
- Sphere: adjustable diameter
- Cylinder: adjustable diameter and height
- Full geometric transformations:
- Translation and rotation for objects, lights, and camera
- (excluding rotation for spheres and lights, as per subject constraints)
- Lighting system:
- Ambient lighting (ensuring no complete darkness)
- Diffuse lighting
- Hard shadows
- Configurable light intensity (brightness)
- Scene rendering from .rt files following the project specification
- Advanced lighting
- Full Phong reflection model (ambient + diffuse + specular)
- Support for multiple colored light sources
- Texturing
- Checkerboard patterns (procedural textures)
- Bump map textures for surface detail via normal perturbation
- Additional geometry
- Cone support (second-degree primitive beyond mandatory objects)
-
libtensr — custom math and geometry library
Provides vector operations, math utilities, and core structures used in the ray tracing engine. -
libft - foundational utility library
Provides standard C functions and basic utilities used across the project.
Included as part of this repository.
For a deeper understanding of the project architecture and implementation details:
- Architecture Overview
- Rendering Pipeline
- Scene File Format
- Threading Model
- User Interactive Settings
-
Ray Tracing Gems (v1.9) — Haines et al.
Comprehensive reference on ray tracing techniques, intersection math, and lighting models. -
Khan Academy — Linear Algebra
Foundational reference for vectors, dot products, cross products, and matrix transformations — all essential to ray tracing. -
The Cherno — Ray Tracing Series (YouTube)
Step-by-step ray tracing series covering the basics through practical implementation. -
Sebastian Lague — Coding Adventures: Ray Tracing (YouTube)
Visual walkthrough of ray tracing fundamentals with clear explanations. -
LearnOpenGL — Normal Mapping
Reference for understanding and implementing bump map / normal map textures. -
NumPy Reference
NumPy library reference manual, which inspired the design for the libtensr library.