Skip to content

oph-design/miniRT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

237 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

miniRT

This project is about implementing a basic Raytracer for ecole 42 by students luntiet- and oheinzel

How to use

  1. You have to download and install the glfw libary.
  2. clone the repo and build miniRT
git clone https://github.com/oph-design/miniRT.git
cd miniRT
make
  1. run the program with the given scenes for example:
./miniRT  scenes/default.rt

You can also create your own .rt files.

Example pictures

Snowman.rt Screenshot 2023-05-23 at 10 58 24 turtle.rt Screenshot 2023-05-23 at 11 01 04 multi_color.rt Screenshot 2023-05-23 at 11 01 46 morphed.rt Screenshot 2023-05-23 at 11 03 47 cyandsp.rt Screenshot 2023-05-23 at 11 04 31

Controls

You can move the Camera, zoom and even move the light source. But keep in mind its rerendering with every movment and is therfore not fluent, depending on the complexity and size of the scene.

ESC - Closes the Window.
W A S D - for Camera movment.
Q E - for Camera zoom.

For the light sources you first have to select the source you want to move, ranging from 1 to 0 on the Keyboard.
Holding that key, you can move with the Arrow keys on the x and y dimension.
For the z dimension u use J and K.

How to create your own scene

We will explain it on an example file from our scenes.

A	0.1                                             255,255,255
C	0,0,0		0,0,1		90
L	5,5,0		    	        0.7             255,255,255

sp	1,1,6			        2               255,0,0
sp	0,0,20                          20              255,0,225
pl	30,0,10		1,0,0.1				230,230,250
pl	-30,0,10	-1,0,0.1			230,230,250
pl	0,0,50		0,0,1				230,230,250
pl	0,-15,0		0,1,0				230,230,250
pl	0,20,0		0,1,0				230,230,250

First we need to set the camera, light and ambilight. Otherwise the scene will not be accepted.

Ambilight

A	0.1                                             255,255,255

A is the identifier.

Capital letter identifiers can only be defined once.
If you try to set 2 Ambilights, it wont accept the scene.

0.1 is the intensety of the ambilight, which can be set in a range from 0 to 1.
All values above 0 will keep nothing in the dark and setting it to 1 means no shadows at all.
255,255,255 is the Color of the ambilight in RGB values from 0 to 255.

Camera

C	0,0,0		0,0,1		90

C is the identifier.

0,0,0 is the positon of the camera as a vector of x,y,z.
0,0,1 is the orientation vector of the camera. In other words, the directon you are looking at in the 3D space.

All values for the orientation, have to be in the range of 0 to 1.

And the last number, represents the FOV of the Camera in a range form 0 to 180.

Light source

L	5,5,0		    	        0.7             255,255,255

L is the identifier.

This is the only Captial letter identifer, that can be declared multiple times.

5,5,0 gives the position of the lightsource as a vector of x,y,z.
0.7 is the light intensety in a range from 0 to 1.
255,255,255 is again the Color of the light.

Objects

Now a list of Objects you can add to your scene.

Sphere

sp	0,0,20                          20              255,0,225

sp is the identifier.

First comes the position 0,0,20, which is the centerpoint of the sphere.
Second value 20 is the diameter of the sphere, which can not be less then 0.
Last is the Color of the object. Same as for light and ambilight.

Plane

pl	0,0,50		0,0,1				230,230,250

pl is the identifier.

The planes are infinite. So the are descriped with a single point on the plan, here it is 0,0,50, and the orientation from that point to 0,0,1.
In the example its a plane standing upwards on the z coordinate.
And last value is the Color of the object.

Cylinder

cy	0,0,40		0,1,0	6		40			50,40,20

cy is the identifier.

For cylinder we have the center point with 0,0,40.
Then we have the orientation of the middle axis 0,0,1.
After that we have the diameter and the height of the cylinder 6 and 40.
And at the end the color with 50,40,20.

Cone

cn	5,0,40		0,1,-1	6		10			255,255,0

cn it the identifier.

Cones are almost identical to Cylinders.
The only difference is that the first coordinates now describe the bottom of the Cone and not the center.

About

Raytracer from ecole 42 by students luntiet- and oheinzel

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors