diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2016-10-30 00:47:30 +0300 |
---|---|---|
committer | Lukas Stockner <lukas.stockner@freenet.de> | 2016-10-30 13:31:28 +0300 |
commit | 26bf230920cb9ca0aa9626430169967f9e120482 (patch) | |
tree | 266e7e0939a6471db8af7086635cc4e914c85b06 /intern/cycles/kernel/kernel_random.h | |
parent | ce785868a56a1446750f5af1779f7623ca462ec2 (diff) |
Cycles: Add optional probabilistic termination of light samples based on their expected contribution
In scenes with many lights, some of them might have a very small contribution to some pixels, but the shadow rays are traced anyways.
To avoid that, this patch adds probabilistic termination to light samples - if the contribution before checking for shadowing is below a user-defined threshold, the sample will be discarded with probability (1 - (contribution / threshold)) and otherwise kept, but weighted more to remain unbiased.
This is the same approach that's also used in path termination based on length.
Note that the rendering remains unbiased with this option, it just adds a bit of noise - but if the setting is used moderately, the speedup gained easily outweighs the additional noise.
Reviewers: #cycles
Subscribers: sergey, brecht
Differential Revision: https://developer.blender.org/D2217
Diffstat (limited to 'intern/cycles/kernel/kernel_random.h')
-rw-r--r-- | intern/cycles/kernel/kernel_random.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/intern/cycles/kernel/kernel_random.h b/intern/cycles/kernel/kernel_random.h index 4a76ffddbe7..2372b07d974 100644 --- a/intern/cycles/kernel/kernel_random.h +++ b/intern/cycles/kernel/kernel_random.h @@ -300,6 +300,23 @@ ccl_device_inline void path_branched_rng_2D(KernelGlobals *kg, ccl_addr_space RN path_rng_2D(kg, rng, state->sample*num_branches + branch, state->num_samples*num_branches, state->rng_offset + dimension, fx, fy); } +/* Utitility functions to get light termination value, since it might not be needed in many cases. */ +ccl_device_inline float path_state_rng_light_termination(KernelGlobals *kg, ccl_addr_space RNG *rng, const PathState *state) +{ + if(kernel_data.integrator.light_inv_rr_threshold > 0.0f) { + return path_state_rng_1D_for_decision(kg, rng, state, PRNG_LIGHT_TERMINATE); + } + return 0.0f; +} + +ccl_device_inline float path_branched_rng_light_termination(KernelGlobals *kg, ccl_addr_space RNG *rng, const PathState *state, int branch, int num_branches) +{ + if(kernel_data.integrator.light_inv_rr_threshold > 0.0f) { + return path_branched_rng_1D_for_decision(kg, rng, state, branch, num_branches, PRNG_LIGHT_TERMINATE); + } + return 0.0f; +} + ccl_device_inline void path_state_branch(PathState *state, int branch, int num_branches) { /* path is splitting into a branch, adjust so that each branch |