Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/kernel_path_surface.h
| Show First 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | ccl_device bool kernel_branched_path_surface_bounce( | ||||
| /* modify throughput */ | /* modify throughput */ | ||||
| path_radiance_bsdf_bounce(kg, L_state, throughput, &bsdf_eval, bsdf_pdf, state->bounce, label); | path_radiance_bsdf_bounce(kg, L_state, throughput, &bsdf_eval, bsdf_pdf, state->bounce, label); | ||||
| #ifdef __DENOISING_FEATURES__ | #ifdef __DENOISING_FEATURES__ | ||||
| state->denoising_feature_weight *= sc->sample_weight / (sum_sample_weight * num_samples); | state->denoising_feature_weight *= sc->sample_weight / (sum_sample_weight * num_samples); | ||||
| #endif | #endif | ||||
| /* modify path state */ | /* modify path state */ | ||||
| path_state_next(kg, state, label); | path_state_next(kg, state, label, bsdf_get_roughness_sqr(sc)); | ||||
| /* setup ray */ | /* setup ray */ | ||||
| ray->P = ray_offset(sd->P, (label & LABEL_TRANSMIT)? -sd->Ng: sd->Ng); | ray->P = ray_offset(sd->P, (label & LABEL_TRANSMIT)? -sd->Ng: sd->Ng); | ||||
| ray->D = normalize(bsdf_omega_in); | ray->D = normalize(bsdf_omega_in); | ||||
| ray->t = FLT_MAX; | ray->t = FLT_MAX; | ||||
| #ifdef __RAY_DIFFERENTIALS__ | #ifdef __RAY_DIFFERENTIALS__ | ||||
| ray->dP = sd->dP; | ray->dP = sd->dP; | ||||
| ray->dD = bsdf_domega_in; | ray->dD = bsdf_domega_in; | ||||
| ▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | if(sd->flag & SD_BSDF) { | ||||
| /* sample BSDF */ | /* sample BSDF */ | ||||
| float bsdf_pdf; | float bsdf_pdf; | ||||
| BsdfEval bsdf_eval; | BsdfEval bsdf_eval; | ||||
| float3 bsdf_omega_in; | float3 bsdf_omega_in; | ||||
| differential3 bsdf_domega_in; | differential3 bsdf_domega_in; | ||||
| float bsdf_u, bsdf_v; | float bsdf_u, bsdf_v; | ||||
| path_state_rng_2D(kg, state, PRNG_BSDF_U, &bsdf_u, &bsdf_v); | path_state_rng_2D(kg, state, PRNG_BSDF_U, &bsdf_u, &bsdf_v); | ||||
| int label; | int label; | ||||
| float bsdf_roughness_sqr; | |||||
| label = shader_bsdf_sample(kg, sd, bsdf_u, bsdf_v, &bsdf_eval, | label = shader_bsdf_sample(kg, sd, bsdf_u, bsdf_v, &bsdf_eval, | ||||
| &bsdf_omega_in, &bsdf_domega_in, &bsdf_pdf); | &bsdf_omega_in, &bsdf_domega_in, &bsdf_pdf, &bsdf_roughness_sqr); | ||||
| if(bsdf_pdf == 0.0f || bsdf_eval_is_zero(&bsdf_eval)) | if(bsdf_pdf == 0.0f || bsdf_eval_is_zero(&bsdf_eval)) | ||||
| return false; | return false; | ||||
| /* modify throughput */ | /* modify throughput */ | ||||
| path_radiance_bsdf_bounce(kg, L_state, throughput, &bsdf_eval, bsdf_pdf, state->bounce, label); | path_radiance_bsdf_bounce(kg, L_state, throughput, &bsdf_eval, bsdf_pdf, state->bounce, label); | ||||
| /* set labels */ | /* set labels */ | ||||
| if(!(label & LABEL_TRANSPARENT)) { | if(!(label & LABEL_TRANSPARENT)) { | ||||
| state->ray_pdf = bsdf_pdf; | state->ray_pdf = bsdf_pdf; | ||||
| #ifdef __LAMP_MIS__ | #ifdef __LAMP_MIS__ | ||||
| state->ray_t = 0.0f; | state->ray_t = 0.0f; | ||||
| #endif | #endif | ||||
| state->min_ray_pdf = fminf(bsdf_pdf, state->min_ray_pdf); | state->min_ray_pdf = fminf(bsdf_pdf, state->min_ray_pdf); | ||||
| } | } | ||||
| /* update path state */ | /* update path state */ | ||||
| path_state_next(kg, state, label); | path_state_next(kg, state, label, bsdf_roughness_sqr); | ||||
| /* setup ray */ | /* setup ray */ | ||||
| ray->P = ray_offset(sd->P, (label & LABEL_TRANSMIT)? -sd->Ng: sd->Ng); | ray->P = ray_offset(sd->P, (label & LABEL_TRANSMIT)? -sd->Ng: sd->Ng); | ||||
| ray->D = normalize(bsdf_omega_in); | ray->D = normalize(bsdf_omega_in); | ||||
| if(state->bounce == 0) | if(state->bounce == 0) | ||||
| ray->t -= sd->ray_length; /* clipping works through transparent */ | ray->t -= sd->ray_length; /* clipping works through transparent */ | ||||
| else | else | ||||
| Show All 11 Lines | |||||
| #endif | #endif | ||||
| return true; | return true; | ||||
| } | } | ||||
| #ifdef __VOLUME__ | #ifdef __VOLUME__ | ||||
| else if(sd->flag & SD_HAS_ONLY_VOLUME) { | else if(sd->flag & SD_HAS_ONLY_VOLUME) { | ||||
| /* no surface shader but have a volume shader? act transparent */ | /* no surface shader but have a volume shader? act transparent */ | ||||
| /* update path state, count as transparent */ | /* update path state, count as transparent */ | ||||
| path_state_next(kg, state, LABEL_TRANSPARENT); | path_state_next(kg, state, LABEL_TRANSPARENT, 0.0f); | ||||
| if(state->bounce == 0) | if(state->bounce == 0) | ||||
| ray->t -= sd->ray_length; /* clipping works through transparent */ | ray->t -= sd->ray_length; /* clipping works through transparent */ | ||||
| else | else | ||||
| ray->t = FLT_MAX; | ray->t = FLT_MAX; | ||||
| /* setup ray position, direction stays unchanged */ | /* setup ray position, direction stays unchanged */ | ||||
| ray->P = ray_offset(sd->P, -sd->Ng); | ray->P = ray_offset(sd->P, -sd->Ng); | ||||
| Show All 17 Lines | |||||