diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2016-09-09 16:51:40 +0300 |
---|---|---|
committer | Lukas Stockner <lukas.stockner@freenet.de> | 2016-09-14 20:45:12 +0300 |
commit | b459d9f46c5355841aae3048c27cf778c0291566 (patch) | |
tree | d960ef258d5106f7b44db5e6b9a41ce255f43848 /intern/cycles/kernel/split/kernel_direct_lighting.h | |
parent | aae2cea28d0c6c970778674e0ba329b2208b8366 (diff) |
Cycles: Stop lamp sampling if the lamp isn't visible
Both spot and area light have large areas where they're not visible.
Therefore, this patch stops the light sampling code when one of these cases (outside of the spotlight cone or behind the area light) occurs, before the lamp shader is evaluated.
In the case of the area light, the solid angle sampling can also be skipped.
In a test scene with Sample All Lights and 18 Area lamps and 9 Spot lamps that all point away from the area that the camera sees, render time drops from 12sec to 5sec.
Reviewers: brecht, sergey, dingto, juicyfruit
Differential Revision: https://developer.blender.org/D2216
Diffstat (limited to 'intern/cycles/kernel/split/kernel_direct_lighting.h')
-rw-r--r-- | intern/cycles/kernel/split/kernel_direct_lighting.h | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/intern/cycles/kernel/split/kernel_direct_lighting.h b/intern/cycles/kernel/split/kernel_direct_lighting.h index ebe91097496..6ad736fc2c1 100644 --- a/intern/cycles/kernel/split/kernel_direct_lighting.h +++ b/intern/cycles/kernel/split/kernel_direct_lighting.h @@ -74,30 +74,31 @@ ccl_device char kernel_direct_lighting( path_state_rng_2D(kg, rng, state, PRNG_LIGHT_U, &light_u, &light_v); LightSample ls; - light_sample(kg, - light_t, light_u, light_v, - ccl_fetch(sd, time), - ccl_fetch(sd, P), - state->bounce, - &ls); + if(light_sample(kg, + light_t, light_u, light_v, + ccl_fetch(sd, time), + ccl_fetch(sd, P), + state->bounce, + &ls)) { - Ray light_ray; + Ray light_ray; #ifdef __OBJECT_MOTION__ - light_ray.time = ccl_fetch(sd, time); + light_ray.time = ccl_fetch(sd, time); #endif - BsdfEval L_light; - bool is_lamp; - if(direct_emission(kg, sd, kg->sd_input, &ls, state, &light_ray, &L_light, &is_lamp)) { - /* Write intermediate data to global memory to access from - * the next kernel. - */ - LightRay_coop[ray_index] = light_ray; - BSDFEval_coop[ray_index] = L_light; - ISLamp_coop[ray_index] = is_lamp; - /* Mark ray state for next shadow kernel. */ - ADD_RAY_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_DL); - enqueue_flag = 1; + BsdfEval L_light; + bool is_lamp; + if(direct_emission(kg, sd, kg->sd_input, &ls, state, &light_ray, &L_light, &is_lamp)) { + /* Write intermediate data to global memory to access from + * the next kernel. + */ + LightRay_coop[ray_index] = light_ray; + BSDFEval_coop[ray_index] = L_light; + ISLamp_coop[ray_index] = is_lamp; + /* Mark ray state for next shadow kernel. */ + ADD_RAY_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_DL); + enqueue_flag = 1; + } } } #endif /* __EMISSION__ */ |