7
$\begingroup$

I'm wondering about the technique used when sampling a layered material for the next event in a path tracer. I have a material with three layers: a base diffuse, specular and sheen lobes. How does one go about choosing a discrete layer to sample for the next ray direction? Is this just a random selection? If so, are equal weights assigned to the layers or are weights used based on final contribution of a lobe? Thanks for any insight into this stage of sampling.

~M

$\endgroup$
9
$\begingroup$

This question is somewhat related to this one.

As Alan has already said, following the actual path of the light ray through each layer leads to more physically accurate results. I will base my answer on a paper by Andrea Weidlich and Alexander Wilkie ("Arbitrarily Layered Micro-Facet Surfaces") that I have read and partially implemented. In their paper they assume that the distance between two layers is smaller than the radius of a differential area element. This simplifies the implementation because we do not have to calculate intersection points separately for each layer, actually we assume that the intersection points are the same for all layers.

According to the paper, two problems must be solved in order to render multilayered material. The first one is to properly sample the layers and the second is to find the resulting BSDF generated by the combination of the multiple BSDFs that are found along the sampling path.

UPDATE: Actually I have adopted a different method to implement the evaluation of this layered model. While I have kept the idea of considering the intersection points to be just the same point along the layers, I have computed the sampling and the final BRDF differently: for sampling, I have used ordinary ray tracing, but through the layers (using Russian Roulette to select between reflection/refraction when that's the case); for the final BRDF evaluation, I just multiply each BRDF traversed by the ray path (weighting the incident radiances according to the cosine of the incident ray).

Sampling

In this first stage we will determine the actual light path through the layers. When a light ray is moving from a less dense medium, e.g. air, to a more dense medium, e.g. glass, part of its energy is reflected and the remaining part is transmitted. You can find the amount of energy that is reflected through the Fresnel reflectance equations. So, for instance, if the Fresnel reflectance of a given dielectric is 0.3, we know that 30% of the energy is reflected and 70% will be transmitted:

enter image description here

When the light ray is moving from a more dense to a less dense medium, the same principle described by the Fresnel reflectance applies. However, in this specific case, total internal reflection (a.k.a TIR) might also happen if the angle of the incident ray is above the critical angle. In the case of TIR, 100% of the energy is reflected back into the material:

enter image description here

When light hits a conductor or a diffuse surface, it will always be reflected (being the direction of reflection related to the type of the BRDF). In a multilayer material, the resulting light path will be the agregate result of all those possibilities. Thus, in the case of a 3-layer material, assuming that the first and secong layers are dielectrics and the third layer is diffuse, we might end up with the following light path (a tree actually):

enter image description here

We can simulate this type of interaction using recursion and weighting each light path according to the actual reflectance/transmitance at the corresponding incident point. A problem regarding the use of recursion is that the number of rays increases with the deepness of the recursion, concentrating computational effort on rays that individually might contribute almost nothing to the final result. On the other hand, the aggregate result of those individual rays at deep recursion levels can be significant and should not be discarded. In this case, we can use Russian Roulette (RR) in order to avoid branching and to probabilistic end light paths without losing energy, but at the cost of a higher variance (noisier result). In this case, the result of the Fresnel reflectance, or the TIR, will be used to randomly select which path to follow. For instance:

enter image description here

As can be seen, TIR or Fresnel reflectance might keep some rays bouncing indefinitely among layers. As far as I know, Mitsuba implements plastic as a two layer material, and it uses a closed form solution for this specific case that accounts for an infinity number of light bounces among layers. However, Mitsuba also allows for the creation of multilayer materials with an arbitrary number of layers, in which case it imposes a maximum number of internal bounces since no closed form solution seems to exist for the general case. As a side effect, some energy can be lost in the rendering process, making the material look darker than it should be.

In my current multilayer material implementation I allow for an arbitrary number of internal bounces at the cost of longer rendering times (well... actually, I've implemented only two layers.. one dielectric and one diffuse :).

An additional option is to mix branching and RR. For instance, the initial rays (lower deep levels) might present substantial contribution to the final image. Thus, one might choose to branch only at the first one or two intersections, using only RR afterwards. This is the case with smallpt.

An interesting point regarding multilayered materials is that individual reflected/transmitted rays can be importance sampled according to the corresponding BRDFs/BTDFs of the current layer.

Evaluating the Final BSDF

Considering the following light path computed using RR:

enter image description here

We can evaluate the total amount of radiance $L_r$ reflected by a multilayer BSDF considering each layer as a individual object and applying the same approach used in ordinary path tracing (i.e. the radiance leaving a layer will be the incident radiance for the next layer). The final estimator can thus be represented by the product of each individual Monte Carlo estimator:

$$ L_r = \left( \frac{fr_1 \cos \theta_1}{pdf_1} \left( \frac{fr_2 \cos \theta_2}{pdf_2} \left( \frac{fr_3 \cos \theta_3}{pdf_3} \left( \frac{fr_2 \cos \theta_4}{pdf_2} \left( \frac{L_i fr_1 \cos \theta_5}{pdf_1} \right)\right)\right)\right)\right)$$

The paper by Andrea Weidlich and Alexander Wilkie also takes absorption into consideration, i.e. each light ray might be attenuated according to the absorption factor of each transmissive layer and to the distance traveled by the ray within the layer. I've not included absorption into my renderer yet, but it is just a real coefficient computed according to the Beer's Law.

Alternate approaches

The Mitsuba renderer uses an alternate representation for multilayered material based on the "tabulation of reflectance functions in a Fourier basis". I have not yet dig into it, but might be of interest: "A Comprehensive Framework for Rendering Layered Materials" by Wenzel Jacob et al. There is also an expanded version of this paper.

$\endgroup$
  • 1
    $\begingroup$ I want to ask (hoping you remember the paper) if you are sure about adding cosine terms for every layer? As far as I understand, we calculate the rendering equation only on the top layer. We go downwards to determine final outgoing direction and to determine BRDF. Do I miss something? $\endgroup$ – Mustafa Işık Sep 23 '18 at 11:31
  • $\begingroup$ @MustafaIşık You are right, in the paper they do not add the cosine terms to the final BRDF. Actually, I have adopted an approach a bit different from the one proposed in the paper (I will include that to my answer). In the paper, they propose the definition of an unique BRDF from the layered BRDFs. I found the derivation process a bit confusing: 1) I do not understand why they add the individual BRDFs (I think they should be multiplied); $\endgroup$ – Christian Pagot Sep 25 '18 at 15:26
  • $\begingroup$ @MustafaIşık 2) as you have pointed out, there is no multiplication by the cosine term (I think you have to because we are considering only the energy that is incident on a differential area); 3) they do not develop the expression $t=(1−G)+T21⋅G$; 4) I do not know if they have diluted the cosine term inside the BRDF; 5) also, TIR may cause energy loss. Due those reasons, I have decided to trace each ray using Russian-Roulette to decide for refraction or reflection, at the cost of longer rendering times then those eventually obtained by them. $\endgroup$ – Christian Pagot Sep 25 '18 at 15:28
  • 1
    $\begingroup$ The paper looks straightforward but it's not since not every term nor strategy is explained clearly enough for an exact implementation. It is influential, though. Yours is more like a simulation avoided by the paper but more accurate. $\endgroup$ – Mustafa Işık Sep 25 '18 at 18:52
2
$\begingroup$

Thinking about it from a physical standpoint, it seems that it would work like a generalized version of diffuse / specular calculation.

You'd start with the top most layer and use fresnel etc to calculate a percentage of light that reflects vs transmits. You then use a random number to determine which of these to do for your sample.

In the case of reflection, you'd do the specular lobe of your top most layer, reflect off the surface and move on.

In the case of transmission, you'd move to the 2nd layer.

At this layer, you'd once again calculate the percentage chance to reflect vs transmit.

In the case of reflection, you'd use the specular lobe of this second layer, do the reflection and move on.

In the case of transmission, you'd move to the inner layer.

For this inner most layer you'd once again figure out if you needed to reflect or transmit.

For reflection you'd use this inner layer's specular lobe.

For transmission, you'd do your diffuse calculation, or whatever else your inner most surface wants to do for transmitted light (sub surface scattering? refraction? etc).

I'm uncertain if each layer should do it's own refraction and if technically you should move the ray a tiny bit between layers to get more realistic effects. For your case it may not make a difference.

But basically, if you had a sphere with 3 layers on it, it SHOULD behave as if you had 3 different spheres nested in one another that each had a single layer that handled transmission vs reflection.

Having a layered material is just a more compact way of saying that this is what you want, compared to having the three separate objects.

$\endgroup$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.