Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/integrator/integrator_subsurface_disk.h
| Show All 25 Lines | |||||
| { | { | ||||
| const float3 eval = bssrdf_eval(radius, r); | const float3 eval = bssrdf_eval(radius, r); | ||||
| const float pdf = bssrdf_pdf(radius, disk_r); | const float pdf = bssrdf_pdf(radius, disk_r); | ||||
| return (pdf > 0.0f) ? eval / pdf : zero_float3(); | return (pdf > 0.0f) ? eval / pdf : zero_float3(); | ||||
| } | } | ||||
| /* Subsurface scattering step, from a point on the surface to other | /* Subsurface scattering step, from a point on the surface to other | ||||
| * nearby points on the same object. */ | * nearby points on the same object. */ | ||||
| ccl_device_inline bool subsurface_disk(INTEGRATOR_STATE_ARGS, | ccl_device_inline bool subsurface_disk(KernelGlobals kg, | ||||
| IntegratorState state, | |||||
| RNGState rng_state, | RNGState rng_state, | ||||
| ccl_private Ray &ray, | ccl_private Ray &ray, | ||||
| ccl_private LocalIntersection &ss_isect) | ccl_private LocalIntersection &ss_isect) | ||||
| { | { | ||||
| float disk_u, disk_v; | float disk_u, disk_v; | ||||
| path_state_rng_2D(kg, &rng_state, PRNG_BSDF_U, &disk_u, &disk_v); | path_state_rng_2D(kg, &rng_state, PRNG_BSDF_U, &disk_u, &disk_v); | ||||
| /* Read shading point info from integrator state. */ | /* Read shading point info from integrator state. */ | ||||
| const float3 P = INTEGRATOR_STATE(ray, P); | const float3 P = INTEGRATOR_STATE(state, ray, P); | ||||
| const float ray_dP = INTEGRATOR_STATE(ray, dP); | const float ray_dP = INTEGRATOR_STATE(state, ray, dP); | ||||
| const float time = INTEGRATOR_STATE(ray, time); | const float time = INTEGRATOR_STATE(state, ray, time); | ||||
| const float3 Ng = INTEGRATOR_STATE(isect, Ng); | const float3 Ng = INTEGRATOR_STATE(state, isect, Ng); | ||||
| const int object = INTEGRATOR_STATE(isect, object); | const int object = INTEGRATOR_STATE(state, isect, object); | ||||
| /* Read subsurface scattering parameters. */ | /* Read subsurface scattering parameters. */ | ||||
| const float3 radius = INTEGRATOR_STATE(subsurface, radius); | const float3 radius = INTEGRATOR_STATE(state, subsurface, radius); | ||||
| /* Pick random axis in local frame and point on disk. */ | /* Pick random axis in local frame and point on disk. */ | ||||
| float3 disk_N, disk_T, disk_B; | float3 disk_N, disk_T, disk_B; | ||||
| float pick_pdf_N, pick_pdf_T, pick_pdf_B; | float pick_pdf_N, pick_pdf_T, pick_pdf_B; | ||||
| disk_N = Ng; | disk_N = Ng; | ||||
| make_orthonormals(disk_N, &disk_T, &disk_B); | make_orthonormals(disk_N, &disk_T, &disk_B); | ||||
| ▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | ccl_device_inline bool subsurface_disk(KernelGlobals kg, | ||||
| for (int hit = 0; hit < num_eval_hits; hit++) { | for (int hit = 0; hit < num_eval_hits; hit++) { | ||||
| const float3 weight = weights[hit]; | const float3 weight = weights[hit]; | ||||
| const float sample_weight = average(fabs(weight)); | const float sample_weight = average(fabs(weight)); | ||||
| float next_sum = partial_sum + sample_weight; | float next_sum = partial_sum + sample_weight; | ||||
| if (r < next_sum) { | if (r < next_sum) { | ||||
| /* Return exit point. */ | /* Return exit point. */ | ||||
| INTEGRATOR_STATE_WRITE(path, throughput) *= weight * sum_weights / sample_weight; | INTEGRATOR_STATE_WRITE(state, path, throughput) *= weight * sum_weights / sample_weight; | ||||
| ss_isect.hits[0] = ss_isect.hits[hit]; | ss_isect.hits[0] = ss_isect.hits[hit]; | ||||
| ss_isect.Ng[0] = ss_isect.Ng[hit]; | ss_isect.Ng[0] = ss_isect.Ng[hit]; | ||||
| ray.P = ray.P + ray.D * ss_isect.hits[hit].t; | ray.P = ray.P + ray.D * ss_isect.hits[hit].t; | ||||
| ray.D = ss_isect.Ng[hit]; | ray.D = ss_isect.Ng[hit]; | ||||
| ray.t = 1.0f; | ray.t = 1.0f; | ||||
| return true; | return true; | ||||
| Show All 9 Lines | |||||