Website powered by

Black Hole Shader

I originally started this piece, because I wanted to try to learn more about ray marching and because I found that the refraction created using i.e. vertex normal or a fresnel to fake gravitational lensing, while often relatively cheap, didn't look convincing enough for me.

The final result is a shader in which I use Ray marching to simulate gravitational lensing as well as energy emission/absorption of the accretion disk.

A big challenge was figuring out how to self-occlude the singularity with its accretion disk. Originally, the setup was a 2d sprite instead of a sphere mesh with another plane mesh for the accretion disk inside a particle system. Both being technically translucent meant that one would inevitably draw on top of the other, which didn't look good and rendering i.e. the accretion disk with 1-bit alpha, dithering and temporal AA really exposed the weaknesses of both TAA and the individual raymarching steps unless I'd increase the step count to an unreasonable amount. The final setup has moved away from the particle system and is now a "fish bowl" setup, projecting inside a sphere performing a "fake depth" test inside the shader.

Original 2D setup with refraction debugging. Refraction logic is pretty much the same as the final version.