2D volume shadowing algorithm for irregular obstacles.
maps
![]() |
![]() |
---|---|
![]() |
![]() |
This C++ repo is for a 2D real-time “volume light” generator, designed for irregular obstacles. I have implemented the algorithm for regular obstacles (squares) in repo: [Enigmatisms/Algorithm-Plus], therefore, this one is regarded as A ‘Volume 2D Shader Pro‘.
The main body of this algo is god-damn fast, 23 obstacles in 1200 * 900 (pixels) canvas, it runs at 6000-12000 fps (without visualization.). Most consumption of time is due to visualization (Function visualizeVisualSpace
).
The dependent libraries are (Ubuntu 18.04):
Name & Version | Roles |
---|---|
OpenCV 3.3.1 | Visualization, video saving, user interaction |
Eigen 3 | Matrix computation and data representation. |
CMake + C++17 | Compilation tool, yet features of C++ 17 is not used. |
cd volume/
mkdir build/
cd build/
cmake .. && make -j
After executing the command lines above, two executable files are generated: ./main
(main body of this “shader”),./editor
(map editor)
I provide you with a map editor, with which you can design your own maps for trying out. However, there are something that need to be make clear:
cd volume/
mkdir maps/ # skip if folder 'maps/' is already in the root folder
cd build/
./editor <map name>
Enters the name of your own design. Map files are stored in maps/
, if the file with the same name already exists, it will be replaced.
cd volume/build/
./main <map_name> <speed>
Run as the instructions above, `./main requires some parameters:
\
\
Execution procedures:
Use your mouse to set the initial position of the light ball.
w
, a
, s
, d
will control the direction of your moving, ESC
for exiting.
To have more information of this repo and algorithm, see the personal blogs of mine [Event Horizon].