r/GraphicsProgramming • u/Far_Meeting_2763 • Jul 31 '26
Real-time CPU Black Hole Ray Tracer in C++ and Raylib
Hey everyone! I built a real-time simulation of gravitational lensing around a Schwarzschild black hole from scratch in C++ using Raylib.
Instead of writing GPU shaders, I wanted to build a CPU software renderer to see how far I could push numerical integration on a single thread. It traces around 30,000 light rays per frame to bend light around the singularity and accretion disk.
• Integrates geodesic light paths directly on the CPU.
• Renders to an internal 200x150 pixel buffer to maintain 60 FPS.
• Bilinearly upscales the buffer to 800x600 using Raylib for display.
Repo & code: https://github.com/hellosharma808-sys/3D-Black-Hole