Black Hole Rendering
Overview
The goal of this project was to create an image that closely resembles a shot from the 2014 film Interstellar of a supermassive black hole,
accretion disk and small planet in the foreground. I figured that this would be an interesting challenge since I had never attempted implementing
a warped rendering algorithm and had to experiment with different ways of modeling a reasonably realistic accretion disk. My final result was obtained
by rendering a 4K image of the black hole, accretion disk and nearby planet at 1spp and downsampling it to 1080p which took ~700ms.
Gravitational Lensing
I implemented gravitational lensing using a simple algorithm that raymarches along a geodesic path created by the black hole for 1k iterations from
the camera, effectively integrating the path of a particle. I found the article, “Writing a Black Hole Raytracer”, to be a helpful reference
for this part of the project. From the beginning it seemed to me that simple Euler integration would be sufficient although the author of that article
recommended using an RK4 integrator. The renderer uses realtime raytracing to cast rays between the raymarching intervals to check for intersections with
geometry such as the accretion disk.
Accretion Disk
The other major component of the image was the accretion disk which turned out to be the more time-consuming element to fine tune in terms of modeling both its density distribution and emission. To simplify ray interactions I modeled the accretion disk as a flat annulus from the perspective of the ray-tracing intersection shader but raymarch 64 steps into a thin 3D heterogenous volume from the perspective of the hit shader. I used an ad-hoc formula to calculate emission throughout the disk and Beer-Lambert to calculate attenuation. Density was calculated by a combination of 16 octaves of value noise using radial coordinates as inputs and 16 octaves using cartesian coordinates as inputs and some other falloffs. Emission was calculated as two falloffs multiplied by density.