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.
This commit is contained in:
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user