Interestingly enough, the termination probability (Q below) can be set
any way you want to, using any information you like (and the result
will be unbiased as long as you do the reweighting correctly with the
1/(1-Q) term as below.
So for direct lighting, a typical use would be to evaluate f() and L()
but not compute visibility (shadow ray). If f * L is small, then pick
a high Q value (terminate most of the time). If f*L is big, set Q to
zero if you want to, etc..
Or, if L() is expensive to evaluate, you can just decide based on the
f() value. Or you can set Q regardless of those values; anything is
correct mathematically.
The difficult part is improving efficiency (image variance per time
spent on computation). For example, it'd be silly to set Q = 0.5 all
of the time--although the result would still be correct in the limit,
for half the rays (probabilistically), you'd go through all the work
of tracing the eye ray, evaluating the BRDF, doing texturing, etc,
just to throw it all away (and weight the rays that weren't terminated
with a factor of 2x (1/(1-.5)). You can see there that you'd
definitely be less efficient compared to no Russian roulette at all.
Regarding the questions below, I think the following answers them all
(but send a followup note if you have more questions). The usual
Russian roulette algorithm is basically:
sum = 0
for i = 1 to N samples
a = evaluate the inexpensive terms of the estimate (f, f*L without
visibility, ...)
Q = g(a); // g() is any function of a. Or it can be constant, or
can return RandomFloat() if you don't care about efficiency :-)
if (RandomFloat() < Q)
// ignore this term of the sum, do nothing
else
sum += (1/N) * (evaluate the entire estimate, for real) / (1-Q);
I hope this helps.
Thanks,
-matt