@@ -19,8 +19,8 @@ struct RayPayload {
1919 * NOTE: This assumes that reinterpret_cast from void pointer to RayPayload works correctly. */
2020struct ShadowPayload : RayPayload {
2121 int in_state ;
22- uint max_hits ;
23- uint num_hits ;
22+ uint max_transparent_hits ;
23+ uint num_transparent_hits ;
2424 uint * r_num_recorded_hits ;
2525 float * r_throughput ;
2626};
@@ -380,8 +380,8 @@ ccl_device_inline bool shadow_intersection_filter(const hiprtRay &ray,
380380{
381381 KernelGlobals kg = payload -> kg ;
382382
383- const uint num_hits = payload -> num_hits ;
384- const uint max_hits = payload -> max_hits ;
383+ uint num_transparent_hits = payload -> num_transparent_hits ;
384+ const uint max_transparent_hits = payload -> max_transparent_hits ;
385385 const int state = payload -> in_state ;
386386 const RaySelfPrimitives & self = payload -> self ;
387387
@@ -407,7 +407,9 @@ ccl_device_inline bool shadow_intersection_filter(const hiprtRay &ray,
407407 return true; /* No hit -continue traversal. */
408408 }
409409
410- if (intersection_skip_shadow_already_recoded (kg , state , object , prim , num_hits )) {
410+ if (intersection_skip_shadow_already_recoded (
411+ kg , state , object , prim , * payload -> r_num_recorded_hits ))
412+ {
411413 return true;
412414 }
413415
@@ -418,18 +420,22 @@ ccl_device_inline bool shadow_intersection_filter(const hiprtRay &ray,
418420# ifndef __TRANSPARENT_SHADOWS__
419421 return false;
420422# else
421- if (num_hits >= max_hits ||
422- !(intersection_get_shader_flags (kg , prim , primitive_type ) & SD_HAS_TRANSPARENT_SHADOW ))
423- {
423+ const int flags = intersection_get_shader_flags (kg , prim , primitive_type );
424+ if (!(flags & SD_HAS_TRANSPARENT_SHADOW )) {
425+ return false;
426+ }
427+
428+ num_transparent_hits += !(flags & SD_HAS_ONLY_VOLUME );
429+ if (num_transparent_hits > max_transparent_hits ) {
424430 return false;
425431 }
426432
427433 uint record_index = * payload -> r_num_recorded_hits ;
428434
429- payload -> num_hits = num_hits + 1 ;
435+ payload -> num_transparent_hits = num_transparent_hits ;
430436 * (payload -> r_num_recorded_hits ) += 1 ;
431437
432- const uint max_record_hits = min ( max_hits , INTEGRATOR_SHADOW_ISECT_SIZE ) ;
438+ const uint max_record_hits = INTEGRATOR_SHADOW_ISECT_SIZE ;
433439 if (record_index >= max_record_hits ) {
434440 float max_recorded_t = INTEGRATOR_STATE_ARRAY (state , shadow_isect , 0 , t );
435441 uint max_recorded_hit = 0 ;
@@ -467,9 +473,9 @@ ccl_device_inline bool shadow_intersection_filter_curves(const hiprtRay &ray,
467473{
468474 KernelGlobals kg = payload -> kg ;
469475
470- const uint num_hits = payload -> num_hits ;
476+ uint num_transparent_hits = payload -> num_transparent_hits ;
471477 const uint num_recorded_hits = * (payload -> r_num_recorded_hits );
472- const uint max_hits = payload -> max_hits ;
478+ const uint max_transparent_hits = payload -> max_transparent_hits ;
473479 const RaySelfPrimitives & self = payload -> self ;
474480
475481 const int object = kernel_data_fetch (user_instance_id , hit .instanceID );
@@ -494,7 +500,10 @@ ccl_device_inline bool shadow_intersection_filter_curves(const hiprtRay &ray,
494500 return true; /* No hit -continue traversal. */
495501 }
496502
497- if (intersection_skip_shadow_already_recoded (kg , payload -> in_state , object , prim , num_hits )) {
503+ /* FIXME: transparent curves are not recorded, this check doesn't work. */
504+ if (intersection_skip_shadow_already_recoded (
505+ kg , payload -> in_state , object , prim , num_recorded_hits ))
506+ {
498507 return true;
499508 }
500509
@@ -510,16 +519,20 @@ ccl_device_inline bool shadow_intersection_filter_curves(const hiprtRay &ray,
510519# ifndef __TRANSPARENT_SHADOWS__
511520 return false;
512521# else
513- if (num_hits >= max_hits ||
514- !(intersection_get_shader_flags (kg , prim , primitive_type ) & SD_HAS_TRANSPARENT_SHADOW ))
515- {
522+ const int flags = intersection_get_shader_flags (kg , prim , primitive_type );
523+ if (!(flags & SD_HAS_TRANSPARENT_SHADOW )) {
524+ return false;
525+ }
526+
527+ num_transparent_hits += !(flags & SD_HAS_ONLY_VOLUME );
528+ if (num_transparent_hits > max_transparent_hits ) {
516529 return false;
517530 }
518531
519532 float throughput = * payload -> r_throughput ;
520533 throughput *= intersection_curve_shadow_transparency (kg , object , prim , primitive_type , u );
521534 * payload -> r_throughput = throughput ;
522- payload -> num_hits += 1 ;
535+ payload -> num_transparent_hits = num_transparent_hits ;
523536
524537 if (throughput < CURVE_SHADOW_TRANSPARENCY_CUTOFF ) {
525538 return false;
0 commit comments