Brazil r/s Tutorials  Brazil 1.x


Global Photon Sampling

By: Dave Lamb

In the following section we will be discussing photon mapping. At first, photons may seem to be a daunting challenge to learn, but when you understand the concepts, photons will surely be your first choice for GI.

You may have seen this scene in one of the previous tutorials, and since it's a good example of how photons work, we'll use it again.
photon_qStart.max

When open, it should look like the following figure.


Fig 1.1

"Out of the box" render look like Fig 1.2.


Fig 1.2

Photons: What They're About, and How it's Done

To get a quick light solution, we're going to use pure photon mapping. At first, all the various settings and options may be a little overwhelming, but once you get the hang of it, you'll wonder how you lived without them.

This is the "Brazil: Photon Map Server" rollout in the Render Scene dialog.


Fig 2.1

Out of these options, [Photons in Estimate] and [Max Search Radius] are the most important. These settings control how the photons are gathered for any given sample point(in this case, it will be per-pixel, since the shade rate is 0/0, but not to worry, it's just as fast). First I'll outline this dialog, to give you an idea of what everything does.

"Current Photon Maps"
There are only two options under this list, Global and Caustic. This simply selects which set of options you're going to be modifying, either the global photon options, or the caustical photon options. In this tutorial, we'll only be using Global.

"Photon Bounces"
This controls the number of bounces a given photon is allowed to make. [Diffuse Depth] is the amount of light that's allowed to bounce off a diffuse surface(for instance, a plain white wall). [Reflected Depth] is how many reflection bounces are allowed per photon, and [Refracted Depth] is how many times a photon can be refracted, these can be considered global caustics, caustics generated by diffuse surfaces.

"Common Parameters"
[Active] simply activates or deactivates the photon calculation, even if a light is set to emit photons, it will not emit if this is not checked. [Total Photons] is not currently integrated.

"Irradiance Estimate"
When estimating a light sample with photons, these options come into play. At a given sample point, one of two conditions must be met, or the light sample will not be counted towards the final map(it will be black). Either the number of photons gathered must be that of [Photons in Estimate], or all the photons in the [Max Search Radius] must have been gathered. In a case where the search radius is small, or there aren't many photons being emitted, and there are no photons in that radius, the sample will be black. If the number of photons gathered in the search radius is greater than that of the number of photons in estimate, no more than the number of photons in estimate will be gathered. The [Energy Multiplier] is the intensity of the photons.

"Filtering"
Generally only used with caustics. This makes the edges of the photon map more pronounced. [Enable] does just that, enable filtering.

Last but not least, the "Photon Maps" rollout in the bLight parameters.


Fig 2.2

Again, a large rollout, but only a few parameters are commonly used.

"Photon Map Types"
Much like the "Current Photon Maps" in the "Brazil: Photon Map Server" rollout(Render Scene dialog), it simply changes the currently active option set for photons, Global or Caustic.

[Generate Photons]
Toggles photon emitting on or off. Even if it's set to on, it will not emit photons if photons are not set active in the render dialog. [# photons] specifies the number of photons to be emitted, this option is situational, and dependent on the scene. [Power] is the power at which the photons are emitted.

[Tweak Emission Params]
I won't be covering this since you shouldn't have to tweak the emission, but if you want to learn about it, refer to the reference manual.

[View Photons (debug)]
Not used -- refer to reference manual.

"Photon Focusing"
This controls how the photons are emitted from the light, much like the hotspot controls on a spotlight. Use this to get the most out of your photons. Be sure, however that you're not cutting out any of your scene, you may get unwanted results.

Now onto the fun stuff. First, go to the "Brazil: Luma Server" rollout in the Render Scene dialog, and check [Enable] under "Indirect Illumination" and set [Bounces] to 1. Then go to the "Brazil: Photon Map Server" rollout, make sure "Global" is the current photon map, check [Active]. Set [Photons in Estimate] to 32, and [Max Search Radius] to 30. Now go back to the "Photon Maps" rollout in the bLight parameters and check [Generate Photons], then check and set [# photons] to 30,000. Enable [Independent Focus], and set hotspot and falloff to 30 to insure all photons are going where they're supposed to be going.

Hit render.


Fig 2.3

Not too shabby. Render time of 00:00:05. But we still aren't getting enough light in the dark areas... increase the [Diffuse Bounces] to 8, and render again.


Fig 2.4

Common problem, overblown scenes from too many bounces. You now have one of two choices, either change the intensity of every light in the scene(in this case it's only one, however this can be tedious in large scenes), or use the "Brazil: Exposure / Color Clamping" rollout.


Fig 2.5

In order to get correct light levels at a lowered exposure, you'll have to set the [Maximum Luminance Per Sample] setting higher than 1. Again, like most settings, this is dependent on the scene. This is with a [Max Luminance Per Sample] setting of 2, and [Exposure] of 0.6.


Fig 2.6

Note: The background is darker as a result.

You can see that it is blotchier. A result of increasing bounces is more intense light, which in turn increases contrast in the scene; it's not blotchier, it's just has more contrast.

To smooth this out, we'll do a few things. One may think that increasing the photons would smooth it out considerably, however what really makes things smooth, is increasing the [Max Search Radius]. This does decrease the accuracy of the map, but photons are not designed to create an accurate map, but to add an accurate ambient light. If you want accuracy, I'm going to be discussing the Regathered method of global illumination later in this tutorial.

By fooling around with the [Max Search Radius] and [Photons in Estimate], I was able to come up with this:

[# Photons] 45000
[Photons in Estimate] 1024
[Max Search Radius] 150


Fig 2.7

At 00:01:04, this result is fair, but as you can see there is no "flare" where the light hits the walls/floor, and the light seems somewhat inaccurate. To "fix" this, we can use a method called Regathering.

Regathering: Hybrid GI

The term "Regathering" refers to a method of GI calculating that involves both Photon Mapping and QMC(or, regular) GI sampling techniques. With the help of photons, QMC samples are "pointed" in the right direction, to where the light is coming from -- where the photons are coming from -- and the result is not only faster than standard QMC sampling, but has the accuracy of photon mapping. As is, however, the scene is not set up to handle ragathering, it has too many photons, the scene would be sluggish if we simply enabled regathering. The result that we are looking for then, is lower amounts of photons, spread out over a large area(high [Max Search Distance]) to give us a smooth result, while keeping the photon numbers low.

I've experimented with the photon settings to get a quick, and smooth result with few photons.

[# Photons] 10,000
[Photons in Estimate] 64
[Max Search Radius] 400

Render time, 10 seconds.


Fig 3.1

To enable regathering, set the [Bounces] option in the "Brazil: Luma Server" rollout to 2. Then set the view rate to 4 and render.


Fig 3.2

Now we get the flares from the light hitting the floor, and at a render time of 00:02:32. You can also, then, combine undersampling, and aa to get a nice smooth result, like the one below.


Fig 3.3

Render time of 00:07:51

There is a problem with regathering, and photon mapping in general. In corners, usually, you may notice light where it's not supposed to be. This is a common problem, and the only way to get around it is to increase the photon count, however like I said, it will increase render times considerably when you get into the higher numbers.

Finally, you should spend a lot of time playing with photons, they're very fast, and if used correctly, you can get the results you want in a fraction of the time of a "regular" QMC GI rendering.

Enjoy!

 



All trademarks and copyrights on this page are owned by their respective owners.
Everything else: ©2002  SplutterFish, LLC. All Rights Reserved. Privacy