Smoothing Discontinuities for Fully Differentiable Ray Tracing#
In a previous work [2], we introduce a smoothing technique that aims at smoothing the discontinuities caused by Ray Tracing in the hope to make optimization through gradient descent easier. This technique was originally implemented in [5], and we now aim to reproduce a similar implementation inside DiffeRT, but with less flexibility to reduce code complexity.
We will not go into details of how the method actually work, nor the actual implementation details, but you can always read the source code or the original paper [2] for more information.
Important
This tutorial is still TODO, but you can find premise of it below.
Smoothing Function#
The smoothing function can be any smooth function \(s: (x;\alpha) \in \mathbb{R} \times \mathbb{R}^+ \mapsto s(x;\alpha) \in [0;1]\), with \(s \in C^1\), with the following properties on the smoothing factor \(\alpha\):
where
In practice, additional constraints are imposed to \(s\), but they are not detailed here. Evaluating \(s(0;\alpha)\) is considered to be undefined behavior, even if it returns actual values (e.g., \(\frac{1}{2}\)), as it might change in the future.
Upstream functions using smoothing#
Currently, only a limited set of functions allow returning a smoothed-out value
instead of a hard boolean decision. The most important function is
TriangleScene.compute_paths. The rest
are downstream functions used by the latter, and can be identified with their optional
smoothing_factor argument.
Boolean equivalents#
The following boolean comparisons are evaluated with the following equivalent real-value functions:
boolean |
real-valued |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
Note the lack of strict equality operator, as it is (currently) not required by upstream functions.
Examples#
In this section, we show usage examples of the smoothing techniques.
But first, we need to import a few packages (the import cell is hidden by default to increase readability).
Coverage Map#
In the cells below, we construct a basic indoor scenario with one blocking object in the center. Then, we compute a rough approximate of the path gain for many receiver positions and different values of smoothing factor (see slider).
set_backend(
"plotly"
) # Our scene is simple, and Plotly is the best backend for online interactive plots :-)
mesh = TriangleMesh.box(length=6, width=4, height=2).set_face_colors(
jnp.asarray([
0.45,
0.27,
0.0,
])
).translate(
jnp.asarray([
0.0,
0.0,
1.0,
])
) + TriangleMesh.plane(
jnp.asarray([0.0, 0.0, 1.0]),
normal=jnp.asarray([1.0, 0.0, 0.0]),
side_length=2.0,
).set_face_colors(jnp.asarray([0.57, 0.57, 0.57]))
scene = TriangleScene(transmitters=jnp.asarray([1.0, 0.0, 1.5]), mesh=mesh)
scene.plot()