Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/split/kernel_direct_lighting.h
| Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | #ifdef __EMISSION__ | ||||
| if((kernel_data.integrator.use_direct_light && | if((kernel_data.integrator.use_direct_light && | ||||
| (ccl_fetch(sd, flag) & SD_BSDF_HAS_EVAL))) | (ccl_fetch(sd, flag) & SD_BSDF_HAS_EVAL))) | ||||
| { | { | ||||
| /* Sample illumination from lights to find path contribution. */ | /* Sample illumination from lights to find path contribution. */ | ||||
| ccl_global RNG* rng = &rng_coop[ray_index]; | ccl_global RNG* rng = &rng_coop[ray_index]; | ||||
| float light_t = path_state_rng_1D(kg, rng, state, PRNG_LIGHT); | float light_t = path_state_rng_1D(kg, rng, state, PRNG_LIGHT); | ||||
| float light_u, light_v; | float light_u, light_v; | ||||
| path_state_rng_2D(kg, rng, state, PRNG_LIGHT_U, &light_u, &light_v); | path_state_rng_2D(kg, rng, state, PRNG_LIGHT_U, &light_u, &light_v); | ||||
| float terminate = path_state_rng_light_termination(kg, rng, state); | |||||
| LightSample ls; | LightSample ls; | ||||
| if(light_sample(kg, | if(light_sample(kg, | ||||
| light_t, light_u, light_v, | light_t, light_u, light_v, | ||||
| ccl_fetch(sd, time), | ccl_fetch(sd, time), | ||||
| ccl_fetch(sd, P), | ccl_fetch(sd, P), | ||||
| state->bounce, | state->bounce, | ||||
| &ls)) { | &ls)) { | ||||
| Ray light_ray; | Ray light_ray; | ||||
| #ifdef __OBJECT_MOTION__ | #ifdef __OBJECT_MOTION__ | ||||
| light_ray.time = ccl_fetch(sd, time); | light_ray.time = ccl_fetch(sd, time); | ||||
| #endif | #endif | ||||
| BsdfEval L_light; | BsdfEval L_light; | ||||
| bool is_lamp; | bool is_lamp; | ||||
| if(direct_emission(kg, sd, kg->sd_input, &ls, state, &light_ray, &L_light, &is_lamp)) { | if(direct_emission(kg, sd, kg->sd_input, &ls, state, &light_ray, &L_light, &is_lamp, terminate)) { | ||||
| /* Write intermediate data to global memory to access from | /* Write intermediate data to global memory to access from | ||||
| * the next kernel. | * the next kernel. | ||||
| */ | */ | ||||
| LightRay_coop[ray_index] = light_ray; | LightRay_coop[ray_index] = light_ray; | ||||
| BSDFEval_coop[ray_index] = L_light; | BSDFEval_coop[ray_index] = L_light; | ||||
| ISLamp_coop[ray_index] = is_lamp; | ISLamp_coop[ray_index] = is_lamp; | ||||
| /* Mark ray state for next shadow kernel. */ | /* Mark ray state for next shadow kernel. */ | ||||
| ADD_RAY_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_DL); | ADD_RAY_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_DL); | ||||
| enqueue_flag = 1; | enqueue_flag = 1; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| #endif /* __EMISSION__ */ | #endif /* __EMISSION__ */ | ||||
| } | } | ||||
| return enqueue_flag; | return enqueue_flag; | ||||
| } | } | ||||