<p>It depends how you define easy and what kind of constraints you have. The general case of this is rendering caustics but that's probably not what you're looking for if real time is your target.</p>

<p>If your mirrors are always flat as in your demo and you only want to support a single bounce, the easiest I can see would be to reflect your light sources on the other side of the mirror's plane, before you start a frame. Let's call each reflection a virtual light source. Then for each of these, test if the ray between whatever you're shading and the virtual light source hits inside the mirror (simple plane/ray test). If it does hit then you trace the actual shadow ray to the mirror and the rest of the shadow ray from the mirror to the actual light source.</p>

<p>This obviously won't scale well to many mirrors. I think it could be adapted to 2-3 bounces if the mirror and light count is low. The number of virtual lights could quickly grow out of hand though.</p>

CC BY-SA 3.0
2017-05-04T20:01:09.090Z
Great solution, which works well. Here's the (exaggerated) result of placing an additional virtual source behind the mirror: https://www.youtube.com/watch?v=A6fppB5jeAY
Bram
CC BY-SA 3.0
2017-05-04T00:36:54.467Z
2017-05-04T00:36:54.467Z
Olivier
<p>In <a href="https://www.youtube.com/watch?v=cWSdORU-Gnk" rel="nofollow noreferrer">my real time ray tracer</a>, I shoot primary rays from the eye, and at hit points, I trace to a single light source to determine if the object is shadowed or lit.</p>

<p>Pretty straightforward stuff so far.
However I have recently added perfect mirrors to my scene.
The reflections work just fine.</p>

<p>However, the shadow calculation breaks down!</p>

<p>A shadowed point could still be lit by the light source via a mirror.</p>

<p>Is there an easy way to handle shadow rays towards bounced light?</p>

<p>NOTE: I am not talking about the projection visible in the mirror surface: this shows shadowed and lit objects. But the directly visible scene itself, there are more shadowed objects than there should be, as some of the scene is lit via a mirror.</p>

<raytracing><shadow><reflection>
Tracing shadow rays in a scene with mirrors
Bram
# Tracing shadow rays in a scene with mirrors

(Asked by: username_0 on 2017-05-03)

In [my real time ray tracer](https://www.youtube.com/watch?v=cWSdORU-Gnk), I shoot primary rays from the eye, and at hit points, I trace to a single light source to determine if the object is shadowed or lit.

Pretty straightforward stuff so far.
However I have recently added perfect mirrors to my scene.
The reflections work just fine.

However, the shadow calculation breaks down!

A shadowed point could still be lit by the light source via a mirror.

Is there an easy way to handle shadow rays towards bounced light?

NOTE: I am not talking about the projection visible in the mirror surface: this shows shadowed and lit objects. But the directly visible scene itself, there are more shadowed objects than there should be, as some of the scene is lit via a mirror.

**Tags:** raytracing, shadow, reflection


---

## 1 answers

### Answer by username_1 on 2017-05-04. Score: 5 | Accepted answer

It depends how you define easy and what kind of constraints you have. The general case of this is rendering caustics but that's probably not what you're looking for if real time is your target.

If your mirrors are always flat as in your demo and you only want to support a single bounce, the easiest I can see would be to reflect your light sources on the other side of the mirror's plane, before you start a frame. Let's call each reflection a virtual light source. Then for each of these, test if the ray between whatever you're shading and the virtual light source hits inside the mirror (simple plane/ray test). If it does hit then you trace the actual shadow ray to the mirror and the rest of the shadow ray from the mirror to the actual light source.

This obviously won't scale well to many mirrors. I think it could be adapted to 2-3 bounces if the mirror and light count is low. The number of virtual lights could quickly grow out of hand though.

> **Comments:**
> **username_0**: Great solution, which works well. Here's the (exaggerated) result of placing an additional virtual source behind the mirror: https://www.youtube.com/watch?v=A6fppB5jeAY  

---

