Video summary

Using Raymarching to create a Black Hole

Main summary

Key takeaways

Technology

Summary: Rendering a Black Hole with Raymarching (SDF) + Volumetric Accretion Disc

Goal / Approach

The video demonstrates how to render a black hole using raymarching—specifically ray tracing via signed distance fields (SDFs). It then extends the technique to create an accretion disc effect by simulating the disc as a volumetric cloud.


1) From Distances to Scenes: Signed Distance Functions (SDFs)

What an SDF is

A signed distance function (SDF) takes any point in space and returns:

  • Positive distance if the point is outside the shape
  • Negative distance if the point is inside
  • Near zero at the surface

Building primitives and combining them

  • SDFs are built from simple primitives (e.g., a circle, then extending to a rectangle).
  • To create complex scenes, multiple SDFs are defined and combined using the minimum distance:
    • The result gives the distance to the closest object, enabling environments made from many implicit shapes.

2) Ray Marching: Core Rendering Loop

Ray marching uses SDFs to iteratively approach geometry:

  1. Cast a ray from the camera in a chosen direction (one ray per pixel).
  2. At each step, use the SDF distance to advance along the ray exactly that far.
  3. Repeat sampling until:
    • the SDF indicates a hit (distance near zero / within a small threshold), or
    • the ray keeps advancing without intersection (no hit).

Visual enhancements

  • Spin / rotate sampling to reveal more detail (e.g., glowing outlines).
  • Use normals derived from the SDF plus lighting to provide shadows and shading.

3) Black Hole Effect: Gravitational Lensing (Curving Rays)

The video starts with a raymarch variant using fixed-length steps, then addresses the fact that:

  • Rays usually travel in straight lines (direction stays constant).
  • Near a black hole, gravity bends light through gravitational lensing.

The technique

Instead of keeping the ray direction constant, the ray direction is updated at each step so it curves inward toward the black hole.

Emergent landmarks as the camera approaches

  • Halo / bending behavior
  • The ability to view objects behind the black hole
  • Potential self-reflection
  • The photon sphere, where light can orbit multiple times
  • The event horizon, from which light cannot escape (resulting in “blackness”)

4) Accretion Disc Rendering via Volumetric “Cloud Disc”

Why it’s rebuilt

A direct surface simulation of an accretion disc is replaced. The disc is instead modeled as a hot gas/dust-like volume, inspired by the appearance in Interstellar.

Volumetric ray marching method

When a ray enters the disc volume:

  • It doesn’t stop at the first “hit.”
  • It continues marching while being progressively blocked by density.
  • Uses Beer’s law to compute transmittance per step:

Transmittance = fraction of light that survives to the next step

As the ray progresses, the system accumulates absorption/transparency so that:

  • Higher density → more opaque
  • Lower density → more transparent

5) Making It Light-Reactive (Scattering + Lighting)

Limitation of the first approach

The initial volumetric approach mainly determines how the cloud blocks the view, not how it interacts with light. As a result, even direct illumination may not produce visible glow/scattering.

Fix: secondary ray to the light source

For each sample point inside the cloud:

  • Cast a second ray toward the light source
  • March through the medium again using Beer’s law to compute how much light is dimmed before reaching the point

This creates internal bright/dark regions depending on effective distance through the medium.


6) Key Improvements for Realism

Anisotropic scattering (phase function)

A Heney–Greenstein model-like phase function is used to bias scattering direction:

  • More forward-biased scattering creates a soft “silver lining” effect.

Non-uniform density

The volume density is modulated using noise (e.g., Perlin/Worley-style “pearling noise”):

  • Dense pockets and gaps produce more realistic structure rather than a uniform medium.

7) Final Assembly

The final effect combines:

  • Black hole lensing raymarching
  • A volumetric cloud accretion disc around the black hole
  • Lighting + scattering + disc rotation/spin

Performance/quality note: volumetric rendering is super inefficient and “not perfect,” but visually compelling.


Main Speakers / Sources

  • Primary speaker: The video narrator/creator (described as a coder, not a physicist)
  • Referenced technical model: Heney–Greenstein phase function
  • Referenced compilation (as heard in subtitles): “Indigo Kiliillis” (noted as someone who compiled many SDFs)
  • Creative inspiration: Visual reference to Interstellar for the accretion disc look

Original video