diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-02-20 17:36:07 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-02-22 02:55:32 +0300 |
commit | 5d5c6bb5efee9bd03004845f9b1eee9d43883525 (patch) | |
tree | ad7e8f0278a5e4745e3468d335f062ffa511495d | |
parent | 2d81758aa650256d6b6ed283e43b6c35808ed205 (diff) |
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.
-rw-r--r-- | intern/cycles/kernel/kernel_path_volume.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/intern/cycles/kernel/kernel_path_volume.h b/intern/cycles/kernel/kernel_path_volume.h index b6a856baf24..6275d0d6562 100644 --- a/intern/cycles/kernel/kernel_path_volume.h +++ b/intern/cycles/kernel/kernel_path_volume.h @@ -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; |