Ray Tracing Engine on C using SDL2. (project from school42(UNIT Factory))
Ubuntu, Debian:
$> sudo apt-get install libsdl2-dev libsdl2-ttf-dev libsdl2-image-devFedora:
$> sudo dnf install SDL2-devel SDL2_ttf-devel SDL2_image-develMacOS:
$> brew install sdl2 sdl2_image sdl2_ttfThis project inlcudes also a few my other projects. It's libraries libvectors, libft and libftsdl, and 1 other - forked parson
Use make for compiling all files.
When you have already installed SDL2 library you can use this simple rules:
- make: Compile all.
- make clean: Delete all RTv1, libft and libftsdl temporary files.
- make del: Delete temporary RTv1 files only.
- make fclean: Expands
make cleanto delete also executable RTv1, libraries libft and libftsdl. - make re: It's rules - make fclean & make in one.
- make pre: It's rules - make del & make in one.
- make profie_all: Re-compile all RTv1 source files without optimization flags but with
-no-pie -pg -O0for profiling. - make debug_all: Re-compile all RTv1 source files without optimization flags but with
-g3for debug. - make profile: Compile RTv1 source files without optimization flags but with
-no-pie -pg -O0for profiling. - make debug: Compile RTv1 source files without optimization flags but with
-g3for debug. - make norme: Check all libft, libftsdl and RTv1
*.cand*.hfiles for norme errors. (Works only on MacOS in school42)
If you change RTv1 source code use:
make del & makeor equal rule -make prefor re-compile only RTv1 executable without re-compile libft and libftsdl.If you chnage libft or libftsdl source code use:
make -C libftorcd libft && make||make -C libftsdlorcd libftsdl && makeIf you wants to re-compile libft and libftsdl for debug use:
make -C libft debug_allandmake -C libftsdl debug_all.
$> ./bin/RTv1 [flags-params] scenes/<scene_name>.json| Flag | Description | Shortcut | Valid values | Default value | Value type | Dependency on -dbg mode |
|---|---|---|---|---|---|---|
| --help | Print short flags description. After print RTv1 will automatically close. | -h | none | none | none | no |
| WITH PARAMS: | ||||||
| --viewportScale | How many times will be increased viewport. | -vps | 0.000001-10.0 | 1.0 | Float | no |
| --ambientLight | On how much shadow must be darker. (Greater - brighter) | -al | 0.000001-100.0 | 0.0 | Float | no |
| --fpsTextColor | FPS counter info text color. | -ftc | All HEX values | 0x7FFF00 | HEX | yes |
| --fpsRefreshTimer | How often will refresh FPS counter. (in ms) | -frt | 0-500 | 25 | Integer | yes |
| --antiAliasing | Enable simplified anti-aliasing algorithm. | -aa | 2-16 | 0 | Integer | no |
| BOOLEAN: | ||||||
| --debug | Enable keybinds switcher(debug) mode. | -dbg | none | not enabled | none | |
| --noCalcLight | Disable calc all light origins. | -ncl | none | not enabled | none | no |
| --textured | Enable textured rendering. | -t | none | not enabled | none | no |
| --randomLightsIntense | Enable randomaize lights intense. | -rli | none | not enabled | none | yes |
| --printUsage | Print usage for -dbg mode. | -pu | none | not enabled | none | yes |
| OTHER: | ||||||
| --noBorder | Create window without borders. | -nb | none | not enabled | none | no |
Note: always put scene file in arguments line, because flags will parse only after successful read scene file.
$> ./bin/RTv1 --debug -vps 0.5 -t -pu -ftc 0x1 -frt 0 -al 10 -nb -aa 4 scenes/sphere.json| Description | Keybinding |
|---|---|
| Toggle on\off rendering info. | Z |
Toggle on\off calculating and rendering shadows. (eShadows scene param) |
H |
| Toggle on\off rendering textures. (-t) | Y |
| Toggle on\off calculating light origins. (-ncl) | N |
| Exit. | Esc |
| Name | Description | Keybinding |
|---|---|---|
| Switcher keybind mode to control all light origins or objects. | After first press is active Lights Control Mode keybinds, after second press - Objects Control Mode. Keybinds after third press retruns to Default Camera Control Mode. All keybinds valid for all light origins or objects dependecny on mode. |
X |
| Increase speed value. | Increase speed value for changing movements[default] or intensity\specular[optional]. | LShift |
| Decrease speed value. | Decrease speed value for changing movements[default] or intensity\specular[optional]. | LCtrl |
| Description | Keybinding |
|---|---|
| Move camera up. | W |
| Move camera left. | A |
| Move camera down. | S |
| Move camera right. | D |
| Move camera backward. | Q |
| Move camera forward. | E |
| Increase camera rotate by X-axis. | R |
| Increase camera rotate by Y-axis. | F |
| Increase camera rotate by Z-axis. | V |
| Decrease camera rotate by X-axis. | T |
| Decrease camera rotate by Y-axis. | G |
| Decrease camera rotate by Z-axis. | B |
| Description | Keybinding |
|---|---|
| Move lights up. | W |
| Move lights left. | A |
| Move lights down. | S |
| Move lights right. | D |
| Move lights forward. [default] | E |
| Move lights backward. [default] | Q |
| Switch to control lights intensity. | C |
| Decrease lights inensity. [optional] | Q |
| Increase lights inensity. [optional] | E |
| Description | Keybinding |
|---|---|
| Move objects up. | W |
| Move objects left. | A |
| Move objects down. | S |
| Move objects right. | D |
| Move objects forward. [default] | E |
| Move objects backward. [default] | Q |
| Switch to control objects specular. | C |
| Decrease objects specular. [optional] | Q |
| Increase objects specular. [optional] | E |
| Increase objects rotate by X-axis. | R |
| Increase objects rotate by Y-axis. | F |
| Increase objects rotate by Z-axis. | V |
| Decrease objects rotate by X-axis. | T |
| Decrease objects rotate by Y-axis. | G |
| Decrease objects rotate by Z-axis. | B |
For re-compile whole project for correct profiling use this command:
$> make profile_allrAfter re-compile just run ./RTv1. More info about profiling on eax.me(RU).
Example on:
$> ./bin/RTv1 -dbg scenes/sphere.jsonExample on:
$> ./bin/RTv1 -dbg scenes/all.jsonExample on:
$> ./bin/RTv1 scenes/all.jsonExample on:
$> ./bin/RTv1 scenes/sphere.json