Continuous-wave ToF path tracer (CWToFPathTracerInline)¶
This render pass renders a continuous-wave time-of-flight (CW-ToF) measurement. A CW-ToF camera modulates its light source periodically and correlates the returning light with a reference signal, so a light path contributes according to the phase of its optical length \(\ell(\bar{\mathbf{x}})\) within the modulation period. Each pixel estimates
where \(f\) is the path contribution, \(\lambda\) the modulation wavelength (modulationWavelength, the
path length of one period), \(\phi\) the sensor phase offset in periods (phase) and \(w\) a periodic
waveform with zero mean (waveform):
|
\(w(t)\), with \(s = t - \lfloor t \rfloor\) the position in the period |
|---|---|
|
\(\cos(2\pi s)\) |
|
\(1 - 4\,|c|\), with \(c = s\) for \(s < 1/2\) and \(c = s - 1\) otherwise |
|
\(+1\) for \(|c| < 1/4\), \(-1\) otherwise |
|
\(2s - 1\) |
cos, triangle and box peak at \(s = 0\). With unsignedModulation, the weight is
\(0.5\,w + 0.5\), in \([0, 1]\), instead of \(w\), in \([-1, 1]\). The zero-mean weight is the part that
antithetic sampling targets: the constant part of the unsigned weight is an ordinary, unmodulated
image. The output is the estimate itself; it is not divided by anything.
Camera paths start at the primary hits from VBufferRT, and every vertex is connected to the light
set on LaserLight. Paths are not cut off by length, because the modulation covers all path
lengths.
Parameters¶
Modulation:
Parameter |
Type |
Description |
|---|---|---|
|
float |
Modulation wavelength \(\lambda\): the optical path length of one period, in scene units. Must be
greater than zero. (Default: |
|
float |
Sensor phase offset \(\phi\), in periods ( |
|
float3 |
Added to |
|
string |
Modulation waveform: |
|
boolean |
Weight paths by \(0.5\,w + 0.5\) instead of \(w\). (Default: |
Sampling:
Parameter |
Type |
Description |
|---|---|---|
|
integer |
Camera paths traced per pixel in each frame. Must be greater than zero. (Default: |
|
integer |
Maximum number of surface vertices on a camera path, counting the primary hit. Each vertex is
connected to the light. |
|
boolean |
Importance-sample the BSDF when extending the camera path; otherwise use the material’s
reference sampler (cosine-weighted for standard materials). (Default: |
|
boolean |
Pair every BSDF-sampled vertex with an antithetic vertex, whose path has the opposite
modulation. See Antithetic sampling. (Default: |
Antithetic shift mapping (used with useAntitheticSampling):
Parameter |
Type |
Description |
|---|---|---|
|
string |
How the antithetic vertex is found: |
|
string |
Newton-based methods only: fixes the direction left free by the one path-length constraint.
|
|
float2 |
Chart axis of the |
|
integer |
Newton-based methods only: maximum Newton iterations per shift. (Default: |
|
float |
Tolerance of the shift solve on the path length, relative to the path-length change of the shift,
and at least the float32 resolution of the path lengths involved. Also used by |
|
float |
|
|
boolean |
Keep an antithetic vertex only if shifting it back returns to the starting vertex, at the cost
of a second shift. |
|
boolean |
Newton-based methods with |
Output:
Parameter |
Type |
Description |
|---|---|---|
|
boolean |
Include the shortest path, camera -> primary hit -> light. (Default: |
|
boolean |
Keep one channel of the image, chosen by |
|
string |
The channel kept by |
|
boolean |
Honor alpha-tested materials when tracing rays. (Default: |
Antithetic sampling¶
With a short wavelength, the modulation changes sign many times across the paths a pixel samples,
so independent samples mostly cancel and the estimate is noisy. With useAntitheticSampling, every
BSDF-sampled vertex \(y\) (after the primary hit) gets an antithetic vertex \(y'\) on its surface such that the
path through \(y'\) has the opposite modulation:
cos,triangleandboxsatisfy \(w(t + 1/2) = -w(t)\), so the antithetic path is half a wavelength longer or shorter, \(\ell(y') = \ell(y) \pm \lambda/2\), with equal probability.sawtoothhas no such shift; its antithetic point is the mirror image in the period, \(t \to 1 - t\).
Because the two paths are geometrically close, their contributions are similar but their modulations have opposite signs, so they largely cancel and the variance drops. The primal and antithetic samples are combined with multiple importance sampling (balance heuristic). The two shifts (\(+\lambda/2\) and \(-\lambda/2\), or the mirror with itself) are inverses of each other, so the weights need the density of only these two points: no extra shift is evaluated. Where no antithetic vertex exists (for example, it would leave the surface or be hidden from the previous vertex), the primal sample is used alone, which keeps the estimate unbiased.
This needs the two shifts to be exact inverses of each other. The radial shift mapping guarantees
it: it moves the vertex along the ray from \(m\), the point of the vertex’s plane with the shortest
path length (found in closed form with the mirror construction), and the path length increases along
every such ray, so each target length has one solution on the ray, and the backward shift lands back
on the start. The Newton-based methods move the vertex along the average gradient, the shortest
move; Newton’s method is local, so a rare shift near \(m\) reaches another solution than its reverse
and leaves a small bias, which shiftRoundTripCheck removes. radial works on
planar faces: on finely tessellated curved surfaces, fewer vertices find an antithetic vertex on their
own plane, which reduces the variance reduction but not the correctness.
Antithetic sampling helps most when the wavelength is short compared with the scene (in the Cornell box, below about 0.1 for path lengths around 17): with long wavelengths, the antithetic path is far from the primal path and the two are no longer similar.
Light¶
The light is set on the LaserLight pass, as for the time-gated passes (see Laser). A CW-ToF
camera is usually modeled with a point light at the camera: isLightSourceLaser = false and
laserCollocated = true. With its projector, the light shows a pattern, as the projector of a PMD camera with a
projector does (O’Toole et al. 2014; see Projector).
Transport probing¶
Transport probing (O’Toole et al. 2012, 2014) separates the light of a CW-ToF measurement by where it travels. Each
path is weighted by \(\Pi(i, j)\), from its camera ray \(i\) and its projector ray \(j\), from the light to the path’s last
vertex. The epipolar lines are the planes through the camera and the light. A direct path (camera, surface, light)
and a retro-reflective one (back along the same rays, e.g. by way of a mirror) always lie on their camera ray’s
line, and most indirect paths do not. With the light at the camera (laserCollocated), the planes all hold the
same line, so a path counts as epipolar when its projector ray is its camera ray, and the masks use the image rows.
Parameter |
Type |
Description |
|---|---|---|
|
string |
|
|
float |
Width of an epipolar line, in camera pixels (the vertical angle of a pixel at the center of the image).
(Default: |
|
integer |
|
|
integer |
|
epipolar and non_epipolar add up to the measurement without probing, path by path. Probing needs the point light
(or its projector); it is off with the laser beam. Depth from the phase of the epipolar measurement is free of the
multipath error that indirect light adds to the conventional one: in a white corner with a box, the median depth
error falls from 103 mm to below 0.1 mm with the light at the camera, and from 122 mm to 0.8 mm with a 0.3 m baseline.
Inputs and outputs¶
Channel |
Description |
|---|---|
|
Primary hits, from |
|
Primary ray directions, from |
|
CW-ToF measurement \(I\), RGBA32Float. With the signed weight it can be negative. Pixels with no primary hit are black: the environment map is not part of the measurement. |
Example¶
testbed.load_scene("cornell-box/scene-v4-nolight.pbrt", falcor.SceneBuilderFlags.DontMergeMaterials)
graph = testbed.create_render_graph("CWToF")
graph.create_pass("VBuffer", "VBufferRT", {"samplePattern": "Center", "sampleCount": 1})
graph.create_pass("Light", "LaserLight", {"isLightSourceLaser": False, "laserCollocated": True})
graph.create_pass("Tracer", "CWToFPathTracerInline", {
"samplesPerPixel": 8, "maxBounces": 3, "computeDirect": False,
"waveform": "cos", "modulationWavelength": 0.01,
})
graph.add_edge("VBuffer.vbuffer", "Tracer.vbuffer")
graph.add_edge("VBuffer.viewW", "Tracer.viewW")
graph.add_edge("Light", "Tracer") # run the light pass first
graph.mark_output("Tracer.color")
testbed.render_graph = graph
See the CW-ToF tutorial for a complete script.
References¶
M. O’Toole, R. Raskar and K. N. Kutulakos. Primal-dual coding to probe light transport. ACM Transactions on Graphics (SIGGRAPH) 31(4), 2012.
M. O’Toole, F. Heide, L. Xiao, M. B. Hullin, W. Heidrich and K. N. Kutulakos. Temporal frequency probing for 5D transient analysis of global light transport. ACM Transactions on Graphics (SIGGRAPH) 33(4), 2014.