Real-time Schwarzschild black hole simulator running entirely in the browser with WebGL2 and GLSL. The project renders gravitational lensing, a relativistic accretion disk, Doppler shift, redshift, and the photon ring without external scene libraries.
Animated GIF preview is also available at docs/preview.gif.
- Fullscreen WebGL2 renderer with GPU-side RK4 ray integration
- Procedural background starfield and accretion disk
- Doppler shift, gravitational redshift, and observer aberration controls
- Adjustable Schwarzschild radius, integration steps, exposure, bloom, and orbit parameters
- Zero runtime dependencies beyond the browser platform
- Node.js
^20.19.0 || >=22.12.0 - A browser with WebGL2 support
EXT_color_buffer_floatsupport for HDR rendering
Geodesica Physics & Implementation (PDF)
npm install
npm run devVite will print the local development URL, typically http://localhost:5173.
npm run build
npm run preview- Drag: tilt the camera
- Mouse wheel or pinch: zoom
WASDor arrow keys: move the observerQ/E: move down / up
- Vite
- TypeScript in strict mode
- WebGL2
- GLSL via
vite-plugin-glsl
black-hole-simulator/
|-- docs/
| |-- geodesica-physics.tex
| |-- geodesica-physics.pdf
| |-- preview.gif
| `-- preview.jpg
|-- index.html
|-- package.json
|-- src/
| |-- main.ts
| |-- renderer.ts
| |-- scene.ts
| |-- gui.ts
| |-- style.css
| |-- shaders/
| | |-- blackhole.vert
| | |-- blackhole.frag
| | `-- postprocess.frag
| `-- utils/
| |-- math.ts
| `-- stats.ts
|-- tsconfig.json
`-- vite.config.ts
- All visuals are generated procedurally in shaders or in code. The repo does not ship third-party texture assets.
- The app is intended for modern desktop and mobile browsers with reasonably current GPU drivers.
