Caustics

In this tutorial we are going to have a look at caustics and how to create them in Maya.

The word "caustics" is used to describe the patterns created by the reflections and refraction of light when it interacts with an object (typically an object with a curved surface). For example when light is refracted through a curved surface, the rays of light can focus together forming hotspots, as you would see with a magnifying glass. Some typical examples of commonly seen caustics are;

- Light focused through liquid (the wine glass)
- Underwater (the bottom of a pool)
- The light from a battery torch

Simulating caustic behaviour is a very complex process as it has to estimate the interaction of light with various substances.

In Maya there are effectively two approaches to the simulation of caustics

1) Photon mapping (using Mental Ray)
2) Texture mapped emulation

Photon Mapping

Mental Ray (Maya 5.0+) simulates caustics using a photon map. In a preprocessing step, the light sources in the scene emit photons which are traced through the scene using photon tracing to generate a photon map. Photons emitted by lights can be reflected or refracted specularly.

Mental ray photons continue through the scene until they hit an object that is diffuse (or the photon trace depth is reached). When the caustic photon hits a diffuse object, it is added to the caustic photon map.

Open this scene in Maya 5.0

This scene contains a brandy glass with some liquid in it, a ground plane and a spotlight.

At the moment if we render we get the something like the image to the right.

To set up suitable diffuse for caustics with Mental Ray we have to do the following.
- Create shaders for the glass and liquid that have minimal diffuse
- Create a shader for the floor that has a high diffuse.

If we look at the shader for the glass, "GlassTex" we can see that it has a diffuse of 0.
Simlarly the brandy liquid, "BrandyTex" has a diffuse of 0. We want objects that cast caustics to have a very low diffuse so the actual caustic photon map is mainly drawn on the floor. This is because the glass/brandy hardly produces any diffuse reflection on the light rays. Accordingly the floor shader has a diffuse of 1.

The next step is to identify which objects in the scene are casting caustics, and which are receiving caustics. To do this we select the glass and the brandy objects and inside their transform node, open up the Mental Ray folder. These objects are to cast caustics, so in the Flags subfolder of the Mental Ray folder, deselect "Derive From Maya" and change the Caustic option for both objects to "Cast Only". Repeat this for the floor, the only difference being that the option will this time be "Receive Only".

In this example, the glass has an index of refraction of 1.5 and the brandy has an index of refraction of 1.3.

To enable raytracing for ray traced shadows and reflections/refractions in Mental Ray, open the Render Globals, set the "Render Using" to Mental Ray.

Open the Quality Folder, and then the General Subfolder and tick the box to enable ray tracing. Do a quick render and you should get something like the following image. .

...

To now create caustics in the image, we need to make the light in the scene emit photons. To do this, select the light's shape node and then open its Mental Ray folder. Inside this open the Caustic and Global Illumination subfolder and tick the box to Emit Photons. By default, the number of caustic photons is 10,000. Now do a test render. You will see that there are some caustics being formed.

...

To increase the intensity of the caustic detail by decreasing the Exponent to around 1.2, which gives more pronounced caustic detail.

...

The next step in refining the caustic detail would be to increase the number of caustic photons and play around with the energy, but for this exercise we are happy to leave it here.

Texture mapped emulation

Using the caustic photon mapped solution of Mental Ray will produce excellent results, but as you can see by now, the rendering overheads are not very attractive. In a realistic production environment it is not practical to adhere to the luxuries of caustics, so a bit of lateral thinking can save you a ton on render times.

A cheap way to achieve resonable caustics is to create a texture map that looks like the original caustic pattern and then mapped this to another light. If we turn off the primary visibility of the glass and brandy and stop the light casting shadows, the following image is what can be seen from the point of view of the light.

If we use this as a stencil in photoshop, we can trace the caustic hotspots such that we have a light texture map similar to the image below.

All that is left to do now is to duplicate the existing light, turn off its shadows, break light links between this new light and the brandy glass and then finally map this file texture to the colour channel of the new "fake caustic" light. You may need to rotate the texture in UV by 180 degrees as well as turn off UV wrapping (remembering to set the default colour in the colour balance to black so no light leaks out. With all this done, the following image was rendered.

This approach to creating caustics is much more favorable for animation, just as long as neither the light nor the glass ever moves. This is by no means as high a quality as that produced by Mental Ray, but at 9 seconds a frame to render, I am not complaining (I had time to boil the jug, make tea and play 2 games of Solitaire for the same render using Mental Ray...)