This project has been created as part of the 42 curriculum by mathboye and zalemu
The project uses c programming language to make a minimal raytracer.
It is possible to render simple to complex scenes by using a sphere,
cylinder and plane.
The project uses one ambient light source, one spot light source and one
camera to render a scene.
- On terminal type
make. - To clean temporary object files, type
make clean. - Then run miniRT with the desired scene file.
Eg:
./miniRT scenes/simple_2.rt - You can close the render window either by hitting
ESCor clicking on the cross
The project is built on extensive information provided by the book The Ray Tracer Challenge by Jamis Buck and the website ScratchPixel
Some scene files were references from https://github.com/0xEDU/minirt/tree/main/scenes
Coordinate system attached to a single object where geometry is represented in its simplest form.
For example, a sphere is defined as a unit sphere: center(0, 0, 0), radius 1.
Representing objects this way makes math calculations easier. And we use transformation matrices to place objects in the scene (world space). Defining every object directly in world space would require redoing intersection math for every position, orientation and scale. Using object space to represent out objects helps avoid that.
A shared, global coordinate system where all objects, camera and lights exist.
For this project we handle three shapes: sphere, cylinder and plane. The shapes have common attributes like id, type, transformation matrices and material.
Material color is set based on input.
We use a unit radius sphere at location (0, 0, 0) for x, y and z
coordinates respectively.
The spheres' transformation matrices are set based on location and diameter inputs.
We use a unit radius sphere cylinder at location (0, 0, 0) with infinite
height and normal in the positive y direction . Its transformation
matrices for location, diameter and height are then set based on inputs.
We use a plane at location (0, 0, 0) with infinite width and height with
normal in the positive y direction. Its transformation for location and
rotation are then set based on inputs.
This project uses the phong reflection model to shade shapes. It uses three types of lightings to model a surface reflection model.
- Ambient reflection simulates light coming from all directions. It colors all points on a surface equally.
- Diffuse reflection depends on the angle between light source and surface normal.
- Specular reflection depends on the angle between the reflection vector and camera vector. It is governed by how shiny a surface is.

AI was used:
- To populate test cases based on a prototype rather than typing each one by hand, saving time.
- To give detail math formula explanations with examples.
