<p>1) When we have multiple BRDFs, adding thier components together can break energy conservation, as I think you suspect. However most renderers will handle this problem when constructing the layered BRDFs. For example you would might weight each layer or use a fresnel term to decide the weight for each layer.</p>

<p>Here is the spec for arnolds standard shader:</p>

<p><a href="https://i.sstatic.net/7lt3o.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/7lt3o.png" alt="enter image description here"></a></p>

<p><a href="https://autodesk.github.io/standard-surface/" rel="nofollow noreferrer">https://autodesk.github.io/standard-surface/</a></p>

<p>Each layer is multiplied by 1 - previous layer weight, which the artist is setting. This is done inside the fr function, which means that energy conservation is solved here.</p>

<p>2) The pdf is an average, I think, if each bxdf has an equal chance of being sampled. You therefore average the pdf even though each layer may contribute different amounts.</p>

<p>Note: Becareful which value you use for p(wr), this will be the pdf you used to sample your direction, so either the bxdf pdf or the light pdf. (You still need to calculate both pdfs at some point for MIS though.) </p>

CC BY-SA 4.0
2020-05-13T16:18:29.780Z
Hi Peter thanks for your answer. May I ask, for 1), do you mean arnold is actually calculating weighted average (weighted sum here is actually more like an weighted average because it's lerp and lerp and lerp)? Thank you!
swfly
CC BY-SA 4.0
2020-05-13T16:42:59.070Z
If your interseted can read the OSL implementation here https://github.com/Autodesk/standard-surface/blob/master/reference/standard_surface.osl
Peter
CC BY-SA 4.0
2020-05-13T16:45:49.310Z
The best way to think about it is that each layer is revealing the one below it as you reduce it's strength. For example if you have 3 layers of Specular -> Metal -> Diffuse, then you would multiply the diffuse albedo by (1 - specular) * (1 - metal) to get your fr term. This is a simplification but the post I linked shows exactly how each is calculated.
Peter
CC BY-SA 4.0
2020-05-14T02:04:43.260Z
Yes I got that. But still not confident about why PBRT is doing a sum for brdf...
swfly
CC BY-SA 4.0
2020-05-14T10:18:53.107Z
Basically the material or ui, which is the collection of bxdfs, will make sure they are energy conserving when you sum them together. If you just averaged all your bxdfs, they would get equal weight which would make things difficult if, for example, you wanted to have a strong diffuse component and only a subtle amount of specular.
Peter
CC BY-SA 4.0
2020-05-14T10:37:09.650Z
I think I've got your idea: instead of computing simple average, we should calculate the actual brdf more carefully (based on parameters for instance), while, it's still necessary to take care of energy conservation constraint.
swfly
CC BY-SA 4.0
2020-05-13T15:08:25.190Z
2020-05-13T15:08:25.190Z
Peter
<p>I learned in PBRT that to sample direct lighting for a surface a integrator usually calculates the sample as
<span class="math-container">$$
Sample = \frac{L_d(p,\omega_r) f(p,\omega_o,\omega_r)|cos\theta_i|}{p(\omega_r)}
$$</span>
where BRDF <span class="math-container">$f(p,\omega_o,\omega_r)$</span> is the sum of brdf from all the components (for instance microfacet specular &amp; lambertian diffuse), and PDF <span class="math-container">$p(\omega_r)$</span> is the average of all the components. My question is why for <span class="math-container">$f$</span> we calculate sum while for <span class="math-container">$p$</span> it's average. I have the intuition that for <span class="math-container">$f$</span> we should also calculate average.
In addition, why can we use the distribution of importance sampling to evaluate <span class="math-container">$p(\omega_r)$</span> for the given <span class="math-container">$\omega_r$</span>?</p>

<sampling>
Calculate BRDF and PDF when doing direct light sampling
swfly
# Calculate BRDF and PDF when doing direct light sampling

(Asked by: username_0 on 2020-05-13)

I learned in PBRT that to sample direct lighting for a surface a integrator usually calculates the sample as
$$
Sample = \frac{L\_d(p,\omega\_r) f(p,\omega\_o,\omega\_r)|cos\theta\_i|}{p(\omega\_r)}
$$
where BRDF $f(p,\omega\_o,\omega\_r)$ is the sum of brdf from all the components (for instance microfacet specular & lambertian diffuse), and PDF $p(\omega\_r)$ is the average of all the components. My question is why for $f$ we calculate sum while for $p$ it's average. I have the intuition that for $f$ we should also calculate average.
In addition, why can we use the distribution of importance sampling to evaluate $p(\omega\_r)$ for the given $\omega\_r$?

**Tags:** sampling


---

## 1 answers

### Answer by username_1 on 2020-05-13. Score: 1

1) When we have multiple BRDFs, adding thier components together can break energy conservation, as I think you suspect. However most renderers will handle this problem when constructing the layered BRDFs. For example you would might weight each layer or use a fresnel term to decide the weight for each layer.

Here is the spec for arnolds standard shader:

[![enter image description here](https://i.sstatic.net/7lt3o.png)](https://i.sstatic.net/7lt3o.png)

<https://autodesk.github.io/standard-surface/>

Each layer is multiplied by 1 - previous layer weight, which the artist is setting. This is done inside the fr function, which means that energy conservation is solved here.

2) The pdf is an average, I think, if each bxdf has an equal chance of being sampled. You therefore average the pdf even though each layer may contribute different amounts.

Note: Becareful which value you use for p(wr), this will be the pdf you used to sample your direction, so either the bxdf pdf or the light pdf. (You still need to calculate both pdfs at some point for MIS though.)

> **Comments:**
> **username_0**: Hi username_1 thanks for your answer. May I ask, for 1), do you mean arnold is actually calculating weighted average (weighted sum here is actually more like an weighted average because it's lerp and lerp and lerp)? Thank you!  
> **username_1**: If your interseted can read the OSL implementation here https://github.com/Autodesk/standard-surface/blob/master/reference/standard_surface.osl  
> **username_1**: The best way to think about it is that each layer is revealing the one below it as you reduce it's strength. For example if you have 3 layers of Specular -> Metal -> Diffuse, then you would multiply the diffuse albedo by (1 - specular) * (1 - metal) to get your fr term. This is a simplification but the post I linked shows exactly how each is calculated.  
> **username_0**: Yes I got that. But still not confident about why PBRT is doing a sum for brdf...  
> **username_1**: Basically the material or ui, which is the collection of bxdfs, will make sure they are energy conserving when you sum them together. If you just averaged all your bxdfs, they would get equal weight which would make things difficult if, for example, you wanted to have a strong diffuse component and only a subtle amount of specular.  
> **username_0**: I think I've got your idea: instead of computing simple average, we should calculate the actual brdf more carefully (based on parameters for instance), while, it's still necessary to take care of energy conservation constraint.  

---

