diff options
Diffstat (limited to 'intern/cycles/kernel/kernel_emission.h')
-rw-r--r-- | intern/cycles/kernel/kernel_emission.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/intern/cycles/kernel/kernel_emission.h b/intern/cycles/kernel/kernel_emission.h index ac498ba3592..8c7c651a053 100644 --- a/intern/cycles/kernel/kernel_emission.h +++ b/intern/cycles/kernel/kernel_emission.h @@ -65,7 +65,7 @@ ccl_device_noinline float3 direct_emissive_eval(KernelGlobals *kg, shader_setup_from_sample(kg, emission_sd, ls->P, ls->Ng, I, ls->shader, ls->object, ls->prim, - ls->u, ls->v, t, time, false); + ls->u, ls->v, t, time, false, ls->lamp); ls->Ng = ccl_fetch(emission_sd, Ng); @@ -94,7 +94,8 @@ ccl_device_noinline bool direct_emission(KernelGlobals *kg, ccl_addr_space PathState *state, Ray *ray, BsdfEval *eval, - bool *is_lamp) + bool *is_lamp, + float rand_terminate) { if(ls->pdf == 0.0f) return false; @@ -134,7 +135,7 @@ ccl_device_noinline bool direct_emission(KernelGlobals *kg, shader_bsdf_eval(kg, sd, ls->D, eval, ls->pdf, ls->shader & SHADER_USE_MIS); #endif - bsdf_eval_mul(eval, light_eval/ls->pdf); + bsdf_eval_mul3(eval, light_eval/ls->pdf); #ifdef __PASSES__ /* use visibility flag to skip lights */ @@ -155,6 +156,16 @@ ccl_device_noinline bool direct_emission(KernelGlobals *kg, if(bsdf_eval_is_zero(eval)) return false; + if(kernel_data.integrator.light_inv_rr_threshold > 0.0f) { + float probability = max3(bsdf_eval_sum(eval)) * kernel_data.integrator.light_inv_rr_threshold; + if(probability < 1.0f) { + if(rand_terminate >= probability) { + return false; + } + bsdf_eval_mul(eval, 1.0f / probability); + } + } + if(ls->shader & SHADER_CAST_SHADOW) { /* setup ray */ bool transmit = (dot(ccl_fetch(sd, Ng), ls->D) < 0.0f); |