# Multiple Importance Sampling in Bidirectional Path Tracing

I'm trying to understand the computation of the path density described in the book Physically Based Rendering. 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 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?

• You copied (1) wrong, it continues till $n-1$. Even then your question is unclear. – lightxbulb Sep 13 '19 at 20:26
• @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 Sep 14 '19 at 4:24
• 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 Sep 14 '19 at 6:30
• @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 Sep 14 '19 at 8:18
• @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 Sep 14 '19 at 8:35