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/render | |
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/render')
-rw-r--r-- | intern/cycles/render/integrator.cpp | 8 | ||||
-rw-r--r-- | intern/cycles/render/integrator.h | 2 |
2 files changed, 10 insertions, 0 deletions
diff --git a/intern/cycles/render/integrator.cpp b/intern/cycles/render/integrator.cpp index 63914e57319..a9a33d2e789 100644 --- a/intern/cycles/render/integrator.cpp +++ b/intern/cycles/render/integrator.cpp @@ -65,6 +65,7 @@ NODE_DEFINE(Integrator) SOCKET_BOOLEAN(sample_all_lights_direct, "Sample All Lights Direct", true); SOCKET_BOOLEAN(sample_all_lights_indirect, "Sample All Lights Indirect", true); + SOCKET_FLOAT(light_sampling_threshold, "Light Sampling Threshold", 0.05f); static NodeEnum method_enum; method_enum.insert("path", PATH); @@ -164,6 +165,13 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene kintegrator->sampling_pattern = sampling_pattern; kintegrator->aa_samples = aa_samples; + if(light_sampling_threshold > 0.0f) { + kintegrator->light_inv_rr_threshold = 1.0f / light_sampling_threshold; + } + else { + kintegrator->light_inv_rr_threshold = 0.0f; + } + /* sobol directions table */ int max_samples = 1; diff --git a/intern/cycles/render/integrator.h b/intern/cycles/render/integrator.h index 39eaaf246d4..17fdd0ef1db 100644 --- a/intern/cycles/render/integrator.h +++ b/intern/cycles/render/integrator.h @@ -64,8 +64,10 @@ public: int mesh_light_samples; int subsurface_samples; int volume_samples; + bool sample_all_lights_direct; bool sample_all_lights_indirect; + float light_sampling_threshold; enum Method { BRANCHED_PATH = 0, |