A physically-inspired, real-time black hole simulation built with Three.js and custom GLSL shaders. Features gravitational lensing, an accretion disk with Doppler beaming, relativistic jets, and interactive controls.
- Gravitational Lensing — Post-processing shader based on the Schwarzschild metric. Background stars visibly bend around the black hole, forming an Einstein ring near the photon sphere.
- Accretion Disk — Custom fragment shader with temperature-dependent color (blue-white core to orange-red edge), Keplerian orbital velocities, Doppler beaming (approaching side brightened/blueshifted), and multi-octave noise turbulence with spiral arm structure.
- Relativistic Jets — 6,000 animated particles streaming from both poles with conical spread and distance-based fade.
- Event Horizon — Black sphere with a Fresnel-effect glow at the photon sphere boundary.
- Star Field — 15,000 point sprites with stellar classification colors distributed on a distant sphere.
- Bloom — UnrealBloomPass for cinematic glow on the disk and jets.
- Interactive Controls — Real-time parameter tuning via lil-gui panel.
No build step required. Serve the directory over HTTP and open in a browser:
npx serve .Then visit http://localhost:3000.
Alternatively:
python3 -m http.server 8000A local server is required because the project uses ES modules and fetches shader files at runtime.
Camera: Drag to orbit, scroll to zoom, right-drag to pan.
GUI Panel:
| Parameter | Description |
|---|---|
| Mass | Black hole mass — scales the Schwarzschild radius and all dependent physics |
| Spin | Spin parameter — controls disk rotation direction |
| Temperature | Accretion disk color temperature |
| Doppler Effect | Toggle relativistic Doppler beaming on the disk |
| Gravitational Lensing | Toggle the lensing post-processing pass |
| Lensing Strength | Intensity of light deflection |
| Relativistic Jets | Toggle jet particle streams |
| Bloom | Glow intensity |
| Time Scale | Speed up or slow down the simulation |
| Auto Rotate | Automatically orbit the camera |
| Paused | Freeze the simulation |
index.html Entry point (import map for Three.js CDN)
css/style.css UI styling
src/
main.js Init, animation loop, orchestration
blackhole.js Event horizon sphere + photon sphere glow
accretionDisk.js Disk geometry + shader material
starfield.js Background star points
jets.js Particle jet system
postprocessing.js Render → Lensing → Bloom pipeline
controls.js OrbitControls + lil-gui
shaders/
lensing.vert/frag Schwarzschild gravitational lensing
accretion.vert/frag Disk temperature, Doppler, turbulence
jet.vert/frag Jet particle rendering
- Render Pass — Scene rendered to an offscreen texture
- Lensing Pass — Full-screen shader deflects UVs using the Schwarzschild metric (
deflection = 2Rs/b+ higher-order correction). Rays inside the capture radius render black. - Bloom Pass — UnrealBloomPass adds glow to bright regions
- Output — Composited to screen with ACES filmic tone mapping
All loaded from CDN at runtime — nothing to install.
- Three.js r160 — 3D engine
- lil-gui — Parameter controls
MIT