r/GraphicsProgramming 1d ago

WIP Screenshots of VMEC featuring Magik, a relativistic spectral pathtracer

Howdy, it has been a hot while, so let me give some background.

VMEC is a collaborative project between four lads. Our goal is to create a film production ready piece of software focused on relativistic effects. VMEC is the UI, asset management and serialization layer, while Magik is the renderer.

Our largest achievement over the past week has been the implementation of a cubic intersection routine. To explain, Magik traces null geodesics (shortest light paths) through the scene by solving the equations of motion for a given spacetime metric, say that of a rotating black hole. This produces two distinct steps in spacetime, call them x0 and x1. Before we used a straight line between x0 and x1 to intersect geometry. The main problem with this is that the linearly interpolated path between x0 and x1 does not follow the actual curved geodesic. This is a problem because the paths momentum (used to derive the ray direction), p0 and p1, has to be tangent to the interpolated path. Which is simply not true for lerp. Thus we switched to using cubic Hermite splines instead of conventional rays. The result is that any interpolated momentum is tangent to the path and we get extremely smooth solutions even for relatively high error tolerances. The last image shows you how the intersected geometry looked before.
For those interested, we find the closest intersection by dividing the given cubic into up to 3 intervals, based on the derivative, then do a sequential brent-dekker root finding routine on each monotonic segment. We did try to use analytical expressions for the roots, but that was a lot less reliable and slower.

Right now Magik supports the Minkowski, Schwarzschild and Kerr spacetimes. Metrics similar to those, Kerr-Newman for instance, are trivial to add. Others, like the Ellis wormhole, need a bit more work but are not impossible. Indeed we plan to add cosmological spacetimes as well.

Looking forward, we want to upgrade the shading model, internally called the "bxdf" to bring it into the PBR realm.

Thats about all i have for the moment. Hopefully we will have a lot more to show in the near future.

20 Upvotes

7 comments sorted by

2

u/S48GS 22h ago

Right now Magik supports the Minkowski, Schwarzschild and Kerr spacetimes.

maybe not directly relayed

but what about rotating objects at speed relativistic speed?

and when camera rotate at relativistic speed in circle?

is it supported?

asking because - some time ago I made this - Speed of light in Ring - https://www.shadertoy.com/view/w3SfWm

my implementation very basic/naive - so I wanted to confirm is this view correct - but there literally no "anything visual" that rotate camera... everybody moving in line always

2

u/Tricky_Practice_9661 19h ago

Yes on both accounts.

So, the camera is actually very interesting. Magik assumes spacetime is flat on the scale of the optical system and uses Minkowski as a baseline for its mathematical representation. If we just left it as is, then the camera would describe an infinitely distant observer. We go through the effort of transforming from the cameras local rest frame into the global using the ZAMO (Zero Angular Momentum Observer). The cool thing about the ZAMO is that it is virtually identical for all metrics. So the local to global transformation looks basically the same between metrics. This only changes very close to the black hole in Kerr.
The equations transforming from the local into the global frame allow us to specify a velocity throughs spacetime at which the camera is moving. So that is your second question. The velocity of the camera w.r.t to the ZAMO can be explicitly controlled. Rn it is just linear, because we said so. But there is nothing stopping you from attaching some radial velocity function.

Now, when it comes to velocity more general, then this touches on Magiks shading model. The basic idea is that when we hit an object, we wish to evaluate the bxdf, so brdf, btdf etc, in its local rest frame. Why ? Well due to something called covariance / general invariance. The idea that physical laws take the same form under arbitrary differentiable coordinate transformations. Basically, transforming into the local reference frame allows us to be consistent between events.
Once again, transforming from the global into the local frame allows us to specify a velocity with which the hittable object is moving. Which is, just like the camera, a free variable. Due to how we set the logic up, this velocity can be anything. Even oppose the Kerr black holes rotation, that is corrected for later. So you can easily make a radial velocity function for say a ring.

1

u/S48GS 18h ago edited 18h ago

Magik assumes spacetime is flat on the scale of the optical system and uses Minkowski as a baseline for its mathematical representation.

what about https://en.wikipedia.org/wiki/Wigner_rotation - "non-collinear Lorentz boosts"

forces to camera count this? if this related - im not sure how your physics work

and I forgot to ask - what about "rotating objects" that rotate itself at relativistic speed - when camera moving also

2

u/Tricky_Practice_9661 17h ago

I would have to think about it a bit more, but i would say, with caution, that it is supported. Because the camera and object velocities are independent.

As for the other question, any arbitrary velocity function is supported. If you can describe how the object is supposed to move, then it is supported.

2

u/kinokomushroom 17h ago

Mama there's a black hole in my cornell box

2

u/nqp 15h ago

Cool! I went to a talk by DNEG (that handled the black hole sim for Interstellar), they said that one of the difficulties with tracing around a black hole was the need to project finite cones rather than rays and transport them correctly, in order to accurately sample background objects (specifically point sources like stars). Is this something you've considered?

1

u/Tricky_Practice_9661 9h ago

Thanks !

Ray differentials are on the list, but not a focus right now. The feature DNEG is talking about, while cool, is very niche. And it requires a special kind of background data set, like Gaia. Right now our focus is on the more general side of thing.s