vm6502q / OpenRelativity

An open source framework to add the effects of traveling at relativistic speeds to visualizations or games
17 stars 2 forks source link

Gravitational lensing for Schwarzschild #17

Closed WrathfulSpatula closed 5 years ago

WrathfulSpatula commented 5 years ago

Gravitational lensing isn't necessarily hard! Assuming that the distance between "source plane" and "lens plane" is much greater than the distance between "lens plane" and observer, it's actually quite easy to apply a post-processing distortion effect to the player perspective camera that is a good approximation to a gravitational lens, for the Schwarzschild metric.

This could theoretically be made more accurate by applying the effect per RelativisticObject, such that we have an accurate tracking of the distance between "source plane" and "lens plane," per object. (That would probably also be extremely computationally intensive for the GPU, though, by comparison.)

WrathfulSpatula commented 5 years ago

We normally consider the gravity lens equation within a deflection angle of -pi / 2 to pi / 2. Outside of this range, there is solid angle in the point-of-view to fill, and the impact parameter outside of this range is not required to be less than the Schwarzschild radius, (indicating decaying orbit of light, in-falling). This suggests decaying orbits out-falling, with successive tangent ranges of width pi incrementally adding half-orbits around the black hole. Full integer orbits are simple enough, but n + 1/2 orbits would act like a "gravity mirror," bending light from behind the player halfway around the black hole and back to the player's eyes.

Incidentally, because of the variability in distance of orbit, I think time from emission to destination still appears the same across the various periods.

WrathfulSpatula commented 5 years ago

I think I might have figured out why I'm confused by the periodic deflection angle, and therefore fractal image: I simply flipped a plus/minus sign. (Firstly, the common deflection angle formula loses accuracy as it gets larger, but put that fact slightly to the side.)

Consider the deflection angle of the gravity lens: the deflection angle is 4GM/(c^2 * b), where b is the impact parameter, or 2 r_s / b, where "r_s" is the Schwarzschild radius. It is not possible to predict an approximate scattering angle greater than pi/2 in magnitude without the impact parameter being less than the Schwarzschild radius. For the counterfactual situation to exist in my code, I think I've just flipped the sign. (Oops.)

WrathfulSpatula commented 5 years ago

(That said, remembering the first part about loss of accuracy for the deflection angle, I like having the "mirror" effect, for a number of reasons. Anyone is free to turn on light-blocking by the event horizon, in which case the "mirror" becomes moot.)

WrathfulSpatula commented 5 years ago

I'll make sure I'm satisfied that I've faithfully enacted the lens equation, before I merge, short of having another set of eyes to review.

A couple of nice things to have, which I still might add:

I know I'm on my own, for this part, and even perhaps in bad taste, but a consistently evaporating black hole, even due to Hawking radiation, should turn a differential "skin" of previously in-falling decaying orbits into ultimately out-going ones. Then, turning blocking by the event horizon off for evaporating black holes might make qualitative sense, except for the potentially extreme time delay, (like, light from the CMB blue-shifted from virtually infinity and redshifted just a comparatively small bit back on the way from the hole to the player's eyes).

WrathfulSpatula commented 5 years ago

Doppler shift is in. (The effect is not actually "qualitatively opposite" looking the opposite direction.)

Infinite regression of near-field images is not easily accomplished. At least, it is out-of-scope, here. For better or worse, I've tried to write a "skybox-limit" shader, except it also regards the volumetric origin of a single black hole. As with the previous work, the black hole origin currently must be at the Unity world coordinate origin, due to the potential computational difficulty of shifting the origin of the Schwarzschild coordinates.

As in the past, with a new feature, there are probably parts that are wrong, by omission or bad physical implementation. There are also known, intentional limitations the shader places on scene design. I'll play with it, (that's the point!) and I'll notice where it's broken and fix it. Eventually getting the impact parameter approximation self-consistent, I believe this is more than "qualitatively" correct, and it's time to play.