In my real time ray tracer, 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.


1 Answer 1


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.

  • $\begingroup$ Great solution, which works well. Here's the (exaggerated) result of placing an additional virtual source behind the mirror: youtube.com/watch?v=A6fppB5jeAY $\endgroup$
    – Bram
    May 4, 2017 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.