Sunday, March 27, 2016

Bidirectional Path Tracing 2 - From solid angle space to area space

The rendering equation usually looks like this:
$$L( x,\vec{\omega _{o}} )=L_{e}(x, \vec{\omega _{o}})+\int_{\Omega }L_{i}( x_{i},\vec{\omega _{i}} )f_{s}(  x,\vec{\omega _{i}}, \vec{\omega _{o}} )cos \theta d\omega $$
We integrate the incoming radiance over hemisphere with BSDF, plus the emitted radiance and we get the result. The integration is in solid angle domain, therefore when we do the monte carlo estimator, our pdf is in solid angle domain: whether the pdf of sampling bsdf, or the pdf of sampling light (actually we usually sampling area lights in pdf with respect to area domain and then convert it to solid angle domain using equation: \(pdf\omega = pdfA/(cos \theta /d^{2})\) where \(d\) is the distance between intersection point to light surface sample point and  \(\theta\) is the angle between light surface normal and the direction from light surface sampled point to intersection.) The solid angle integration is roughly looks like this:


One of the mindset shifting while reading the paper for me was moving the integration from solid angle domain to area domain. That is: instead of shooting bounce rays around the solid angle hemisphere, we integrate the radiance coming from all the "surfaces in the scene". Replace the \(d\omega\) in solid angle integration with \( cos(\theta_{o}) / r^{2} dx\) in area domain, we see the equation become something like:
$$L( x'\to x'' )=L_{e}( x'\to x')+\int_{A }L_{i}( x \to x' )f_{s}(x \to x' \to x'')G(x \leftrightarrow  x')dx $$
where \(G(x \leftrightarrow  x') = V(x \leftrightarrow  x')\mid cos(\theta_{o})cos( \theta_{i'})\mid/\parallel x - x' \parallel^{2}\) (\(V\) stands for visibility test, aka occlusion test, aka shooting a shadow ray and make sure two point is visible to each other) Veach called this "The three-point form of the transport equations" (see Veach97 8.1) and the \(G\) is usually referred as the "geometry term". The illustration above can be transformed to area domain integration like this:


We are still trying to figure out the radiance \(Lo\) but the integration style is different, the final result value should be the same, ie. two different sampling methods should converge to same result at the end.

With above LTE to compute radiance, we further integrate radiance over the camera lens area and the solid angle extended by focal plane, and then we get the power flow through focal plane and land on camera lens (well in real life focal(film) plane should be behind the camera lens, but this is a commonly used CG approximation model and it made this integration easier to understand)

$$\Phi = \int_{A_{lens}} \int_{\Omega} L(x, \omega_{i}) cos\theta d\omega dx$$

And interesting stuff happened...LTE is a recursive equation (both left side and right side contains unknown value L) If we break it down by recursion levels, the power integration above can be think about as the combination of: integration of all the possible length 1 paths (2 vertices, one on lens, one on light) + integration of all the possible length 2 paths (3 vertices, one on lens, one on scene surfaces, one on light) + integration of all the possible length 3 paths (4 vertices, one on lens, two on scene surfaces, one on light).....+ integration of all possible length \(\infty\) paths...illustrated in the following images:




The cool thing is: there is no necessary order dependency between the area space integration! you can sample p3 and then sample p2, it doesn't matter, it's always "sample a surface point in the scene".  In solid angle space, that is, unidirectional path tracing, we always find the first intersection and then propagate to the first bounce, then second bounce, then third bounce. In area space you just keep choosing the point on surface and connect them together, there are plenty of freedom on the way you choose from surface to form a list of vertex connection (a path), you can start from light and shoot out particle as ray, bounce around the scene....you can start from camera and shoot out viewing ray, bounce around the scene....you can do both, and then connect them together! This is actual one key idea for bidirectional path tracing: there are many ways to skin a cat, we can try them out(....and then figure out which is the best way)

Veach97 formalize this idea as math equations in chapter 8.2 "The path integral formulation". We construct the paths of length 1 to length \(\infty\), we use monte carlo to approximate the integration, and then we can figure out the power flow from scene through film to lens,

Uhh...ya that does sounds kinda cool, but....isn't ray tracing usually want the radiance on a specified pixel instead of this power flow? Can we transform this power flow to radiance? These questions marks pop through my mind while reading through this part, and it's another new concepts "importance \(W_{e}\)" and "measurement equation" come to rescue at last. :)


No comments:

Post a Comment