A real-time, interactive simulation of a supermassive black hole with an accretion disk, gravitational lensing, and N-Body physics. Built with Rust and Bevy Engine.
- Raymarching Rendering: Custom WGSL shader rendering a volumetric accretion disk.
- Gravitational Lensing: Simulates the bending of light rays near the event horizon using geodesic approximations.
- Relativistic Doppler Effect: Visualizes redshift (dimmer/redder) and blueshift (brighter/bluer) caused by the relativistic speed of the disk's rotation.
- N-Body Physics: Planets interact with the black hole and each other using Newton's Law of Universal Gravitation.
- Procedural Generation: The accretion disk texture and star field are generated procedurally on the GPU.
The light path is bent towards the singularity as it passes through the gravity well. In the shader, this is approximated by iteratively modifying the ray direction vector
Where
Matter in the accretion disk rotates at relativistic speeds. Light emitted by matter moving towards the observer appears brighter and bluer (blueshift), while matter moving away appears dimmer and redder (redshift).
The intensity shift
In the simulation, this results in the iconic "bright side" and "dim side" of the accretion disk.
Planets are initialized with a velocity vector perpendicular to the radius to achieve a stable circular orbit:
The simulation uses a Symplectic Euler integrator for stable orbital evolution.
| Input | Action |
|---|---|
| Left Mouse Button + Drag | Rotate the camera |
| Mouse Wheel | Zoom in / out |
Ensure you have Rust installed.
-
Clone the repository:
-
Run the project in release mode (recommended for high FPS):
cargo run --release
or
cargo run
- Language: Rust
- Engine: Bevy 0.14
- Shaders: WGSL (WebGPU Shading Language)
Created as a project to study astronomy in programming
