Cycles: add Russian roulette termination for volume multiple scattering.

This mainly helps with dense volumes, rendering can be 30% faster with
little noise increase in such scenes.
This commit is contained in:
Brecht Van Lommel
2018-02-20 15:36:07 +01:00
parent 2d81758aa6
commit 5d5c6bb5ef

View File

@@ -99,6 +99,23 @@ bool kernel_path_volume_bounce(
/* update path state */
path_state_next(kg, state, label);
/* Russian roulette termination of volume ray scattering. */
float probability = path_state_continuation_probability(kg, state, *throughput);
if(probability == 0.0f) {
return false;
}
else if(probability != 1.0f) {
/* Use dimension from the previous bounce, has not been used yet. */
float terminate = path_state_rng_1D(kg, state, PRNG_TERMINATE - PRNG_BOUNCE_NUM);
if(terminate >= probability) {
return false;
}
*throughput /= probability;
}
/* setup ray */
ray->P = sd->P;
ray->D = phase_omega_in;