## Weighted delta tracking question

Practical and theoretical implementation discussion.
dawelter
Posts: 52
Joined: Sun Oct 29, 2017 3:15 pm
Location: Germany

### Weighted delta tracking question

Hello,

I read the recent paper on Spectral and Decomposition Tracking by Kutz et al.
http://drz.disneyresearch.com/~jnovak/p ... index.html

I want to use weighted tracking methods in my own toy path tracer.

Following the PBRT book pg 889, the incident radiance is composed of two terms: the radiance arriving from the distant hit point Tr*Lo and the inscattered radiance integrated along the viewing ray.
pbrt_pg889.png
I evaluate only one of these terms probabilistically. The first, term if no collision was generated, otherwise there is a scattering or absorption even.

As per PBRT I need to weight Tr*Lo with the probability that no interaction takes place, i.e. the probability to hit the surface p_surf. Thus the estimator is Tr*Lo/p_surf.

However, I cannot figure out how to determine the weight Tr/p_surf.

So how is the inscattered radiance combined with the background?

I also took a brief look at Novak's Ratio Tracking paper but there I also failed to find an answer.

Cheers,

shocker_0x15
Posts: 75
Joined: Sun Aug 19, 2012 3:24 pm
Contact:

### Re: Weighted delta tracking question

Hi,

In my understanding, T_r / p_surf becomes the weight computed by cumulatively multiplying the following single step weight:
single_step_weight.png
as in the SD tracking paper.

If this is implemented by following PBRT's interface for example for GridDensityMedium::Sample(),
it returns the above weight if no interaction found, otherwise returns
weight_for_scattering.png
, where w is the cumulative weight until this step.

In the conventional delta tracking,
P_n(x) = \mu_n(x) / \bar{\mu} (this leads the single step weight to 1.)
\bar{\mu} = \mu_a(x) + \mu_s(x) + \mu_n(x).
Therefore, this implementation matches the current PBRT-v3's implementation.

dawelter
Posts: 52
Joined: Sun Oct 29, 2017 3:15 pm
Location: Germany

### Re: Weighted delta tracking question

Thanks! It's true. I had the impression that there needs to be another factor 1/p_surf. But you are right.

I made a quick implementation in python https://github.com/DaWelter/ToyTrace/bl ... racking.py.
It seems to work fine as you say, with the minor exception that I take 1/P_s instead of 1/(1-P_n). (Where did you get that from?)

Using two channels with different u_s and u_a (or sigma, as I named it). Reference:
The Integral = [ 0.60379031 0.04641034]
Transmission to the end = [ 0.33283447 0.86069506]

10k samples:
-----------------
spectral_tracking
-----------------
Interacting fraction: 0.4491
Escaping fraction: 0.5509
Integral estimate: 0.597721 +/- 0.008839, 0.046448 +/- 0.000701
Transmission estimate: 0.331000 +/- 0.004706, 0.879645 +/- 0.011789
-------------------------------
spectral_tracking_no_absorption
-------------------------------
Interacting fraction: 0.4186
Escaping fraction: 0.5814
Integral estimate: 0.609066 +/- 0.008566, 0.046662 +/- 0.000669
Transmission estimate: 0.329594 +/- 0.004540, 0.860574 +/- 0.010576

Looks good. I want to use it to simulate atmospheric scattering. If I understand correctly, strong variation of sigma_t across lambda causes high variance. But since my pathtracer was build for RGB channels I can change things to trace three nearby wavelengths simultaneously.

shocker_0x15
Posts: 75
Joined: Sun Aug 19, 2012 3:24 pm
Contact:

### Re: Weighted delta tracking question

The reason why I wrote 1 / (1 - P_n(x)) is that PBRT-v3's delta tracking implementation only cares about the interaction is null-collision or not, while the integral formulation in the paper simultaneously cares about three types of interaction (scattering, absorption(emission), null-collision).

Therefore, there are two steps until determining that the interaction is scattering in that implementation.
The first is whether the interaction is null-collision or not.
The second is whether the interaction is scattering out of scattering and absorption(emission).
weight_for_scattering_PBRT_style.png
The above expression shows how these steps form the weight.
The first fraction is division by the probability that the interaction is NOT null-collision.
The second fraction is division by the probability that the interaction is scattering out of scattering and absorption.

The denominator of the second fraction becomes scattering albedo in the standard delta tracking, and might be used for Russian roulette decision to continue constructing a light path.

dawelter
Posts: 52
Joined: Sun Oct 29, 2017 3:15 pm
Location: Germany

### Re: Weighted delta tracking question

Ah all right.

The sky is blue. It works!
Single Lambda.
atmosphere_single_lambda.jpg
Spectral. Same number of samples per pixel. Higher render time but the result is worth it.
atmosphere_spectral.jpg
Edit. I managed to do a crude derivation of why this works. Basically taking the delta-source from appendix B into the derivation of the scattering integral estimator.
delta_tracking_derivation.png