Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/integrator/integrator_intersect_shadow.h
| Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
| ccl_device bool integrate_intersect_shadow_transparent(INTEGRATOR_STATE_ARGS, | ccl_device bool integrate_intersect_shadow_transparent(INTEGRATOR_STATE_ARGS, | ||||
| ccl_private const Ray *ray, | ccl_private const Ray *ray, | ||||
| const uint visibility) | const uint visibility) | ||||
| { | { | ||||
| Intersection isect[INTEGRATOR_SHADOW_ISECT_SIZE]; | Intersection isect[INTEGRATOR_SHADOW_ISECT_SIZE]; | ||||
| /* Limit the number hits to the max transparent bounces allowed and the size that we | /* Limit the number hits to the max transparent bounces allowed and the size that we | ||||
| * have available in the integrator state. */ | * have available in the integrator state. */ | ||||
| const uint max_transparent_hits = integrate_shadow_max_transparent_hits(INTEGRATOR_STATE_PASS); | const uint max_hits = integrate_shadow_max_transparent_hits(INTEGRATOR_STATE_PASS); | ||||
| const uint max_hits = min(max_transparent_hits, (uint)INTEGRATOR_SHADOW_ISECT_SIZE); | |||||
| uint num_hits = 0; | uint num_hits = 0; | ||||
| bool opaque_hit = scene_intersect_shadow_all(kg, ray, isect, visibility, max_hits, &num_hits); | float throughput = 1.0f; | ||||
| bool opaque_hit = scene_intersect_shadow_all( | |||||
| kg, ray, isect, visibility, max_hits, &num_hits, &throughput); | |||||
| /* Computed throughput from baked shadow transparency, where we can bypass recording | |||||
| * intersections and shader evaluation. */ | |||||
| if (throughput != 1.0f) { | |||||
| INTEGRATOR_STATE_WRITE(shadow_path, throughput) *= throughput; | |||||
| } | |||||
| /* If number of hits exceed the transparent bounces limit, make opaque. */ | /* If number of hits exceed the transparent bounces limit, make opaque. */ | ||||
| if (num_hits > max_transparent_hits) { | if (num_hits > max_hits) { | ||||
| opaque_hit = true; | opaque_hit = true; | ||||
| } | } | ||||
| if (!opaque_hit) { | if (!opaque_hit) { | ||||
| uint num_recorded_hits = min(num_hits, max_hits); | const uint num_recorded_hits = min(num_hits, min(max_hits, INTEGRATOR_SHADOW_ISECT_SIZE)); | ||||
| if (num_recorded_hits > 0) { | if (num_recorded_hits > 0) { | ||||
| sort_intersections(isect, num_recorded_hits); | sort_intersections(isect, num_recorded_hits); | ||||
| /* Write intersection result into global integrator state memory. | /* Write intersection result into global integrator state memory. | ||||
| * More efficient may be to do this directly from the intersection kernel. */ | * More efficient may be to do this directly from the intersection kernel. */ | ||||
| for (int hit = 0; hit < num_recorded_hits; hit++) { | for (int hit = 0; hit < num_recorded_hits; hit++) { | ||||
| integrator_state_write_shadow_isect(INTEGRATOR_STATE_PASS, &isect[hit], hit); | integrator_state_write_shadow_isect(INTEGRATOR_STATE_PASS, &isect[hit], hit); | ||||
| ▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines | |||||