meritissimo1 / 42-course-miniRT

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MiniRT

This project was developed by me and cadet Marcelo as part of the curriculum of 42 São Paulo, with the main pedagogical focus of implementing a Raytracer, a computer graphics algorithm capable of rendering three-dimensional scenes.

Introduction

Ray tracing is a technique used to render 3D images by calculating the intersection of a ray of light, coming from the viewer's camera, with the objects in the scene. Each ray is fired from the camera, passing through the corresponding pixels in the viewing window, and the color of each pixel is determined by the color of the object intersected by the ray at the point of intersection (or the background color if there is no intersection).

Ray tracing accurately simulates the physical properties of light rays, allowing lights, shadows, and surfaces to be rendered with a reasonable degree of fidelity, even on modest computers.

About the implementation

This algorithm was implemented based on the book "The Ray Tracing Challenge" using the Test Driven Development (TDD) method. The UNITY Test was used as the testing tool. However, it is important to note that some tests suggested by the book became outdated due to school specifications, which required some implementation details not covered in the book. To achieve this goal, the school's 42 graphics library, MiniLibX, was used! This library was developed internally and includes the basic tools needed to open a window, create images, and manipulate keyboard and mouse events.

How to Run

Git clone the project:

git@github.com:leaozim/42-course-miniRT.git

Installing dependencies

Inside the libs directory in the MiniRT folder, you will find the minilibx-linux library. If you are running on Linux, you can execute the command below and it will install its dependencies. If you use MacOS, follow the installation instructions contained in this repository

sudo apt-get update && sudo apt-get install xorg libxext-dev zlib1g-dev

To compile, use make

MiniRT relies on the libft submodule and the MiniLibX library to run. Both are located at the root of the project and will be compiled when running the make command.

cd 42-course-miniRT && make

Run the program

Run MiniRT with an .rt file as an argument. You can use one of the examples located in the scenes folder or write your own .rt file.

./miniRT scenes/bonitao.rt

Create your own RT File

Files with the .rt extension require at least one camera, ambient light, and regular light. The available shapes are planes, cylinders, and spheres. You can configure as many shapes and lights as you want.

Objects Input Example
Camera C [coordinate] [vector] [field of view] C 10,0,0 -1,0,0 90
Light L [coordinate] [brightness] [rgb color] L 0,10,10 0.13 255,255,255
Ambient Light A [brightness] [rgb color] A 0.3 0,255,0
Plane pl [coordinate] [vector] [rgb color] pl 0,0,0 0,1,0 255,0,255
Cylinder cy [coordinate] [vector] [diameter] [height] [color] cy 0,0,0 0,0,1 3 5 145,255,79
Sphere sp [coordinate] [diameter] [rgb color] sp 0,0,0 3 0,0,255

Examples of rendered images






About

License:MIT License


Languages

Language:C 93.3%Language:Roff 4.6%Language:Makefile 1.6%Language:Shell 0.4%Language:Perl 0.1%