diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-04-05 19:17:45 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-04-05 19:17:45 +0400 |
commit | 6e93e3329427390c35fb93b2c5add8a639671bb6 (patch) | |
tree | 47785308f6b8341d8cc81e351045180d96f447a1 /intern/cycles/kernel/kernel_accumulate.h | |
parent | 5d0bfc032530018ba20bb13cee5970695753e80b (diff) |
Cycles: add rejection of inf/nan samples, in principle these should not happen
but this makes it more reliable for now.
Also add an integrator "Clamp" option, to clamp very light samples to a maximum
value. This will reduce accuracy but may help reducing noise and speed up
convergence.
Diffstat (limited to 'intern/cycles/kernel/kernel_accumulate.h')
-rw-r--r-- | intern/cycles/kernel/kernel_accumulate.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/intern/cycles/kernel/kernel_accumulate.h b/intern/cycles/kernel/kernel_accumulate.h index 7ba50973444..a78cfc4dfb7 100644 --- a/intern/cycles/kernel/kernel_accumulate.h +++ b/intern/cycles/kernel/kernel_accumulate.h @@ -294,5 +294,49 @@ __device_inline float3 path_radiance_sum(PathRadiance *L) #endif } +__device_inline void path_radiance_clamp(PathRadiance *L, float3 *L_sum, float clamp) +{ + float sum = fabsf(L_sum->x) + fabsf(L_sum->y) + fabsf(L_sum->z); + + if(!isfinite(sum)) { + /* invalid value, reject */ + *L_sum = make_float3(0.0f, 0.0f, 0.0f); + +#ifdef __PASSES__ + if(L->use_light_pass) { + L->direct_diffuse = make_float3(0.0f, 0.0f, 0.0f); + L->direct_glossy = make_float3(0.0f, 0.0f, 0.0f); + L->direct_transmission = make_float3(0.0f, 0.0f, 0.0f); + + L->indirect_diffuse = make_float3(0.0f, 0.0f, 0.0f); + L->indirect_glossy = make_float3(0.0f, 0.0f, 0.0f); + L->indirect_transmission = make_float3(0.0f, 0.0f, 0.0f); + + L->emission = make_float3(0.0f, 0.0f, 0.0f); + } +#endif + } + else if(sum > clamp) { + /* value to high, scale down */ + float scale = clamp/sum; + + *L_sum *= scale; + +#ifdef __PASSES__ + if(L->use_light_pass) { + L->direct_diffuse *= scale; + L->direct_glossy *= scale; + L->direct_transmission *= scale; + + L->indirect_diffuse *= scale; + L->indirect_glossy *= scale; + L->indirect_transmission *= scale; + + L->emission *= scale; + } +#endif + } +} + CCL_NAMESPACE_END |