<p>I'm trying to understand the computation of the path density described in the book <a href="http://www.pbr-book.org/3ed-2018/contents.html" rel="nofollow noreferrer">Physically Based Rendering</a>. They assume that a path <span class="math-container">$$x=(x_0,\ldots,x_{n-1})=(q_0,\ldots,q_{s-1},p_{t-1},\ldots,p_0)$$</span> with <span class="math-container">$s$</span> and <span class="math-container">$t$</span> vertices on the light and camera path, respectively, has been generated. Along with each vertex <span class="math-container">$x_i$</span> they store two densites <span class="math-container">$\overset{{}_{\rightarrow}} p(x_i)$</span> and <span class="math-container">$\overset{{}_{\leftarrow}} p(x_i)$</span>. <span class="math-container">$\overset{{}_{\rightarrow}} p(x_i)$</span> is the "forward" density of <span class="math-container">$x_i$</span>, which is probability per unit area of <span class="math-container">$x_i$</span> as generated by the path sampling algorithm. <span class="math-container">$\overset{{}_{\leftarrow}} p(x_i)$</span> is the hypothetical probability density of <span class="math-container">$x_i$</span> if the direction of light transport was reversed.</p>

<p>Now let <span class="math-container">$p_i(x)$</span> denote the density of sampling the same path <span class="math-container">$x$</span> with the strategy <span class="math-container">$(i, j)$</span>, <span class="math-container">$i + j = s + t$</span>, instead (i.e. the strategy of considering <span class="math-container">$x_0,\ldots,x_{i-1}$</span> and <span class="math-container">$x_i,\ldots,x_{n-1}$</span> as being on the light and camera path, respectively). <a href="http://www.pbr-book.org/3ed-2018/Light_Transport_III_Bidirectional_Methods/Bidirectional_Path_Tracing.html#eq:path-density" rel="nofollow noreferrer">They claim</a> that <span class="math-container">$$p_i(x)=\overset{{}_{\rightarrow}} p(x_0)\cdots\overset{{}_{\rightarrow}} p(x_{i-1})\overset{{}_{\leftarrow}} p(x_i)\cdots\overset{{}_{\leftarrow}} p(x_{n-1})\tag1.$$</span></p>

<blockquote>
  <p>I can't make sense of <span class="math-container">$(1)$</span>. Even if we take <span class="math-container">$i=s$</span> (in which case the <span class="math-container">$(i, j) = (s, t)$</span> is the strategy being used for generating <span class="math-container">$x$</span>), the formula doesn't make sense to me. Shouldn't <span class="math-container">$p_s(x)$</span> be the product of the densities of the light and camera subpaths? The density of the light subpath is clearly <span class="math-container">$\overset{{}_{\rightarrow}} p(x_0)\cdots\overset{{}_{\rightarrow}} p(x_{i-1})$</span>, since the sampling startet at a light source at <span class="math-container">$x_0$</span> and all the densities on the way to <span class="math-container">$x_{i-1}$</span> are "forward densities". On the other hand, the density of the camera subpath should be <span class="math-container">$\overset{{}_{\rightarrow}} p(p_0)\cdots\overset{{}_{\rightarrow}} p(p_{t-1})$</span>, since from <span class="math-container">$x_{n-1}=p_0$</span> all the densities are forward densities as well. However, according to <span class="math-container">$(1)$</span> the density of the camera subpath is <span class="math-container">$\overset{{}_{\leftarrow}} p(p_{t-1})\cdots\overset{{}_{\leftarrow}} p(p_0)$</span>. What am I missing?</p>
</blockquote>

CC BY-SA 4.0
2019-09-13T20:26:03.407Z
You copied (1) wrong, it continues till $n-1$. Even then your question is unclear.
lightxbulb
CC BY-SA 4.0
2019-09-14T04:24:56.620Z
@lightxbulb Yes, there was a typo in $(1)$. The question is why take the product of the reverse densities of the vertices $p_{t-1},\ldots,p_0$ on the camera path and not their forward product? If I understand it correctly, the forward density of $p_i$ should be the density which was used to sample $p_i$ at $p_{i-1}$.
0xbadf00d
CC BY-SA 4.0
2019-09-14T06:30:38.550Z
They have previously defined:
$$p_s(\bar{x}) = \vec{p}(q_0)\cdots\vec{p}(q_{s-1})\overleftarrow{p}(p_{t-1})\cdots\overleftarrow{p}(p_{0})$$
The only difference when taking a different length of subpaths is:
$$p_i(\bar{x}) = \vec{p}(x_0)\cdots\vec{p}(x_{i-1})\overleftarrow{p}(p_i)\cdots\overleftarrow{p}(x_{n-1})$$
That is you just take the probabilities up to $i$ as forward.
lightxbulb
CC BY-SA 4.0
2019-09-14T08:18:41.557Z
@lightxbulb My point is that this formula for $p_s(x)$ doesn't make sense (and they don't *define* it in that way, but claim that it holds). $p_s(x)$ should be the product of the density for obtaining $q_0,\ldots,q_{s-1}$ and the density for obtaining $p_0,\ldots,p_{t-1}$. The former is clearly $\overset{{}_{\rightarrow}} p(q_0)\cdots\overset{{}_{\rightarrow}} p(q_{s-1})$ and the latter should be $\overset{{}_{\rightarrow}} p(p_0)\cdots\overset{{}_{\rightarrow}} p(p_{t-1})$.
0xbadf00d
CC BY-SA 4.0
2019-09-14T08:35:12.120Z
@lightxbulb I think I've found out where the confusion comes from: They always want to understand $\overset{{}_{\rightarrow}} p(x_i)$ and $\overset{{}_{\leftarrow}} p(x_i)$ as the importance transport and radiance transport densities, respectively. They actually write this, but it's highly confusing, since they associate with each such vertex $x_i$ a density `xi.pdfFwd` and `xi.pdfRev` but their meaning is different.
0xbadf00d
<raytracing><rendering><pathtracing><pbr><monte-carlo>
Multiple Importance Sampling in Bidirectional Path Tracing
0xbadf00d
# Multiple Importance Sampling in Bidirectional Path Tracing

(Asked by: username_0 on 2019-09-13)

I'm trying to understand the computation of the path density described in the book [Physically Based Rendering](http://www.pbr-book.org/3ed-2018/contents.html). They assume that a path $$x=(x\_0,\ldots,x\_{n-1})=(q\_0,\ldots,q\_{s-1},p\_{t-1},\ldots,p\_0)$$ with $s$ and $t$ vertices on the light and camera path, respectively, has been generated. Along with each vertex $x\_i$ they store two densites $\overset{{}\_{\rightarrow}} p(x\_i)$ and $\overset{{}\_{\leftarrow}} p(x\_i)$. $\overset{{}\_{\rightarrow}} p(x\_i)$ is the "forward" density of $x\_i$, which is probability per unit area of $x\_i$ as generated by the path sampling algorithm. $\overset{{}\_{\leftarrow}} p(x\_i)$ is the hypothetical probability density of $x\_i$ if the direction of light transport was reversed.

Now let $p\_i(x)$ denote the density of sampling the same path $x$ with the strategy $(i, j)$, $i + j = s + t$, instead (i.e. the strategy of considering $x\_0,\ldots,x\_{i-1}$ and $x\_i,\ldots,x\_{n-1}$ as being on the light and camera path, respectively). [They claim](http://www.pbr-book.org/3ed-2018/Light_Transport_III_Bidirectional_Methods/Bidirectional_Path_Tracing.html#eq:path-density) that $$p\_i(x)=\overset{{}\_{\rightarrow}} p(x\_0)\cdots\overset{{}\_{\rightarrow}} p(x\_{i-1})\overset{{}\_{\leftarrow}} p(x\_i)\cdots\overset{{}\_{\leftarrow}} p(x\_{n-1})\tag1.$$

> I can't make sense of $(1)$. Even if we take $i=s$ (in which case the $(i, j) = (s, t)$ is the strategy being used for generating $x$), the formula doesn't make sense to me. Shouldn't $p\_s(x)$ be the product of the densities of the light and camera subpaths? The density of the light subpath is clearly $\overset{{}\_{\rightarrow}} p(x\_0)\cdots\overset{{}\_{\rightarrow}} p(x\_{i-1})$, since the sampling startet at a light source at $x\_0$ and all the densities on the way to $x\_{i-1}$ are "forward densities". On the other hand, the density of the camera subpath should be $\overset{{}\_{\rightarrow}} p(p\_0)\cdots\overset{{}\_{\rightarrow}} p(p\_{t-1})$, since from $x\_{n-1}=p\_0$ all the densities are forward densities as well. However, according to $(1)$ the density of the camera subpath is $\overset{{}\_{\leftarrow}} p(p\_{t-1})\cdots\overset{{}\_{\leftarrow}} p(p\_0)$. What am I missing?

**Tags:** raytracing, rendering, pathtracing, pbr, monte-carlo

> **Comments:**
> **username_1**: You copied (1) wrong, it continues till $n-1$. Even then your question is unclear.  
> **username_0**: @username_1 Yes, there was a typo in $(1)$. The question is why take the product of the reverse densities of the vertices $p_{t-1},\ldots,p_0$ on the camera path and not their forward product? If I understand it correctly, the forward density of $p_i$ should be the density which was used to sample $p_i$ at $p_{i-1}$.  
> **username_1**: They have previously defined: $$p_s(\bar{x}) = \vec{p}(q_0)\cdots\vec{p}(q_{s-1})\overleftarrow{p}(p_{t-1})\cdots\overleftarrow{p}(p_{0})$$ The only difference when taking a different length of subpaths is: $$p_i(\bar{x}) = \vec{p}(x_0)\cdots\vec{p}(x_{i-1})\overleftarrow{p}(p_i)\cdots\overleftarrow{p}(x_{n-1})$$ That is you just take the probabilities up to $i$ as forward.  
> **username_0**: @username_1 My point is that this formula for $p_s(x)$ doesn't make sense (and they don't *define* it in that way, but claim that it holds). $p_s(x)$ should be the product of the density for obtaining $q_0,\ldots,q_{s-1}$ and the density for obtaining $p_0,\ldots,p_{t-1}$. The former is clearly $\overset{{}_{\rightarrow}} p(q_0)\cdots\overset{{}_{\rightarrow}} p(q_{s-1})$ and the latter should be $\overset{{}_{\rightarrow}} p(p_0)\cdots\overset{{}_{\rightarrow}} p(p_{t-1})$.  
> **username_0**: @username_1 I think I've found out where the confusion comes from: They always want to understand $\overset{{}_{\rightarrow}} p(x_i)$ and $\overset{{}_{\leftarrow}} p(x_i)$ as the importance transport and radiance transport densities, respectively. They actually write this, but it's highly confusing, since they associate with each such vertex $x_i$ a density `xi.pdfFwd` and `xi.pdfRev` but their meaning is different.  

---

## 0 answers

