A gravitational lensing simulator written in CUDA C++. This project renders the visual distortion of a Schwarzschild black hole.
Watch the summary and final render on youtube.
- Simulates the bending of light using the geodesic equations.
- Solves
$\frac{\partial^2 u}{\partial \phi^2} =\frac{3GM}{C^2} u^2 - u$ using RK4 method, where$u = \frac{1}{r}$ , and$r$ and$\phi$ are polar coordinates in 2D. This generates the path taken by a ray under the influence of the black hole. - Leverages CUDA kernels for parallel processing of millions of light rays.
- Generates PNG sequences of black hole visuals.
- You need to run a couple of python scripts before running the renderer. Install python packages using
requirements.txt. - Run
create_disk.pyscript to create the Perlin noise mapdata/disk3d.txtfor the accretion disk. - Download the starmap_2020_4k.exr file and place it in the
datafolder. - Run
starmap_preprocess.pyto create thedata/starmap.pngfile. - Run the
.build.shscript from thebuildfolder, then run the resultinga.outexecutable. You need to havestarmap.pnganddisk3d.txtfiles in thedatafolder (which were created in the previos steps) before running the executable. - The rendered frames will be located in the
datafolder.
- GPU: NVIDIA Tesla T4
- OS: Ubuntu 24.04 LTS
- NVIDIA Driver: 570.211.01
- CUDA Toolkit: 12.6 Update 2 (nvcc 12.6.85)
- Compilers: NVCC 12.6.85 / GCC 13.3.0
- Build Tools: CMake / GNU Make
- Lodepng: Used for PNG image encoding. Developed by Lode Vandevenne. Licensed under the Zlib License.
- NASA Scientific Visualization Studio: The background starfield/Milky Way textures are courtesy of NASA/Goddard Space Flight Center.
This project is licensed under the GNU General Public License v3 (GPL v3).