Skip to content

Commit

Permalink
Readme (#132)
Browse files Browse the repository at this point in the history
* save

* update README

* add build emoji

* Update README.md

---------

Co-authored-by: Vincent Fries <91223304+V-Fries@users.noreply.github.com>
  • Loading branch information
tdameros and V-Fries authored Nov 6, 2023
1 parent aa1c513 commit e76f862
Show file tree
Hide file tree
Showing 22 changed files with 237 additions and 44 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,4 @@ decompress:

.PHONY: render
render: all
find assets/scenes -name "*.rt" -exec ./miniRT {} \;
find assets/scenes -name "*.rt" -not -path '*/.*' -exec ./miniRT {} \;
159 changes: 159 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# MiniRT

**MiniRT** is a C-based mini raytracer that utilizes a minimal graphics library.

A raytracer is a computer graphics technique used to create highly realistic images by simulating the behavior of light in a virtual 3D environment. In ray tracing, the fundamental concept revolves around tracing the path of light rays as they interact with objects and surfaces within a scene.


## 📸 Renders
<table align=center>
<thead>
<tr>
<th colspan=2>Some renders</th>
</tr>
</thead>
<tbody>
<tr>
<td><image src="assets/screenshots/suzanne.png"></image></td>
<td><image src="assets/screenshots/lamborghini.png"></image></td>
</tr>
<tr>
<td><image src="assets/screenshots/xwing.png"></image></td>
<td><image src="assets/screenshots/earth.png"></image></td>
</tr>
</tbody>
</table>

<table align=center>
<thead>
<tr>
<th colspan=2>Integrated post-processing effects</th>
</tr>
</thead>
<tbody>
<tr>
<td><image src="assets/screenshots/chess_no_effects.png"></image></td>
<td><image src="assets/screenshots/chess_black_and_white.png"></image></td>
</tr>
<tr>
<td><image src="assets/screenshots/chess_inverse_color.png"></image></td>
<td><image src="assets/screenshots/chess_inverse_black_and_white.png"></image></td>
</tr>
</tbody>
</table>

<table align=center>
<thead>
<tr>
<th colspan=2>Interactive interface</th>
</tr>
</thead>
<tbody>
<tr>
<td><image src="assets/screenshots/interface.png"></image></td>
</tr>
</tbody>
</table>

<table align=center>
<thead>
<tr>
<th colspan=2>Bounding Volume Hierarchy Debugger</th>
</tr>
</thead>
<tbody>
<tr>
<td><image src="assets/screenshots/bvh.png"></image></td>
</tr>
</tbody>
</table>

## 🔨 Build

⚠️ [Needs mlx prerequisites](https://harm-smits.github.io/42docs/libs/minilibx/getting_started.html#installation)

```
make -j
./miniRT *.rt
```

Run default scene
```
make run
```
Run all renders
```
make render
```


## 🚀 Features

- Basic Geometric Shapes:
- Sphere
- Cylinder
- Cone
- Plane
- Interactive GUI with Object Manipulation
- Font Rendering from scratch using .ttf files
- Dynamic Camera Control with 3 Axes and Field of View (FOV)
- Multiple Colored Light Management
- Texture Mapping:
- .ppm files
- Checkerboard
- Normal Maps for relief
- Full Phong Lighting Model
- Post-Production Effects:
- Black & White
- Color Inversion
- Integrated Screenshot Export
- 3D Mesh Import (.obj)
- Bounding Volume Hierarchy (BVH)
- Bilinear Interpolation for Resolution Adaptation while Maintaining 30 FPS
- Anti-Aliasing for Smooth Rendering
- Multi-Threading Support

## 🕹️ **Controls**

- **W** - Move the camera forward
- **A** - Move the camera left
- **S** - Move the camera backward
- **D** - Move the camera right
- **Q** - Camera peaking left
- **E** - Camera peaking right
- **Right Mouse Button** - Switch between camera and GUI mode
- **Mouse Movement** *[GUI Mode]* - Move object
- **Mouse Movement** *[Camera Mode]* - Adjust camera view direction
- **Mouse Scroll** *[GUI Mode]* - Increase or decrease value
- **Spacebar** - Move the camera up
- **Shift** - Move the camera down
- **H** - Hide the GUI
- **B** - Switch to the next post-processing effect
- **T** - Take screenshot
- **R** - Enable BVH debugger
- **DELETE** - Deselect object
- **COMMAND + S** *[MacOS]* - Save current scene
- **CTRL + S** *[Linux]* - Save current scene
- **Esc** - Exit the program

## 📚 **Resources**

- [Fonts](https://developer.apple.com/fonts/TrueType-Reference-Manual/)
- [Bézier curves](https://www.youtube.com/watch?v=aVwxzDHniEw&t)
- [The Cherno](https://www.youtube.com/watch?v=gfW1Fhd9u9Q&list=PLlrATfBNZ98edc5GshdBtREv5asFW3yXl)
- [Sebastian Lague](https://www.youtube.com/watch?v=Qz0KTGYJtUk)
- [The Book Series](https://raytracing.github.io/)
- [Normal Mapping](https://learnopengl.com/Advanced-Lighting/Normal-Mapping)
- [Normal Mapping2](https://www.youtube.com/watch?v=oOOeV3IU2Yo)
- [Texture Mapping](http://raytracerchallenge.com/bonus/texture-mapping.html)
- [Projective Camera Models](https://pbr-book.org/3ed-2018/Camera_Models/Projective_Camera_Models)
- [How To Build A BVH](https://jacco.ompf2.com/2022/04/13/how-to-build-a-bvh-part-1-basics/)
- [AABB Intersection Algorithm](https://medium.com/@bromanz/another-view-on-the-classic-ray-aabb-intersection-algorithm-for-bvh-traversal-41125138b525)
- [Shading And Lighting](https://cglearn.codelight.eu/pub/computer-graphics/shading-and-lighting#material-lambert-lighting-model-1)
- [Intersection equations](https://physique.cmaisonneuve.qc.ca/svezina/nyc/note_nyc/NYC_CHAP_6_IMPRIMABLE_4.pdf)


## 📝 Authors

- [Vincent Fries](https://github.com/V-Fries) ([**vfries**](https://profile.intra.42.fr/users/vfries))
- [Tom Damerose](https://github.com/tdameros) ([**tdameros**](https://profile.intra.42.fr/users/tdameros))
Binary file modified assets/normal_maps/normal_maps.tar.gz
Binary file not shown.
Binary file modified assets/objects/objects.tar.gz
Binary file not shown.
37 changes: 37 additions & 0 deletions assets/scenes/fun.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
C 73.568977,6.377863,13.869437 0.993900,-0.106286,-0.006556 100.000000

A 0.100000 255.000000,255.000000,255.000000
L 76.113953,7.071667,12.440534 0.320000 255.000000,255.000000,255.000000
L 70.998718,5.498545,12.596428 0.500000 222.000046,135.000000,255.000000
L 81.306839,6.704214,9.284767 0.500000 91.000000,255.000000,110.000023
L 92.994293,8.766823,9.752440 0.500000 0.000000,189.000000,255.000000

pl 79.112068,0.017770,22.203047 0.000000,0.000000,0.000000 147.000000,147.000000,147.000000
ma reflection:0.200000 outline_normal_map:"assets/normal_maps/438-normal.ppm"
pl 86.829681,13.009595,12.308246 0.000000,0.000000,0.000000 147.000000,147.000000,147.000000
pl 68.091751,5.250502,13.361444 0.000000,0.000000,90.000000 3.000000,3.000000,3.000000
ma reflection:0.800000
pl 101.765602,4.417149,15.707047 0.000000,0.000000,90.000000 8.000000,8.000000,8.000000
ma reflection:0.800000
pl 76.155800,5.387167,21.574078 90.000000,0.000000,0.000000 147.000000,147.000000,147.000000
pl 82.042976,2.377486,5.691332 90.000000,0.000000,0.000000 147.000000,147.000000,147.000000
sp 83.548340,6.813190,10.633235 1.800000 147.000000,147.000000,147.000000
ma outline_texture:"assets/textures/baseball.ppm"
sp 83.228325,7.753211,16.061512 1.400000 147.000000,147.000000,147.000000
ma outline_texture:"assets/textures/tennis_ball.ppm"
cy 83.356522,5.203247,13.535020 30.000000,0.000000,210.000000 1.200000 2.400001 147.000000,147.000000,147.000000
ma outline_texture:"assets/textures/coca_cola.ppm" cap_texture:"assets/textures/can_top.ppm"
co 85.459839,2.688098,17.736216 0.000000,0.000000,0.000000 2.200000 2.700000 249.000046,249.000046,249.000046
ma outline_checkerboard:14,8-68.000000,68.000000,68.000000
mesh 84.230431,-0.057073,8.418860 0.000000,0.000000,0.000000 1.200000,1.200000,1.200000 249.000031,255.000000,248.000031 "assets/objects/chess_king.obj"
mesh 91.186066,1.350786,9.151388 0.000000,0.000000,0.000000 1.000000,2.400000,1.000000 9.000000,9.000000,9.000000 "assets/objects/cube.obj"
ma reflection:0.800000
mesh 85.237221,1.361714,13.512420 340.000000,70.000000,0.000000 1.500000,1.500000,1.500000 8.000000,8.000000,8.000000 "assets/objects/suzanne_low_poly.obj"
ma reflection:0.800000
sp 84.591972,4.013287,16.139410 1.600000 8.000000,8.000000,8.000000
ma reflection:0.800000
sp 83.819595,7.972381,12.247081 1.200000 147.000000,147.000000,147.000000
ma outline_texture:"assets/textures/earth.ppm" outline_normal_map:"assets/normal_maps/earth_normals.ppm"
sp 87.586060,3.054936,12.217457 1.400000 185.000000,255.000000,230.000031
ma outline_normal_map:"assets/normal_maps/cliff.ppm"
mesh 87.281265,0.073158,9.587049 0.000000,0.000000,0.000000 3.999999,3.999999,3.999999 225.000031,225.000031,225.000031 "assets/objects/chicken.obj"
19 changes: 8 additions & 11 deletions assets/scenes/suzanne.rt
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
C 90.163483,5.792243,29.154982 -0.176922,-0.265536,-0.947393 88.000000
C 83.471458,5.925137,23.300941 0.043072,-0.534063,-0.843828 79.000000

A 0.100000 255.000000,255.000000,255.000000
L 87.380264,4.860219,26.142035 0.500000 255.000000,255.000000,255.000000
L 89.550941,5.345338,24.245787 0.500000 255.000000,255.000000,255.000000
L 82.773834,4.183286,21.385666 0.500000 255.000000,33.000000,16.000000
L 77.637627,5.723908,16.737373 0.500000 0.000000,200.000015,255.000000
L 78.085289,10.028838,39.212433 0.500000 255.000000,255.000000,255.000000

pl 79.112068,0.017770,22.203043 0.000000,0.000000,0.000000 4.000000,147.000000,0.000000
ma outline_checkerboard:2,2-2.000000,57.000004,0.000000
pl 82.027870,1.977248,14.023896 90.000000,0.000000,0.000000 103.000008,103.000008,103.000008
pl 83.181870,7.900528,19.575264 90.000000,90.000000,0.000000 255.000000,26.000002,0.000000
pl 92.474602,5.218919,21.820732 90.000000,90.000000,0.000000 19.000000,52.000004,248.000015
pl 87.628639,7.475714,14.216568 0.000000,0.000000,0.000000 255.000000,255.000000,255.000000
pl 87.665253,3.815007,30.466049 90.000000,0.000000,0.000000 74.000000,74.000000,74.000000
mesh 88.073997,3.595053,20.933519 0.000000,340.000000,0.000000 2.000000,2.000000,2.000000 255.000000,255.000000,255.000000 "assets/objects/suzanne.obj"
pl 79.112068,0.017770,22.203043 0.000000,0.000000,0.000000 147.000000,147.000000,147.000000
ma reflection:0.530000
mesh 83.502609,0.887835,16.183208 320.000000,40.000000,0.000000 2.000000,2.000000,2.000000 189.000000,189.000000,189.000000 "assets/objects/suzanne.obj"
pl 82.116455,8.026399,-0.981926 90.000000,0.000000,0.000000 147.000000,147.000000,147.000000
11 changes: 0 additions & 11 deletions assets/scenes/suzanne_hd.rt

This file was deleted.

16 changes: 16 additions & 0 deletions assets/scenes/suzanne_low_poly.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
C 91.133606,5.447998,27.607620 -0.355897,-0.214733,-0.909173 80.000000

A 0.100000 255.000000,255.000000,255.000000
L 87.380272,4.860219,26.142038 0.500000 255.000000,255.000000,255.000000
L 89.550941,5.345338,24.245789 0.500000 255.000000,255.000000,255.000000

pl 79.112068,0.517770,22.203045 0.000000,0.000000,0.000000 4.000000,147.000000,0.000000
ma outline_checkerboard:2,2-2.000000,57.000008,0.000000
pl 82.227867,2.277248,14.223897 90.000000,0.000000,0.000000 103.000015,103.000015,103.000015
ma reflection:0.800000
pl 83.181870,7.900528,19.575262 90.000000,90.000000,0.000000 255.000000,113.000008,97.000008
pl 92.474602,5.218919,21.820732 90.000000,90.000000,0.000000 111.000008,131.000000,251.000015
pl 87.628639,7.475714,14.216567 0.000000,0.000000,0.000000 255.000000,255.000000,255.000000
pl 87.665245,3.815007,30.466049 90.000000,0.000000,0.000000 74.000000,74.000000,74.000000
mesh 88.073997,3.595053,20.933519 0.000000,340.000000,0.000000 2.000000,2.000000,2.000000 161.000000,161.000000,161.000000 "assets/objects/suzanne_low_poly.obj"
ma reflection:0.430001
20 changes: 10 additions & 10 deletions assets/scenes/tore.rt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
C 85.585022,4.187748,25.802193 0.146718,-0.204524,-0.967616 88.000000

A 0.100000 255.000000,255.000000,255.000000
L 86.116226,4.311119,20.043287 1.000000 135.000000,133.000000,253.000015
L 85.084312,3.688516,23.898817 0.500000 255.000000,118.000008,116.000008
L 86.116226,4.311120,20.043289 1.000000 135.000000,133.000000,253.000031
L 85.084305,3.688516,23.898815 0.500000 255.000000,118.000015,116.000015

pl 79.112068,0.017770,22.203047 0.000000,0.000000,0.000000 245.000031,251.000031,245.000031
pl 79.112068,0.017770,22.203049 0.000000,0.000000,0.000000 245.000046,251.000046,245.000046
ma reflection:0.300001 outline_checkerboard:2,2-0.000000,6.000000,0.000000
pl 81.727875,1.977248,14.023896 90.000000,0.000000,0.000000 57.000008,57.000008,57.000008
pl 82.081886,7.300529,19.575260 90.000000,90.000000,0.000000 255.000000,177.000000,0.000000
pl 91.574615,3.818920,22.020735 90.000000,90.000000,0.000000 219.000015,255.000000,10.000000
pl 87.628639,7.575715,14.216566 0.000000,0.000000,0.000000 4.000000,0.000000,250.000031
pl 98.384689,1.703001,26.363888 90.000000,0.000000,0.000000 78.000000,78.000000,78.000000
mesh 86.114182,3.570415,19.939489 90.000000,40.000000,0.000000 1.000000,1.000000,1.000000 70.000000,100.000008,255.000000 "assets/objects/tore.obj"
mesh 87.084854,3.139940,20.344057 30.000000,0.000000,0.000000 1.300000,1.300000,1.300000 255.000000,138.000000,133.000000 "assets/objects/tore.obj"
pl 81.827873,2.177248,13.723895 90.000000,0.000000,0.000000 57.000011,57.000011,57.000011
pl 82.181885,7.300529,19.675259 90.000000,90.000000,0.000000 255.000000,177.000000,0.000000
pl 91.574615,3.818920,22.020737 90.000000,90.000000,0.000000 219.000031,255.000000,10.000000
pl 87.628639,7.575715,14.216565 0.000000,0.000000,0.000000 4.000000,0.000000,250.000046
pl 98.384689,1.703001,26.363886 90.000000,0.000000,0.000000 78.000000,78.000000,78.000000
mesh 86.114174,3.570415,19.939491 90.000000,40.000000,0.000000 1.000000,1.000000,1.000000 70.000000,100.000015,255.000000 "assets/objects/tore.obj"
mesh 87.084862,3.139940,20.344057 30.000000,0.000000,0.000000 1.300000,1.300000,1.300000 255.000000,138.000000,133.000000 "assets/objects/tore.obj"
4 changes: 0 additions & 4 deletions assets/scenes/x-fighter.rt

This file was deleted.

13 changes: 6 additions & 7 deletions assets/scenes/xwing.rt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
C -44.297020,13.879954,459.960907 -0.405369,-0.312052,-0.858429 100.000000
C 83.003510,3.438079,12.466525 -0.066077,-0.128674,0.989052 80.000000

A 0.100000 255.000000,255.000000,255.000000
L 0.000000,1.000000,15.000000 1.000000 255.000000,254.000015,254.000015
L -44.578426,13.984364,449.965424 0.500000 255.000000,251.000015,251.000015
L 80.090302,4.105485,11.202250 1.000000 254.000046,254.000046,254.000046
L 83.526154,4.919744,9.309553 0.500000 197.000015,0.000000,32.000000

mesh -82.689552,-7.084890,368.861816 0.000000,0.000000,0.000000 0.101000,0.100000,0.100000 255.000000,217.000015,217.000015 "assets/objects/x-fighter.obj"
ma reflection:0.100000
sp -55.801208,7.263139,438.616791 304.400177 251.000015,251.000015,255.000000
ma outline_texture:"assets/textures/2k_stars.ppm"
sp 82.985535,1.909789,18.252590 68.800102 189.000000,189.000000,189.000000
ma outline_texture:"assets/textures/space.ppm"
mesh 82.914879,3.233144,16.065313 350.000000,0.000000,340.000000 1.000000,1.000000,1.000000 251.000031,251.000031,251.000031 "assets/objects/xwing.obj"
Binary file added assets/screenshots/bvh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/chess_black_and_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/chess_inverse_color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/chess_no_effects.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/earth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/interface.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/lamborghini.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/suzanne.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/xwing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/textures/textures.tar.gz
Binary file not shown.

0 comments on commit e76f862

Please sign in to comment.