Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Black Hole Simulation

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.

Three.js WebGL No Build

Features

  • 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.

Quick Start

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 8000

A local server is required because the project uses ES modules and fetches shader files at runtime.

Controls

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

Architecture

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

Rendering Pipeline

  1. Render Pass — Scene rendered to an offscreen texture
  2. Lensing Pass — Full-screen shader deflects UVs using the Schwarzschild metric (deflection = 2Rs/b + higher-order correction). Rays inside the capture radius render black.
  3. Bloom Pass — UnrealBloomPass adds glow to bright regions
  4. Output — Composited to screen with ACES filmic tone mapping

Dependencies

All loaded from CDN at runtime — nothing to install.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages