Light Sampling

Light Sampling

Light sampling when working in the RIS mode of PRMan is designed to be as simple as possible. For the most part, sample balancing is controlled by the integrator. The two primary built-in integrators - PxrVCM and PxrPathTracer - provide slightly different interfaces for establishing the sampling guidelines for the integrator.


Control Over Sample Counts

Normally the lighting system in RIS is controlled with a single sample count that is requested by the integrator. The integrator typically has a numLightSamples parameter that undergoes some form of sample-reduction as down the ray tree.

Within this budget, the system usually automatically apportions samples. This frees the user from the need to explicitly control sample counts. However, there are some situations where the automatic balancing may be undesirable - cases where the system cannot effectively automate the selection, or cases where the user wishes for certain lights to assume the assignment of a sample count explicitly. This may be done by passing fixedsamplecount to the emit() call of the relevant light.

A fixed sample count light is usually removed from the automatic sample selection mechanism and will be assigned the requested sample count. This means that the effective sample count specified by numLightSamples is the budget for automatically balanced samples. In addition to this the sum of the fixedsamplecount requests will be taken.

An integrator may choose to ignore this request as ray depths increase or as the path importance decreases, in which case the lights are once again considered for sharing the budget of automatically balanced samples.


Integrator Controls

Both PxrPathTracer and PxrVCM provide numLightSamples and numBxdfSamples as controls. Light samples are picked according to the importance of the light (or subportion of the light in the case of fixedsamplecount lights) and are effective at sampling diffuse and glossy reflections. The tighter the Bxdf lobes are, the less likely that these samples will 'line up' with the peak. To resolve such features, multiple importance sampling is used. Samples are taken from the lights, importance sampled according to an importance metric on them, and samples are also taken from the Bxdf, according to importance weighting of its function. They are combined to produce a final result. In most cases, it makes sense for numLightSamples and numBxdfSamples to be set to the same sample count.

The following images show multiple importance sampling, light-only sampling and Bxdf-only sampling respectively. Lights vary in size and their color temperature, and the surfaces are less rough nearer to the camera. The Bxdf (PxrDisney) has both a specular and a diffuse component.

As shown, light samples are effective at resolving the lights when the Bxdf is rough, but the sharper the lobes become, the harder it is to hit their peak. Smaller lights focus more energy in one part of the Bxdf and to a certain extent overcome this by sheer weight of similarly placed samples on the light.

Bxdf samples are very effective at sampling the peak of the Bxdf, but do not sample the diffuse lobe as well (this is altered somewhat if the light is very close to the surface). Notice also that as the lights become smaller, they become harder to hit and antialias less well on the edges.

Multiple importance sampling is able to produce a clean image by combining the two (the only difference between the images is the settings for numLightSamples and numBxdfSamples, where numBxdfSamples is zero in the second image, numLightSamples is zero in the third, and neither is zero in the first.

images/lighting/lightTypes_misCombined.jpg images/lighting/lightTypes_misLight.jpg images/lighting/lightTypes_misBxdf.jpg

Setting sample counts to zero is however a useful diagnostic tool in understanding where any noise might be coming from (as is turning off the indirect transport).