---
id: "schwarzschild-null-geodesic-lensing"
title: "Schwarzschild Null-Geodesic Gravitational Lensing and Relativistic Accretion Disk"
aliases: [black hole ray tracing, relativistic accretion disk rendering, Binet geodesic lensing, Schwarzschild photon ray marching]
domain: "volumes"
stage: "volume"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, cuda]
year_introduced: 2015
inputs: [hdr-image, depth, texture]
outputs: [hdr-image, radiance]
style: "photoreal"
dynamic: "dynamic"
cost: "medium"
authority: "James et al., 2015"
url: "https://texelatlas.vercel.app/t/schwarzschild-null-geodesic-lensing/"
sources_verified_at: "2026-11-30"
---
# Schwarzschild Null-Geodesic Gravitational Lensing and Relativistic Accretion Disk (James et al., 2015)

> Integrate curved null-geodesic photon paths around a Schwarzschild mass per pixel, combining thin-lens background deflection with relativistic Doppler-beamed, gravitationally redshifted emission from a Keplerian accretion disk.

## Reach for it when

- render a physically plausible black hole with photon ring and accretion disk
- bend background starfields and environment maps around a gravity well
- integrate curved light rays in curved spacetime on the gpu in real time
- show top and bottom of an accretion disk simultaneously via gravitational lensing
- avoid numerical spiral blowup near the event horizon when ray marching

## How it works

Around a compact mass, light no longer follows straight rays. Each pixel near the hole steps a camera ray backward in Cartesian coordinates using the Binet null-geodesic acceleration $x'' = -\tfrac{3}{2} h^2 x / r^5$ (in units of the Schwarzschild radius $r_s$, with conserved angular momentum $h = |x \times v|$). Rays with impact parameter below the critical threshold $b_c = \tfrac{3\sqrt{3}}{2} r_s$ plunge into the event-horizon shadow, while rays grazing $b_c$ orbit partially around the hole to form a razor-sharp photon ring.

Whenever a curved ray crosses the equatorial plane between the innermost stable circular orbit and the outer radius, the shader evaluates a thin, differentially rotating turbulent accretion disk. Emission follows a blackbody temperature profile ($T \propto r^{-3/4}$) shifted in both frequency and brightness ($I \propto g^4$) by the combined Keplerian Doppler factor and gravitational redshift, brightening and blue-shifting the approaching limb while dimming the receding side. Because rays bend over and beneath the shadow, the far side of the disk arches both above and below the black core.

For embedded 3D scenes rather than skyboxes alone, a depth-gated weak-field thin-lens pass deflects background pixels behind the lens plane while keeping foreground geometry sharp and clamping lookups away from the hole's own silhouette.

## When to use it

Choose it when rendering physically recognizable black holes, Einstein rings, or relativistic singularities in real-time VFX, space simulations, or cinematic visualization.

Prefer [volume-ray-marching](volume-ray-marching) when rays travel in straight lines through ordinary nebulae, clouds, or gas without spacetime curvature. Prefer [sphere-tracing](sphere-tracing) for refractive or warped analytic SDF anomalies where general-relativistic disk crossings and photon rings are unnecessary. Prefer [lens-flare](lens-flare) for purely optical camera bloom and diffraction effects without scene deflection.

## Cost

medium — Runs as a single fullscreen or bounding-region fragment pass whose cost scales with geodesic integration step count (typically 48–96 steps) and screen coverage of the black hole.
Measured GPU Weight: 41.35× baseline (heavy) — 1.3604 ms median / 1.4432 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 38.84× baseline (heavy) — 0.6176 ms median (2.2× faster on L4).
Ampere A100 scaling: 24.39× baseline (heavy) — 0.7025 ms median (1.94× faster on A100).

## Failure modes

- Coarse integration steps near the photon sphere cause jagged or stepped aliasing along the critical photon ring and secondary disk images
- Screen-space background deflection cannot reveal occluded geometry behind foreground objects and tears at depth discontinuities unless eased smoothly behind the lens plane
- Extreme Doppler beaming ($g^4$) produces huge HDR spikes on the approaching side that clip harshly without wide-gamut tonemapping
- Schwarzschild symmetry omits Kerr spin frame-dragging asymmetry and D-shaped shadows unless extended with full Kerr metric integration

## Dataflow

- Inputs: hdr-image, depth, texture
- Outputs: hdr-image, radiance
- Platforms: webgl2, webgpu, desktop-gpu, cuda

## Presets

### Real-time Schwarzschild disk starting parameters (json-params; parameter preset)

```json
{
  "geodesic_steps": 72,
  "isco_radius_rs": 3,
  "outer_disk_radius_rs": 13,
  "critical_impact_rs": 2.598,
  "inner_temp_kelvin": 6500,
  "kepler_speed_scale": 1
}
```

Attribution: written for this index

### Schwarzschild Null-Geodesic Lensing — flat Euclidean rays (left) vs curved spacetime photon ring & Doppler disk (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_BH_MASS": 1,
  "P_DISK_INCL": 0.22,
  "P_DOPPLER_STR": 0.85,
  "P_SPLIT": 0.48
}
```

```glsl
const float P_BH_MASS = 1.00; // P Horizon Scale [0.6, 1.5, 0.05]
const float P_DISK_INCL = 0.22; // P Disk Inclination [0.08, 0.55, 0.02]
const float P_DOPPLER_STR = 0.85; // P Relativistic Beaming [0.0, 1.4, 0.05]
const float P_SPLIT = 0.48; // P Flat / Geodesic Split [0.0, 1.0, 0.02]

float hash21(vec2 p) {
  p = fract(p * vec2(127.1, 311.7));
  p += dot(p, p + 34.5);
  return fract(p.x * p.y);
}

// Background galactic starfield & faint nebula sampled by asymptotic deflected photon direction d
vec3 evalStarfield(vec3 d) {
  d = normalize(d);
  float phi = atan(d.z, d.x);
  float th = acos(clamp(d.y, -1.0, 1.0));
  vec2 g = vec2(phi * 26.0, th * 26.0);
  vec2 id = floor(g);
  vec2 f = fract(g) - 0.5;
  float rnd = hash21(id);
  float star = step(0.965, rnd) * exp(-dot(f, f) * 58.0) * (1.2 + 1.8 * hash21(id + 7.3));
  vec3 starCol = mix(vec3(0.75, 0.88, 1.0), vec3(1.0, 0.84, 0.65), hash21(id + 3.1));
  // Subtle galactic dust band
  float band = exp(-pow(d.y * 2.8 + 0.35 * sin(phi * 2.0), 2.0) * 3.5);
  vec3 neb = vec3(0.06, 0.09, 0.16) * band + vec3(0.015, 0.02, 0.035);
  return neb + starCol * star;
}

// Keplerian accretion disk emission with relativistic Doppler beaming & gravitational redshift
vec3 evalDiskEmission(vec3 pos, vec3 rayDir, float rs, float dopplerK) {
  float r = length(pos.xz);
  float rIn = rs * 2.15;
  float rOut = rs * 6.8;
  if (r < rIn || r > rOut) return vec3(0.0);

  float ang = atan(pos.z, pos.x);
  float omega = 1.65 / max(pow(r, 1.25), 0.2);
  float spiral = 0.55 + 0.45 * sin(ang * 4.0 + r * 4.2 - iTime * (1.8 + omega));
  float rings = 0.65 + 0.35 * sin(r * 14.0 - iTime * 1.4);
  float radialFade = smoothstep(rIn, rIn + 0.25 * rs, r) * smoothstep(rOut, rIn + 1.4 * rs, r);

  // Keplerian tangent velocity vector v (counter-clockwise orbiting disk)
  vec3 velDir = normalize(vec3(-pos.z, 0.0, pos.x));
  float beta = clamp(sqrt(0.5 * rs / max(r, rs * 1.1)), 0.0, 0.62);
  float cosA = dot(velDir, -rayDir);
  // Relativistic Doppler factor D = 1 / (gamma * (1 - beta*cosA)) -> approaching left side beams blazing blue-white, receding right redshifts!
  float doppler = mix(1.0, (1.0 + beta * cosA) / max(1.0 - 0.55 * beta * cosA, 0.35), dopplerK);
  float gravRed = sqrt(max(1.0 - rs / max(r, rs * 1.02), 0.08));
  float gShift = clamp(doppler * gravRed, 0.25, 2.4);

  // Temperature shifts from deep crimson -> blazing gold -> blue-white under gShift
  vec3 coldC = vec3(0.95, 0.20, 0.04);
  vec3 midC = vec3(1.0, 0.68, 0.24);
  vec3 hotC = vec3(0.85, 0.94, 1.0);
  vec3 tempCol = mix(coldC, mix(midC, hotC, smoothstep(0.85, 1.75, gShift)), smoothstep(0.35, 1.05, gShift));

  float intensity = pow(gShift, 2.4) * radialFade * (0.45 + 0.55 * spiral * rings) * 2.2;
  return tempCol * intensity;
}

vec3 aces(vec3 x) {
  x = max(x, 0.0);
  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  float sx = fragCoord.x / max(iResolution.x, 1.0);
  float split = clamp(P_SPLIT, 0.0, 1.0);
  bool useGeodesic = sx >= split;

  float rs = clamp(P_BH_MASS, 0.5, 1.6) * 0.42;
  float incl = clamp(P_DISK_INCL, 0.06, 0.65);
  float dopplerK = clamp(P_DOPPLER_STR, 0.0, 1.5);

  float camDist = 5.4;
  vec3 ro = vec3(0.0, camDist * sin(incl), camDist * cos(incl));
  vec3 fw = normalize(-ro);
  vec3 ri = normalize(cross(fw, vec3(0.0, 1.0, 0.0)));
  vec3 up = cross(ri, fw);
  vec3 rd = normalize(fw * 1.65 + ri * uv.x + up * uv.y);

  // Integrate photon trajectory: null geodesic a = -1.5 * rs * h^2 * p / r^5 (where h = |p x rd| is angular momentum!)
  vec3 pos = ro;
  vec3 vel = rd;
  vec3 hVec = cross(pos, vel);
  float h2 = dot(hVec, hVec);

  vec3 accCol = vec3(0.0);
  bool captured = false;

  const int STEPS = 84;
  for (int i = 0; i < STEPS; i++) {
    float r = length(pos);
    if (r < rs * 1.02) { captured = true; break; }
    if (r > 14.0) break;

    float dt = clamp(r * 0.085, 0.04, 0.35);
    vec3 prevPos = pos;

    if (useGeodesic) {
      // Schwarzschild exact general-relativistic null-geodesic bending force (-3/2 * rs * h^2 / r^5 * pos)
      vec3 accel = -1.5 * rs * h2 * pos / max(pow(r, 5.0), 1e-4);
      vel = normalize(vel + accel * dt);
    }
    pos += vel * dt;

    // Detect crossing of equatorial accretion disk plane (y == 0)
    if (prevPos.y * pos.y <= 0.0 && abs(pos.y - prevPos.y) > 1e-5) {
      float f = abs(prevPos.y) / abs(pos.y - prevPos.y);
      vec3 hitP = mix(prevPos, pos, f);
      accCol += evalDiskEmission(hitP, vel, rs, dopplerK);
    }
  }

  vec3 col = accCol;
  if (!captured) {
    col += evalStarfield(vel);
  }

  // Subtle Einstein photon sphere glow near r = 1.5 * rs on geodesic side
  if (useGeodesic) {
    float bImpact = sqrt(h2);
    float bCrit = 2.598 * rs;
    float photonRing = exp(-pow((bImpact - bCrit) / (0.045 * rs), 2.0));
    col += vec3(1.0, 0.86, 0.62) * photonRing * 0.45;
  }

  float sep = smoothstep(0.0035, 0.0008, abs(sx - split));
  col = mix(col, vec3(0.95, 0.97, 1.0), sep);
  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}
```

Attribution: MIT — written for this index.

## Lineage

- extends [Ray-marched Participating Media](https://texelatlas.vercel.app/t/volume-ray-marching.md)

## Combines with

- [Dual-filter and progressive-downsample bloom](https://texelatlas.vercel.app/t/dual-filter-bloom.md): HDR radiance from the Doppler-beamed inner accretion disk and photon ring drives physically convincing optical glare.
- [AgX](https://texelatlas.vercel.app/t/agx-tonemapping.md): High-contrast blackbody emission compresses cleanly into display gamut without abrupt hue shifts on the hot approaching limb.

## Sources

1. [primary] Oliver James, Eugénie von Tunzelmann, Paul Franklin, Kip S Thorne (2015) Gravitational lensing by spinning black holes in astrophysics, and in the movie
                    <i>Interstellar</i>. Classical and Quantum Gravity. https://doi.org/10.1088/0264-9381/32/6/065001 (verified via crossref on 2026-11-30)
2. [implementation] Humpalumps (2026) Humpalumps/ultra-elements. https://github.com/Humpalumps/ultra-elements License: MIT. (verified via github on 2026-11-30)

## Cite this entry

Texel. "Schwarzschild Null-Geodesic Gravitational Lensing and Relativistic Accretion Disk." https://texelatlas.vercel.app/t/schwarzschild-null-geodesic-lensing/ (accessed 2026-12-01).
