Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Sep 15, 2021. It is now read-only.
/RTv1-42Public archive

Ray Tracing Engine on C (project from school 42)

NotificationsYou must be signed in to change notification settings

Iipal/RTv1-42

Repository files navigation

Ray Tracing Engine on C using SDL2. (project from school42(UNIT Factory))

made by tmaluh(_ipal)

screenshot

Addiitonal SDL2 pre-installation:

Ubuntu, Debian:

$> sudo apt-get install libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev

Fedora:

$> sudo dnf install SDL2-devel SDL2_ttf-devel SDL2_image-devel

MacOS:

$> brew install sdl2 sdl2_image sdl2_ttf
I'm not tested this on other OS or distros.

Additional info:

This project inlcudes also a few my other projects. It's librarieslibvectors,libft andlibftsdl, and 1 other - forkedparson

Compiling

Usemake 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: Expandsmake clean to 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 -O0 for profiling.
  • make debug_all: Re-compile all RTv1 source files without optimization flags but with-g3 for debug.
  • make profile: Compile RTv1 source files without optimization flags but with-no-pie -pg -O0 for profiling.
  • make debug: Compile RTv1 source files without optimization flags but with-g3 for debug.
  • make norme: Check all libft, libftsdl and RTv1*.c and*.h files for norme errors. (Works only on MacOS in school42)

If you change RTv1 source code use:make del & make or equal rule -make pre for re-compile only RTv1 executable without re-compile libft and libftsdl.

If you chnage libft or libftsdl source code use:make -C libft orcd libft && make ||make -C libftsdl orcd libftsdl && make

If you wants to re-compile libft and libftsdl for debug use:make -C libft debug_all andmake -C libftsdl debug_all.

Usage:

$> ./bin/RTv1 [flags-params] scenes/<scene_name>.json

Flags:

FlagDescriptionShortcutValid valuesDefault valueValue typeDependency on-dbg mode
--helpPrint short flags description. After print RTv1 will automatically close.-hnonenonenoneno
WITH PARAMS:
--viewportScaleHow many times will be increased viewport.-vps0.000001-10.01.0Floatno
--ambientLightOn how much shadow must be darker. (Greater - brighter)-al0.000001-100.00.0Floatno
--fpsTextColorFPS counter info text color.-ftcAll HEX values0x7FFF00HEXyes
--fpsRefreshTimerHow often will refresh FPS counter. (in ms)-frt0-50025Integeryes
--antiAliasingEnable simplified anti-aliasing algorithm.-aa2-160Integerno
BOOLEAN:
--debugEnable keybinds switcher(debug) mode.-dbgnonenot enablednone
--noCalcLightDisable calc all light origins.-nclnonenot enablednoneno
--texturedEnable textured rendering.-tnonenot enablednoneno
--randomLightsIntenseEnable randomaize lights intense.-rlinonenot enablednoneyes
--printUsagePrint usage for -dbg mode.-punonenot enablednoneyes
OTHER:
--noBorderCreate window without borders.-nbnonenot enablednoneno
Note: always put scene file in arguments line, because flags will parse only after successful read scene file.

Example:

$> ./bin/RTv1 --debug -vps 0.5 -t -pu -ftc 0x1 -frt 0 -al 10 -nb -aa 4 scenes/sphere.json

Keybinds:

All binds below works only with-dbg flag.

General keybinds what works in all keybind modes:

DescriptionKeybinding
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
NameDescriptionKeybinding
Switcher keybind mode to control all light origins or objects.After first press is activeLights Control Mode keybinds, after second press -Objects Control Mode. Keybinds after third press retruns toDefault 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
DescriptionKeybinding
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
DescriptionKeybinding
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
DescriptionKeybinding
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

Profilig (with gprof, gprof2dot and graphviz):

For re-compile whole project for correct profiling use this command:

$> make profile_allr

After re-compile just run./RTv1. More info about profiling oneax.me(RU).

Example on:

$> ./bin/RTv1 -dbg scenes/sphere.json

./RTv1 -dbg scenes/sphere.json

Example on:

$> ./bin/RTv1 -dbg scenes/all.json

./RTv1 -dbg scenes/all.json./RTv1 -dbg scenes/all.json

Example on:

$> ./bin/RTv1 scenes/all.json

./RTv1 scenes/all.json

Example on:

$> ./bin/RTv1 scenes/sphere.json

./RTv1 scenes/sphere.json

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp