Power-User Systems

Black Hole

A real-time Schwarzschild black hole raytraced per-pixel in a WebGL2 shader — null geodesics bend a lensed accretion disk over the event horizon, with Doppler beaming, gravitational redshift, a photon ring, and a lensed starfield, all under a cinematic orbit.

Install

bun add ogl clsx tailwind-merge

Then copy 3 files into your project:

  • components/registry/black-hole/black-hole.tsx
  • hooks/use-animation-loop.ts
  • lib/utils.ts

Props

PropTypeDefaultDescription
stepsnumber300Geodesic integration steps per ray. Higher sharpens the lensing and photon ring; lower runs faster. The single heaviest cost in the shader.
diskInnernumber3Inner disk radius in Schwarzschild radii. 3 Rs is the ISCO — the innermost stable circular orbit around a non-spinning hole.
diskOuternumber12Outer edge of the accretion disk, in Schwarzschild radii.
diskBrightnessnumber1Overall emission of the accretion disk.
ringColorstring (hex)"#ff9e38"Recolors the accretion disk. White keeps the physical blackbody gradient (gold → white → blue) and the Doppler asymmetry; pick a hue to tint the ring without dimming it.
dopplerMaxnumber1Relativistic Doppler beaming and redshift strength. 0 flattens the disk to symmetric; 1 is the physical approaching-side-brighter, receding-side-dimmer asymmetry.
starBrightnessnumber1Brightness of the gravitationally lensed background stars and Milky Way band.
skyFloornumber0.02Ambient deep-space glow filling the void behind the stars. Tinted by the halo color.
rotationSpeednumber1Speed of the cinematic camera orbit and the disk's differential swirl. 0 stops both.
fovnumber85Observer camera field of view. Wider pushes the hole smaller and exaggerates the lensing curvature; narrower zooms in and flattens the perspective.
bloomStrengthnumber1Intensity of the HDR bloom that blooms the bright disk and photon ring. 0 disables the bloom passes entirely.
bloomRadiusnumber1Spread of the bloom blur. Disabled when bloom is 0.
vignettenumber0.4Darkening toward the frame edges.
grainnumber0.06Animated fine film grain over the final image.
chromaticAberrationnumber0.15Lens-edge color fringing, strongest toward the corners.
autoOrbitbooleantrueSpin the camera continuously left-to-right around the hole at a fixed distance. Drag to take manual 360° control; the orbit resumes a few seconds after you let go and keeps spinning around your current view — it never resets the angle. Off freezes the current view, which you can still drag.
debug"off" | "steps" | "disk" | "min-r" | "escape-dir" | "redshift""off"Diagnostic shader outputs — step-count heatmap, disk-hit mask, closest-approach radius, escape direction, and the redshift factor.
tintstring (hex)"#a855f7"Accent that tints only the outer halo, photon ring, sky floor, and hero-star glow. The accretion disk keeps its physical blackbody color.

What It Demonstrates

Orbit
An element circling around another in a continuous path.
Loop
An animation that repeats, a set number of times or infinitely.
Drag
Moving an element by grabbing it, often with momentum when released.
Frame rate (FPS)
Frames drawn per second. 60fps is the baseline for smooth motion; 120fps on newer displays.

Related Components

Appears In