3DS Max/Mental Ray: Photon Mapping/Global Illumination

Before you read this post, you might want to take a look at 3DS Max/Mental Ray: Basic Final Gather Explained3DS Max/Mental Ray: Setting up a daylight rig & lighting definitions

Photon Mapping

“Global illumination is a universal term for the description of a scene in which all aspects of light have been considered as bounced, reflected, and refracted light. Rendering algorithms that calculate the way light travels between surfaces of objects are called Global Illumination algorithms. The two most important Global Illumination algorithms are raytracing and radiosity. Radiosity is used by the scanline renderer, whereas mental ray uses ray-tracing.” (Van der Steen 2007: 7)

Photon Mapping is the second of two primary indirect illumination techniques that are used by the Mental Ray renderer. Unlike Final Gathering, that shoots out rays from the camera, it works in a very similar way to how light is emitted in reality. Using the mrSun (Or any photon emitter), it fires small particles towards the scene, where they are either absorbed or continue on their journey. Photons are important because they track energy and wavelength, therefore this technique of indirect illumination is able to bleed colour onto other surfaces and mimic physical effects like caustics, “Photons in Mental Ray simulate the phenomena of real-world photons. Photons are reflected by mirrors, refracted through glass, or scattered by diffuse surfaces. The big advantage of photons is that they replicate what happens in nature.” (Van der Steen 2007: 12). The Global Illumination that is achieved through using photons is split into various settings in a similar way to Final Gather. These settings are Photons per Sample (The look-up), the Sampling Radius and crucially the Amount of Photons that are fired into the scene (And therefore absorbed by it).

As the amount of photons emitted into a scene increase, the solution will refine and more information is computed. Once emitted and absorbed they are averaged within a threshold set in the max Photons per sample box. A setting of 50 will therefore look for that amount around itself biased towards those closest in proximity. Like with Final Gather, if the radius is too small, or there are not enough photons to register a consistent image, the results can appear blotchy (This can be seen below). It is therefore important that all three of these key settings are balanced the ensure that the amount of photons entering the scene is combined with a high enough sample size to create a smooth image in a radius that is not going to isolate areas of the model. Below are some examples of what happens when you play with these options:

100 0.5 20000Photons per Sample 100 Sampling Radius 0.5m Amount of Photons 20000

100 5.0 20000Photons per Sample 100 Sampling Radius 2.0m Amount of Photons 20000

200 2.0 20000Photons per Sample 200 Sampling Radius 2.0m Amount of Photons 20000

300 2.0m 20000Photons per Sample 300 Sampling Radius 2.0m Amount of Photons 20000

The images above highlight how increasing the settings can instantly change the way photons are smoothed throughout the scene. To achieve a somewhat clean solution, upping the Sampling Radius to 2.0m and increasing the Photons per Sample was required. Global illumination is a little more linear than Final Gather as the geometry can only absorb so much energy and once that point is passed, the remaining photons will simply fire into the surrounding scene. Therefore, once the calculation stage reaches a point where the time taken to compute the calculation is not noticeably increasing, it becomes fairly safe to assume that the majority of the geometry has been hit (This is not to say it is necessary to do this to achieve a good result). At this point it becomes increasingly important to play with the Sampling Radius and Photons per Sample to achieve a smooth lighting model. An upside of photons as technique is that even if you only view your model from a certain angle, the calculation is firing across all of the geometry. This means that once you have created a photon map, it can be saved and reused for any shot of that same model, as long as you do not change, or move elements within the scene.

So, what are the quirks of using Photon Mapping/Global Illumination?

Rogue photons?

In 3DS Max, photon mapping is the default way of producing global illumination, but this is not the same for every 3D package. As mentioned earlier, because this method deals with the distribution of energy and the firing of photons into a scene, it is possible that they can escape through open doorways, windows, or simply off into space if you are approaching an exterior shot. This could mean that the computer is calculating for photons that are indefinitely flying through the model space and wasting valuable time and resources to do so. To avoid this happening a common method is to seal the scene with a non reflective, invisible sphere to catch any stray photons that might find their way into empty space. This can be seen below:

SPhere

Mateiral

It is detrimental to have anything that distorts, or effects the lighting, so your sphere should not cast or receive shadows, or generate global illumination; it’s job is simply to catch any rogue photons and act as a final barrier to speed up calculations.

Combining GI with Final Gather?

When combining photons with Final Gather, the Bounces setting is ignored. Instead, photons take over the process of moving energy around the scene, and provide a rendered image that has, “both great light depth in the shadows and soft tonal variations in the illuminated areas” (Van der Steen 2007: 12). The union of these two techniques can often mean that lower settings can be applied as the photon mapping supplements the initial Final Gather pass. This can be useful in some scenes, but also detrimental in others.

Be careful of thin geometry!

The nature of the photon is to sample energy in 3D space and often if you fire samples onto very thin geometry (For example a thin wall or ceiling section), you might notice that light leaks in an unnatural way. This is a common problem that people new to photons encounter and it is due to samples from both the outside and inside of the wall converging and averaging out to produce a result that looks visibly wrong for interior lighting. An example of this can be seen below.

LargeRender LargeRenderMRAOAn example of light leaking through thin geometry  

It is clear that the first example does not look correct and there are many implications for undesirable energy entering the scene in this way. To solve this problem, the Maximum Sampling Radius in the Photon Mapping (GI) roll-out provides a way to restrict photons from intersecting past a certain threshold and after measuring the distance between the outside and the inside of the walls it was possible to ensure that no two photons were overlapping.

What about moving objects?

Specifically on moving objects they can produce ‘popping’. It is therefore common to rely simply on Final Gather for animated objects (Often relying upon faked physical phenomena like caustics if you have reflective, or refractive surfaces). A good start is to use photons for non-moving environments and interior backdrop lighting and then Final Gather with a new map at every frame (or less depending on how fast the movement is) for objects with motion.

References

Van der Steen 2007 Rendering with Mental Ray

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s