# Direct illumination, specular surfaces, and MIS

Multiple Importance Sampling (MIS) is a technique used by Veach's VCM technique to balance responses of different surfaces to different types of importance sampling for direct illumination. My understanding is that specular surfaces are best lit without sampling the light at all; instead, you pull a direction from the BRDF and hope that it hits the light source. Diffuse surfaces "spread" light more broadly over their domain, so firing rays towards random points on the area covered by the light produces good results without the wastage produced by sampling over the BRDF.

I'm still unsure about a few things, though:

• Veach's demonstration images show flat specular surfaces eventually converging with light sampling; how is this possible? All rays fired towards random points on the light will reach the light (assuming no obstructions), so shouldn't the specular surfaces wash out under all the assumed illumination?
• "Multiple Importance Sampling" implies that tracing gather rays towards the light is an importance-sampled technique (which makes sense, it's very difficult to have invalid rays if all rays approximate the direction of light relative to the surface); does this mean I need to be dividing my direct gathers by a PDF? Given that the "direction" of the light could be anywhere on the unit sphere surrounding the lit point, should the PDF be $4\pi$?

Specular surfaces which use MIS are not perfectly specular like a mirror. They have a small amount of blur, otherwise there is indeed no point in sampling the light as all the samples will evaluate the BRDF as 0. In fact, you would only need to trace a single reflection ray.

A small amount of blur means that a given camera ray will see a small area of the lightsource (assuming it hits where the specular highlight is visible). Thus, a small fraction of the light samples will get a BRDF which is not 0 so it will eventually converge. The less blur, the more samples it will take.

You are correct that such a case will converge faster if you sample only the BRDF. Likewise, a very diffuse BRDF will usually converge faster if you sample only the light. But this is not true if your light is very large and your surface very close to it1. Where MIS shines is that it handles those cases as well as the BRDFs which are neither very diffuse nor very specular.

If you choose to ignore it, what you have to do is a simple integral. There are a few ways to go about it but if you start from MIS equations, just use 0 as the PDF of the BRDF since you're not generating those samples. And be prepared for some cases which won't converge well.

1. The assumption is that the light samples all have a similar contribution to the final result. Even with very good sampling of the light, this must assume that the BRDF will be similar for all light samples. At least I don't know of any direct light sampling formula which takes the cosine term of the diffuse surface into account. Pushing this to the extreme, you can build an example where most of the light is behind the surface, so most of the light samples will contribute nothing at all to the final result. BRDF samples are obviously sent only on the front side of the surface so they might converge faster, even if only a small % of them hit the light.
• So convergence rests on the BRDF being zero/nonzero. How does that work? I've been assuming that the BRDF is just a generator function for ray directions... – Paul Ferris Jan 17 '18 at 4:53
• Also, why shouldn't light sampling accelerate convergence for large, close light sources? If every ray that isn't obstructed is guaranteed to reach the light (which they should be for area lights), then shouldn't light sampling always give a better result for diffuse surfaces? – Paul Ferris Jan 17 '18 at 4:55
• @PaulFerris the BRDF is a function which says how much light is reflected in any given direction. The ray generator function can be any distribution which throws rays everywhere the BRDF is non-zero (eg. a uniform generator over the entire sphere). You get ideal sampling when the generator exactly matches the BRDF but that is not a requirement of MIS. Some BRDFs are very hard to generate rays for perfectly so a different function is often used. I'll edit the answer for your other comment. – Olivier Jan 17 '18 at 16:54
• That makes sense, thank you. So my misunderstanding was treating the BRDF and the ray generator as the same thing when the BRDF really just gives reflectance along the output rays provided by the generator? W.r.t light sampling, would this (imgur.com/a/BC8HV) be an example of the sort of situation you're referring to? – Paul Ferris Jan 22 '18 at 5:39
• @PaulFerris Yes. Although be aware that some older BRDF papers will present only a generator function and a sample weighting function to compensate for the difference between the generator and the BRDF. And yes, the tip of that "cube" nearest the sphere is the kind of thing I had in mind. It would likely have more noise when sampling only the light (sphere) vs MIS. – Olivier Jan 22 '18 at 14:45