Photon Mapping

Photon Mapping for Refractive Caustics

Caustics provide interesting lighting effects. They are the quickest to setup in a scene and they are also the quickest to render. There are two types of caustics. One is called refractive caustics when the caustics are produced by photons passing through transparent and refractive material and the other is called reflective caustics when the caustics are produced by photons being reflected off a reflective material.

While setting up a surface attribute that can exhibit one form of caustics is not difficult, setting up a surface that will properly exhibit the two form simultaneously can be a little trickier and requires more thinking and knowledge of surface properties.

First I will review how to setup a scene for refractive caustics.

Setting up a scene for rendering refractive caustics is very simple. All you need is a transparent and refractive object that will bend the photon paths, a light that will emit photons toward the refractive object and a surface which will receive and display the photons.

In the example scene, the sphere acts as a refractive object, a klieg light oriented toward the sphere will emit photons and a simple ground plane will receive the photons.

The first thing to do when rendering caustics is to set the "Caustics" attribute in Choreography Properties to ON. But don't turn it ON immediately because there are other settings that we want to test using raytracing only.

Light setup

The second thing to do is to setup the light properties. Finding the correct set of radiosity attributes in the choreography properties can take some time and we want to have an initial setup that will render the quickest as possible and give us the most useful information on our progress.

Type

When rendering caustics, using a klieg light will ensure that the photon shooting step will be kept to a reasonable time. It is possible to use a bulb light. However, bulb lights will shoot photons in all direction but only those photons which reach the refractive surface will be used resulting in a lot of unused photons and thus a lot of lost time shooting photons for nothing.

Shadows

Make sure that the light shadow property is set to raytraced and only 1 ray is cast. This may be changed later after finding the proper radiosity attributes.

Width

Set the light width to 0. This will not speedup render time but it will greatly help find the optimal radiosity attributes. This may also be changed later.

Fall-Off

Set the light fall-off to the minimum distance that will give a proper lighting. Ideally, for radiosity, light fall-off should be set in such a way that it does not actually reach any object in the scene and then its intensity should increased accordingly. At least, its fall-off distance should never exceed the point where the caustics are projected on the receiving surface. Increasing fall-off beyond this point wil only produce overbright caustics and it will be necessary to compensate with photon intensity afterward which may not be even possible in situation where the fall-off extends way too far. In the example scene, here, the fall-off extends to about the center of the caustics projected on the ground. This will produce overbright caustics but it is OK for demonstration purposes. (See the description of the light fall-off)

Refractive Object Setup

There are some necessary attributes to setup for refractive setup. They are:

Transparency

The object needs to be transparent. 98% transparency will do.

Index of Refraction

The object needs an Index of Refraction. This is important otherwise the photons will not bend at all and thus will not produce caustics. An IOR of 1.1 will do.

The other following attributes are not a requirement for refractive caustics setup but will make a more believable glass sphere. They are:

Reflectivity

A glass sphere would also be reflective. A reflectivity of 40% will do. A reflective surface will also produce reflective caustics. The consequence of having both reflective and refractive attribute on a surface is that the photons will be split 50/50 between refracted photons and reflected photons thus potentially producing more grainy caustics. But this can be taken care of by increasing the number of photons in the scene. For the purpose of realism, the total of transparency plus reflectivity should not be higher than 100%. Although the photon mapper will render such a surface, physically, this would mean that more photons leave the surface than it receive which is clearly not realistic.

Specular Size and Intensity

A glass sphere would not quite look like a glass sphere without specular highlight. Set the Specular size to 50% and the intensity to 100%.

Reflectivity Fall-Off

This is a nice trick I learned from examining Fabrice Favé original Sphere scene. By adding a Reflectivity fall-off, it gives a nice diaphanous transparency to the sphere. A value of 350 will do.

Choreography Setup

The initial scene render should look something like that.

Note that the A:M renderer tries to simulate a caustics even when not using photon mapping

But now is the time to add some real caustics.

Simply turning the Radiosity ON and then Caustics ON on the choreography properties will give this render.

In this case, the default setting of 10k photons, sampling area 100 and 100 photon samples produces grainy caustics.

Grainy caustics generally means that the sampling area is too small. But a number of photon samples too small will also produce this result. However, 100 photon samples is generally a good start so it is best to first focus on the sampling area.

How much too small is not easy to guess. I use a procedure called dichotomic search to help find an almost optimal set of attributes. The idea of dichotomic search is to try out large variations of one attribute and then reduce by half the variation inside the span which offers the best probability of nice render.

For instance, I know that a sampling area of 100 is too small. I will then try a much larger sampling area. I will try 1000.

This will produce this render. It can be noticed that now, the caustics is much softer but also a little too muddled on the edges.

Following the dichotomic search rule, I would test a value about midpoint between 100 and 1000. So I will next test a sampling area of 500.

Which produces this render.

I find the caustics still a little bit muddled on the edges but grain starts to appear so still tweaking the the sampling area will not get me the quality I want.

So mMy next best bet is to increase the number of photons.

Increasing the number of photons to 100k should be a good start for the dichotomic search. It renders like this.

It seems overkill so by the dichotomic rule, I will reduce the number of photons to about half between 10k and 100k.

50k photons looks good. Nice caustics edge definition and no annoying grain.

I could probably keep on searching for a more optimal attribute set but for the purpose of this tutorial, I will let it like that.

Sometime, finding the optimal caustics set of attributes can look like a black art. It is not provided that a very systematic method is followed. This systematic method is the dichotomic search. It is the fastest method available for this type of search. The next section will cover a little bit on that method.

Download the final project file by clicking here.