Path tracer - multi layered materials and importance sampling I'm currently trying to implement a Monte Carlo path tracer. I've done some research and it seems that a common approach to materials is to use a layered model. Something like this:



When light hits the surface, Fresnel tells us how much of that light is reflected by the first layer and how much goes to the second, and so forth.

So I did something similar, but simpler: only one layer of specular and one layer of diffuse. No transmittance yet. So far so good, I use a simple cosine-weighted brdf for my diffuse and the Cook-Torrance microfaceted model for my specular. 

Now comes the hard part: what should I do once a ray hits the surface?
Normally, I'd pick the brdf corresponding to the surface material, sample an incident light direction, evaluate the brdf, and divide by the right probability distribution function.

But here, a surface hit effectively corresponds to multiple materials. The naive way to handle this would be to sample once for each layer hit. But this clearly is source of a huge performance hit, causing my path to effectively become a tree.

Is there a better solution?
Wenzel Jakob et al presented a framework for layered Materials at SIGGRAPH 2014. Section 6.2 explains importance sampling. If you prefer code over equations, the method is implemented in the Mitsuba renderer.