MiniRT is a ray tracing program developed as a project for the 42 school. It aims to create realistic computer-generated images by simulating the behavior of light rays as they interact with objects in a scene. This project serves as a hands-on exploration of computer graphics principles, including ray tracing algorithms, lighting models, and scene rendering techniques.
MiniRT provides the following features:
-
Scene Rendering: MiniRT can render 3D scenes composed of various geometric objects such as spheres, planes, cylinders, and cones.
-
Camera Control: Users can specify camera parameters including position, orientation, field of view, and aspect ratio to define the viewpoint for rendering.
-
Lighting Models: MiniRT supports different lighting models including ambient, point, and directional lighting, allowing users to control the illumination of the scene.
-
Shading: MiniRT implements shading models such as Phong shading to calculate the color of each pixel in the rendered image based on lighting conditions and surface properties.
-
Shadows: MiniRT simulates shadows cast by objects in the scene, adding realism to the rendered images.
-
Specular Reflection: MiniRT supports specular reflection effects for shiny surfaces.
-
Colored and Multi-Spot Lights: Support for multiple light sources with different colors.
-
Bump Mapping: MiniRT can handle bump map textures for enhanced surface detail.
-
Scene Parsing: Users can define scenes using a simple scene description language.
MiniRT is compatible with:
- MacOS
- Linux
-
Before running MiniRT on Linux, ensure that you have the necessary dependencies installed. You may need to install the following packages:
sudo apt-get update sudo apt-get install build-essential -y sudo apt-get install xorg -y sudo apt-get install libxext-dev -y
-
Clone the repository:
git clone https://github.com/jesuismarie/RayTracer-MiniRT.git
-
Change into the project directory:
cd RayTracer-MiniRT -
Compile the program:
make
-
Run MiniRT with a scene file:
./minirt scenes/scene.rt
-
Clone the repository:
git clone https://github.com/jesuismarie/RayTracer-MiniRT.git
-
Change into the project directory:
cd RayTracer-MiniRT -
Compile the program:
make
-
Run MiniRT with a scene file:
./minirt scenes/scene.rt
MiniRT provides a command-line interface where users can specify scene parameters and rendering options. Here are some example commands:
-
Render a scene with default settings:
./minirt scenes/scene.rt
For more information on available options and scene description syntax, please refer to the project documentation.
To further test the capabilities of MiniRT, you can use the provided scene files in the scenes/ directory. These files contain various scenes with different geometries, lighting setups, and rendering parameters to showcase the capabilities of MiniRT.
Below are example renderings of various scenes:
-
Sphere with Textures:
-
Sphere with Bump Map:
-
Sphere with Textures and Bump Map:
-
Spere with Checkerboard:
Scene description files (.rt) are used to define the parameters of the 3D scenes that MiniRT will render. These files provide a structured way to specify the geometry, lighting, camera, and other properties of the scene. Each type of element can be separated by one or more line break(s). Each type of information from an element can be separated by one or more space(s). Each type of element can be set in any order in the file. Elements which are defined by a capital letter can only be declared once in the scene (except lights).
Defines the ambient lighting in the scene:
-
identifire: A -
ambient lightingratio in range [0.0,1.0]: 0.2 -
R,G,B colorsin range [0-255]: 255, 255, 255A 0.2 255,255,255
Specifies the camera parameters:
-
identifire: C
-
x,y,z coordinatesof the view point: -50.0,0,20 -
3d normalized orientation vector.In range [-1,1] for each x,y,z axis: 0.0,0.0,1.0 -
FOV: Horizontal field of view in degrees in range [0,180]: 70C -50.0,0,20 0,0,1 70
Defines the light sources in the scene:
-
identifire: C -
x,y,z coordinatesof the view point: -40.0,50.0,0.0 -
the light brightnessratio in range [0.0,1.0]: 0.6 -
R,G,B colorsin range [0-255]: 10, 0, 255L -40.0,50.0,0.0 0.6 10,0,255
Defines the objects in the scene:
Sphere
-
identifier: sp -
x,y,z coordinatesof the sphere center: 0.0,0.0,20.6 -
the sphere diameter: 12.6 -
specularity (optional)in range [1-∞]: 50 (default value is 100, if not set) -
R,G,B colorsin range [0-255]: 10, 0, 255sp 0.0,0.0,20.6 12.6 50 10,0,255sp 0.0,0.0,20.6 12.6 10,0,255
Plane
-
identifier: pl -
x,y,z coordinatesof a point in the plane: 0.0,0.0,-10.0 -
3d normalized normal vector.In range [-1,1] for each x,y,z axis: 0.0,1.0,0.0 -
specularity (optional)in range [1-∞]: 50 (default value is 100, if not set) -
R,G,B colorsin range [0-255]: 0,0,225pl 0.0,0.0,-10.0 0.0,1.0,0.0 50 0,0,225pl 0.0,0.0,-10.0 0.0,1.0,0.0 0,0,225
Cylinder
-
identifier: cy -
x,y,z coordinatesof the center of the cylinder: 50.0,0.0,20.6 -
3d normalized vectorof axis of cylinder. In range [-1,1] for each x,y,z axis: 0.0,0.0,1.0 -
the cylinder diameter: 14.2 -
the cylinder height: 21.42 -
specularity (optional)in range [1-∞]: 50 (default value is 100, if not set) -
R,G,B colorsin range [0,255]: 10, 0, 255cy 50.0,0.0,20.6 0.0,0.0,1.0 14.2 21.42 50 10,0,255cy 50.0,0.0,20.6 0.0,0.0,1.0 14.2 21.42 10,0,255
Cone
-
identifier: cy -
x,y,z coordinatesof the center of the cone: 50.0,0.0,20.6 -
3d normalized vectorof axis of cone. In range [-1,1] for each x,y,z axis: 0.0,0.0,1.0 -
the cone diameter: 14.2 -
the cone height: 21.42 -
specularity (optional)in range [1-∞]: 50 (default value is 100, if not set) -
R,G,B colorsin range [0,255]: 10, 0, 255co 50.0,0.0,20.6 0.0,0.0,1.0 14.2 21.42 50 10,0,255co 50.0,0.0,20.6 0.0,0.0,1.0 14.2 21.42 10,0,255
The project structure is as follows:
sources/: Contains the source code files.includes/: Contains the header files.scenes/: Contains example scene files.Makefile: The Makefile for compiling the project.
MiniRT has the following dependencies:
- C compiler (e.g., CC)
- Make
- miniLibX (for window management and image rendering)