A raytracing sandbox, including an editor for scene setup and configuration, which supports 3D raytracing of simple objects like spheres, but also ray marching in curved spacetime, based on the laws of general relativity.
I started this project as a basic 3D raytracer with the usual "hello world" stuff, but the ultimate goal was the accurate rendering of some metrics of general relativity (wormholes, black holes), continuing the work from a previous project. 🙂
It is inspired by a lot of fantastic open source content, starting from the well known "Raytracing in one weekend" series [1] over to TheCherno's youtube channel on game engines and graphics programming [2] to the papers by Kip S. Thorne et. al. on GR raytracing, which were published after the release of the movie "Interstellar" [3], [4].
Part of this project is a standalone wormhole renderer in form of a CLI application. It allows you to easily create your own realistic image sequences and videos. It is based on the modified Ellis wormhole metric from the mentioned paper, which was used by the DNEG special effects team in the movie "Interstellar". You can configure your own scene, including image size, wormhole parameters, camera position and velocities via arguments. Several celestial background sphere textures can be chosen to set the "background" of the two connected space time regions.
As an example, the following call would create a 5s sequence of 1080x720 images @30 fps, starting from a given distance to the wormhole. Two celestial sphere textures are taken from https://www.dneg.com/, which were provided for educational purposes. In general the id can be set to a value between 0..7 for the available textures.
traceit_cli.exe
-w 1080 -h 720
--distance 10.0
--radial_velo 0.0
--azimuth_velo 0.4
--duration 5.0
--lower_sphere_id 0 # "Saturn side"
--upper_sphere_id 2 # "Far Galaxy side"
Example output video, which can be generated from the image sequence with tools like ffmpeg:
interstellar_wormhole.mp4
Trip through the wormhole with a radial velocity > 0:
interstellar_wormhole_fly_through.mp4
As a prerequisite VulkanSDK-1.3.236.0 (or later) has to be installed, which is used for the GUI application. Tested on Win 10, but should be adaptable to other systems. Developed with Visual Studio 2022.
Libraries automatically bundled with this repo:
- ImGui, excellent and lightweight GUI library
- glm (OpenGL Mathematics, header-only)
- glfw-3.3.8 (header + precompiled lib/dll)
- stb (for image loading)
- Add more things to the 3D setup (objects, materials ...)
- Support for black hole metrics
[1] https://raytracing.github.io/books/RayTracingInOneWeekend.html
[2] https://www.youtube.com/@TheCherno
[3] Kip S. Thorne et al. (2015), Visualizing Interstellar's Wormhole
[4] Kip S. Thorne et al. (2015), Gravitational lensing by spinning black holes in astrophysics, and in the movie Interstellar
[5] Mykhailo Moroz, https://michaelmoroz.github.io/TracingGeodesics/