# In bidirectional path tracing, is a camera subpath with $n$ vertices determined by a fixed number of random numbers?

In the Multiplexed Metropolis Light Transport implementation of the book Physically Based Rendering, the proposal samples are generated by the Primary Sample Space Sampler MLTSampler.

I'm not sure if I really understand what the authors mean in the following paragraph:

In the context of MLT, the resulting sequence of sample requests creates a mapping between components $$X$$ of and vertices on the camera or light subpath. With the process described above, the components $$X_0,\ldots,X_n$$ determine the camera subpath (for some $$n\in\mathbb N_0$$), and the remaining values $$X_{n+1},\ldots,X_m$$ determine the light subpath. If the camera subpath requires a different number of samples after a perturbation (e.g., because the random walk produced fewer vertices), then there is a shift in the assignment of primary sample space components to the light subpath. This leads to an unintended large-scale modification to the light path.

Does this mean that even for a fixed strategy with $$n\in\mathbb N_0$$ vertices on the camera subpath, the number of random numbers needed to generate such a subpath may vary? Or do they mean that the shift in the assignment is happening only when we switch to an other strategy?

One way of mitigating this issue in practice is to separate the two random number vectors for the camera and light subpaths and always mutate all dimensions of the unit hypercube $$\mathcal{U}^{o(k)}$$, regardless if they are being used or not by the mutation. This doesn't remove the shift caused by BSDF changes (which is unavoidable) but at least you're not spilling your samples between camera and light subpaths.
• Thank you for your answer! "If your ray [...] hits a light source prematurely, you would use fewer samples.": Consider the $(s,t)$-strategy so that we generate a camera subpath with exactly $t$ vertices. If we hit a light source prematurely, then the GenerateCameraSubpath routine returns a vertex count less than $t$ and the PBR implementation returns $0$ radiance. So, "In these cases, you'd keep the subpart of the path that is relevant to avoid discarding the full state.", seems to be wrong. Am I missing something? – 0xbadf00d Jan 7 at 16:12
• I think that I still don't understand the citation: Say the current primary sample space state is $u\in[0,1)^\mathbb N$ and we generated a path $x$ of length $k=s+t-1$ with $s$ and $t$ vertices on the light and camera subpath, respectively, from it. Say the camera subpath was generated using $u_1,\ldots,u_{d_1}$ and the light subpath using $u_{d_1+1},\ldots,u_{d_2}$. In the next iteration $u$ is mutated to $v\in[0,1)^\mathbb N$ (i.e. all dimensions are mutated). If I got you right, then - no matter whether we are still using the $(s,t)$-strategy in the next iteration or any other strategy - – 0xbadf00d Jan 7 at 19:31
• it might be the case that a subset of $v_1,\ldots,v_{d_1}$ is now used for the light subpath and a subset of $v_{d_1+1},\ldots,v_{d_2}$ is now used for the camera subpath (and any dimension $>d_2$ might be used for the light subpath as well). Is this correct? (a) If so, how does the index scheme described in the paragraph solve this problem? (b) You've mentioned the inversion described in RJ-MLT: How does this solve the problem? (c) Is there an implementation of the inversion in PBR available? See also my other question for that: computergraphics.stackexchange.com/q/9443/9254. – 0xbadf00d Jan 7 at 19:31