3D
Black Hole
A real-time Schwarzschild black hole in the browser, with light rays traced per pixel in WebGL2.
View live (opens in a new tab)View code (opens in a new tab)
- Role
- Solo designer and developer
- Timeframe
- Oct 2026
- 6Shaders
- 4Quality tiers
- 145,536 BStar catalogue
- 6Commits
Problem
Images of black holes are usually pre-rendered or faked with a texture. The aim was a Schwarzschild black hole that runs live in a browser tab, where the shadow, photon ring and warped accretion disk come from tracing light rather than from artwork, and that stays usable on slower devices.
Approach and decisions
The project is TypeScript and Vite with WebGL2 and GLSL. Every pixel traces a ray backwards through curved spacetime in a fragment shader. The code is split into src/physics (Schwarzschild geometry, disk, colour), src/render (renderer, quality control and six shaders, including bloom) and src/sky/stars.ts. The sky uses a 145,536 B binary star catalogue over a 498,197 B Milky Way image. The Physical look applies Doppler and redshift; the Film look switches them off. Quality has four tiers and steps down automatically when frames run slow.
GitHub Pages cannot set response headers, so the Content-Security-Policy is a meta tag (decision 11).
What broke and how it was fixed
- The house
.gitignoreignoredpublic/data/, which would have deployed a site with no stars (decision 15). - Cubemap texels near face corners covered up to 5.2 times less sky, so stars there looked dim; the flux was corrected (decision 17).
- The canvas trapped page scrolling; cooperative gestures fixed it (decision 20).
Results
The site is live on GitHub Pages and the repository is public. It was built in 6 commits between 2026-10-17 and 2026-10-19, with four unit-test files and one end-to-end test that includes an axe accessibility check. The page fetches only its own files and needs no keys.
Whatโs next and limits
This models a non-rotating black hole only; spinning (Kerr) geometry is not implemented. Performance depends on the GPU, which is why the quality tiers exist. The star catalogue is limited to bright stars.



