A real-time Schwarzschild black hole raytracer built with Three.js, WebGL 2, and GLSL.
- Real-time Schwarzschild gravitational lensing
- Null-geodesic ray integration
- Procedural accretion disk rendering
- Relativistic Doppler beaming
- Gravitational redshift
- Lensed procedural star field
- Multiple camera presets
- Cinematic camera mode
- Adjustable physical and optical parameters
- HDR bloom and post-processing
- Debug visualization modes
- Screenshot capture
A browser with WebGL 2 and hardware acceleration is required.
If GitHub Pages is enabled, the live demo will be available at:
https://INFP-coder.github.io/BlackHoleRaytracer/
Clone the repository:
git clone https://github.com/YOUR_USERNAME/BlackHoleRaytracer.git
cd BlackHoleRaytracerStart a local HTTP server:
python3 -m http.server 8080Open the following URL:
http://localhost:8080/
Do not open index.html directly with a file:// URL because the project
uses JavaScript modules.
| Control | Action |
|---|---|
| Mouse drag | Orbit camera |
| Mouse wheel | Zoom |
1–4 |
Select camera preset |
Space |
Toggle cinematic mode |
Alt+0–Alt+9 |
Select debug view |
Q |
Change rendering quality |
P |
Toggle parameter panel |
M |
Toggle ambient audio |
H |
Toggle HUD |
S |
Save screenshot |
R |
Reset parameters |
The application includes three quality profiles:
- Standard: Lower resolution and fewer integration steps
- High: Balanced quality and performance
- Cinematic: Higher resolution and additional integration steps
For troubleshooting, start the application in safe mode:
http://localhost:8080/?safe=1&post=0
Run the built-in startup test:
http://localhost:8080/?selftest=1
- A modern browser with WebGL 2 support
- Hardware-accelerated graphics
- JavaScript ES module support
- Python 3 or another static HTTP server for local development
BlackHoleRaytracer/
├── assets/
├── js/
│ ├── main.js
│ └── shaders.js
├── vendor/
│ ├── three.module.js
│ └── addons/
├── index.html
├── styles.css
├── LICENSE
└── README.md
- Three.js
- WebGL 2
- GLSL
- JavaScript ES Modules
This project includes or depends on Three.js and selected Three.js example modules. Three.js is distributed under the MIT License.
See the relevant third-party source files and license notices for details.
This project is licensed under the MIT License. See LICENSE for details.
