# Raytracing + general relativity

This topic is 5459 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I've been learing about general realtivity in school the past couple of days, really cool stuff; the bending of light and black holes seem most interesting. Combining my interest in physics with programming i thought i could do some simulations related to the topic. So i was thinking of doing a ray traced version of a solar system or some other astronomical bodies (black holes anyone?). Ok, so how could the path of light be calculated taking into consideration gravitiational pull from massive stars? Well mostly how could i do calculate intersections in a space curved from these bodies? (if it's possible). I've done a simulation of the curvature of space using a grid of points and calculating at each point the total disturbance caused by all objects like this f(x, y) = sum( G * Mi / ((x - xi)^2 + (y - yi)^2)). The results are quite cool i'm thinking of adding forces and movement. We haven't gone into the any of the math involved in school, because we haven't done such advanced math (meh, have to wait for college) so i'm asking this question without much knowledge of the math involved (i saw some huge equations on a site about general realtivity but they were for arbirary objects, i'm guessing for spheres they should be simpler). Any pointers / links to these kind of things? hmm, maybe the math forum would be more appropiate, but everybody comes here..

##### Share on other sites
Nice idea. But, as i know, GR is pretty hard, alot harder than SR... i know SR and related math probably well enough to make a renderer, but not GR. Perhaps, for slowly moving masses, light equations is simple enough (just attraction and G Dopler), but i don't sure.

(SR=special relativity. GR=general relativity)

##### Share on other sites
To get the responses you're after, it would be better targetting this question to the Maths forum which is geared up for exactly this sort of discussion.

##### Share on other sites
The maths is very advanced. The basic idea is that space-time, a four dimensional space containing both space and time, is locally flat but on an astronomical scale it is curved, by masses such as planets and stars.

This is very difficult to represent as to do so you need a virtual fifth dimension in which the curvature takes place - virtual as it doesn't really exist but is just a mathematical construct meant to make things easier (!).

Once you have this motion takes place along geodesics in it, i.e. lines which are locally straight but curve to follow the curved 4D surface. The space is spacetime, in which every body has a 'velocity' (even bodies at rest are moving in time), so a path exists for each body, and the curvature accounts for e.g. how a body escapes or doesn't escape a gravitational field depending on its initial 4-position and 4-velocity in spacetime.

This is difficult to imagine but it's mathematically an order of magntude more complex. It was a hard third year course at my university which I avoided. But I don't think you'll need such math for a simulation: if you use the equation you quote, treating light as a particle travelling at light-speed that can be diverted but not slowed (instead experiencing a doppler effect escaping strong gavitational fields).

I don't know how close this is to the 'correct' GR maths but I suspect it will either be almost correct or out by a magnitude which you can correct for by comparing your simulation with real examples of e.g. gravitation lensing.

##### Share on other sites
Quote:
 Original post by johnbif you use the equation you quote, treating light as a particle travelling at light-speed that can be diverted but not slowed (instead experiencing a doppler effect escaping strong gavitational fields). I don't know how close this is to the 'correct' GR maths but I suspect it will either be almost correct or out by a magnitude which you can correct for by comparing your simulation with real examples of e.g. gravitation lensing.

Sounds good, i was thinking along the same lines but this sort of raytracing would be step by step, like doing it in a voxel field.

My formula gives nice results for static masses, but does not allow gravitational waves from moving ones. Any ideas on how to do those? I'm imagining it like a fluid simulation where energy flows between grid points.

##### Share on other sites
Quote:
 Original post by johnbThe maths is very advanced. The basic idea is that space-time, a four dimensional space containing both space and time, is locally flat but on an astronomical scale it is curved, by masses such as planets and stars.This is very difficult to represent as to do so you need a virtual fifth dimension in which the curvature takes place - virtual as it doesn't really exist but is just a mathematical construct meant to make things easier (!).Once you have this motion takes place along geodesics in it, i.e. lines which are locally straight but curve to follow the curved 4D surface. The space is spacetime, in which every body has a 'velocity' (even bodies at rest are moving in time), so a path exists for each body, and the curvature accounts for e.g. how a body escapes or doesn't escape a gravitational field depending on its initial 4-position and 4-velocity in spacetime.This is difficult to imagine but it's mathematically an order of magntude more complex. It was a hard third year course at my university which I avoided. But I don't think you'll need such math for a simulation: if you use the equation you quote, treating light as a particle travelling at light-speed that can be diverted but not slowed (instead experiencing a doppler effect escaping strong gavitational fields). I don't know how close this is to the 'correct' GR maths but I suspect it will either be almost correct or out by a magnitude which you can correct for by comparing your simulation with real examples of e.g. gravitation lensing.

I guess it's not close to GR math by at least magnitude of 2. GR result of light disturbance by sun gravitationfield is 2 times bigger than non-GR results, IIRC. It's one of ways how GR was proven, IIRC.

Anyway , perhaps, if masses move with "normal" speeds and accelerations (say, speeds below 1/100 c), light equations must be relatively simple, probably not that much harder than usual projectile motion equations.
(but you'll not be able to do spinning blackholes... )

##### Share on other sites
Quote:
Original post by Ilici
Quote:
 Original post by johnbif you use the equation you quote, treating light as a particle travelling at light-speed that can be diverted but not slowed (instead experiencing a doppler effect escaping strong gavitational fields). I don't know how close this is to the 'correct' GR maths but I suspect it will either be almost correct or out by a magnitude which you can correct for by comparing your simulation with real examples of e.g. gravitation lensing.

Sounds good, i was thinking along the same lines but this sort of raytracing would be step by step, like doing it in a voxel field.

My formula gives nice results for static masses, but does not allow gravitational waves from moving ones. Any ideas on how to do those? I'm imagining it like a fluid simulation where energy flows between grid points.

oh, i'm sure gravitation waves is exactly what's hard. And computationally intensive (you have to make some kind of 3D grid).

I'm now almost sure that for light, most of GR equations is simpler than for fast projectile.

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 22
• 16
• 13
• 14