A real-time black hole shader for Unity URP. Gravitational lensing, a swirling accretion disk, a procedural starfield, all raymarched inside a single material. Inspired by Gargantua from Interstellar.
Light rays bend along Schwarzschild-style null geodesics, so the shadow, the photon ring, and the disk wrapping over and under the hole all fall out of the physics instead of being faked. The disk itself is turbulent: orbiting hot clumps, spiral density waves, dark dust lanes, and a Doppler-shifted bright side that all rotate with proper Keplerian shear. Behind the hole the procedural sky gets lensed by the same bent rays, so stars and nebula smear into an Einstein ring around the shadow.
- Geodesic gravitational lensing (real ray bending, not a screen warp)
- Photon ring and event horizon shadow that hold up from any angle
- Animated accretion disk: filaments, particle clumps, spiral arms, dust lanes
- Relativistic Doppler beaming and color shift
- Procedural lensed starfield + nebula, seamless with the matching skybox shader
- 4x rotated-grid supersampling toggle for clean edges
- Drop-in prefab, everything exposed in the inspector
- Unity 6 (6000.x) with Universal Render Pipeline
- Bloom in a Volume (the disk emits HDR values way above 1.0, bloom is what sells the glow)
- ACES tonemapping recommended
- Drop
Assets/BlackHole/Prefabs/BlackHole.prefabinto your scene. - Scale the transform to size the hole. The effect lives inside the mesh bounds, so keep it roughly spherical.
- Add a Volume with Bloom enabled. Without bloom the disk looks flat.
- Tilt the prefab to pick how edge-on the disk reads.
Open Assets/BlackHole/Scenes/BlackHoleDemo.unity for a configured example (skybox, bloom, ACES already set up).
Tuned on the material. Sensible defaults ship with the prefab.
Event Horizon Scale size of the shadow relative to the mesh
Raymarch Steps quality vs cost; lower for mobile (~96-128)
Raymarch Step Scale step length; smaller = more accurate near the ring
Disk Inner/Outer Radius disk extent
Disk Brightness HDR emission (feeds bloom)
Disk Color / Hot Color cool outer, hot inner blend
Disk Ring Detail radial noise frequency
Disk Rotation Speed Keplerian spin rate
Doppler Strength approaching-side brightening + blue shift
Particle Intensity brightness of orbiting clumps
Particle Sparsity how rare the clumps are
Spiral Arms number of spiral density waves
Spiral Intensity how pronounced the arms are
Turbulence Warp domain-warp swirl of the disk
Dust Lane Strength darkness of absorbing dust filaments
Starfield Intensity lensed background brightness
Supersample 4x anti-aliasing toggle (off to save fill rate)
The shader is fill-rate heavy where the mesh covers the screen (up to a few hundred raymarch steps per pixel). As a hero effect on desktop it is fine. For mobile or many instances, drop Raymarch Steps and turn off Supersample 4x.
It does not lens actual scene geometry behind the hole, only the procedural sky. That keeps the background seamless with the skybox. If you need real geometry lensed, that is a separate screen-space pass.
MIT. See LICENSE.
