<p>As you have probably observed, in general, you cannot solve in closed-form the equations for ray trajectories around multiple distorting objects.</p>

<p>The standard approach for such things is just to discretize it.  This looks like Eulerian integration.  Just step your ray a little bit toward the object, calculate gravity from all sources and bend it, then step it more, und so weiter.  This is called <em>raymarching</em>.</p>

<p>Since you're interested in problems on an astrophysical scale, you can assume the ray is linear far enough away from the object, with minimal error.</p>

<hr>

<p>Here's a scene I rendered a while ago using a homebrew photonmapper (no QMC) using this raymarching technique.</p>

<p>I present: relativistic photon mapping: black hole in a Cornell box!
<a href="https://i.sstatic.net/0rxaX.png" rel="noreferrer"><img src="https://i.sstatic.net/0rxaX.png" alt="black hole in a Cornell box"></a></p>

CC BY-SA 3.0
2015-09-01T16:29:40.593Z
2015-09-01T16:29:40.593Z
geometrian
<p>I'd like to simulate the magnification of very distant objects by the lensing effect of a less distant galaxy. Will I need to model large numbers of point masses or can I get away with just a single average point mass?</p>

<p>I can see how to raytrace using hyperbolae for the rays influenced by a single point mass, but I wouldn't know where to begin with multiple point masses. So before I attempt to build this raytracer I'd like to know whether I'm going to be able to avoid multiple masses, and still have believable results.</p>

CC BY-SA 3.0
2015-08-28T05:40:39.697Z
This might be a better question for [Physics.SE](https://physics.stackexchange.com/) or [Astronomy.SE](https://astronomy.stackexchange.com/). I know a point mass does produce lensing effects (see e.g. [this](http://spiro.fisica.unipd.it/~antonell/schwarzschild/)) but no idea if a galaxy can be well-approximated by a point mass for something like this.
Nathan Reed
<raytracing>
Can I raytrace gravitational lensing using only a single point source of gravity?
trichoplax is on Codidact now
# Can I raytrace gravitational lensing using only a single point source of gravity?

(Asked by: username_0 on 2015-08-23)

I'd like to simulate the magnification of very distant objects by the lensing effect of a less distant galaxy. Will I need to model large numbers of point masses or can I get away with just a single average point mass?

I can see how to raytrace using hyperbolae for the rays influenced by a single point mass, but I wouldn't know where to begin with multiple point masses. So before I attempt to build this raytracer I'd like to know whether I'm going to be able to avoid multiple masses, and still have believable results.

**Tags:** raytracing

> **Comments:**
> **username_1**: This might be a better question for [Physics.SE](https://physics.stackexchange.com/) or [Astronomy.SE](https://astronomy.stackexchange.com/). I know a point mass does produce lensing effects (see e.g. [this](http://spiro.fisica.unipd.it/~antonell/schwarzschild/)) but no idea if a galaxy can be well-approximated by a point mass for something like this.  

---

## 1 answers

### Answer by username_2 on 2015-09-01. Score: 10

As you have probably observed, in general, you cannot solve in closed-form the equations for ray trajectories around multiple distorting objects.

The standard approach for such things is just to discretize it. This looks like Eulerian integration. Just step your ray a little bit toward the object, calculate gravity from all sources and bend it, then step it more, und so weiter. This is called *raymarching*.

Since you're interested in problems on an astrophysical scale, you can assume the ray is linear far enough away from the object, with minimal error.

---

Here's a scene I rendered a while ago using a homebrew photonmapper (no QMC) using this raymarching technique.

I present: relativistic photon mapping: black hole in a Cornell box!
[![black hole in a Cornell box](https://i.sstatic.net/0rxaX.png)](https://i.sstatic.net/0rxaX.png)


---

