Black Hole Shader - POINT-VR/POINT-VR-Chapter-1 GitHub Wiki

1. Opening the Shader

Currently the shader is located in the black-hole-shader branch in the Assests\POINT\BlackHole folder. Adding any primitive sphere to the scene and applying the Black Hole Shader to the material will add the black hole.

2. How it works.

The first Idea is that the event horizon itself will be only a portion of the shader. Any lensing must be completed on a material for the engine to do any calculations. This means that the sphere model will denote the furthest reach that the black hole lensing will work on passing light. The main goal of the shader is to apply a deflection angle to any incoming 'looking vector' and apply the skybox of that new looking vector. There is a spherical symmetry around the black hole center itself, and deflection angle should only depend on how far light is from the black hole center. Astronomically this term is the impact parameter. calculation for impact parameter After that it is just finding an equation for deflection angle from impact parameter. I found 2 papers that reference this, One for far impact parameter and another for near impact parameter. Using both a new function was created to mimic both and minimize computational impact. Image for deflection angle from impact parameter black line is far approximation, red line is close, and blue line is the compromise that is used.


Now that we have the deflection angle we need to deflect. This is done using axis-angle representation. the angle was found, and the axis can be calculated with a cross product as the rotation axis should be perpendicular to both the sphere normal and incoming light (I'll leave this as an exercise to the reader as to why this works). When combined we finally get a result.

first lensing image. This almost works, but the sphere edge should be seemless in order to make the illusion work correctly. This sharp cut is because the deflection angle doesn't go to zero at the edge, leaving a discontinuity. Many solutions can be used to fix this, but I used the smoothing function x/(1-x) on the impact parameter to make it go from [0,r]→[0,∞].