diff --git a/intern/cycles/kernel/bvh/shadow_all.h b/intern/cycles/kernel/bvh/shadow_all.h index bb927ec37be..67372a578b0 100644 --- a/intern/cycles/kernel/bvh/shadow_all.h +++ b/intern/cycles/kernel/bvh/shadow_all.h @@ -222,14 +222,12 @@ ccl_device_inline /* shadow ray early termination */ if (hit) { - /* detect if this surface has a shader with transparent shadows */ - /* todo: optimize so primitive visibility flag indicates if - * the primitive has a transparent shadow shader? */ + /* Detect if this surface has a shader with transparent shadows. */ + /* TODO: optimize so primitive visibility flag indicates if the primitive has a + * transparent shadow shader? */ const int flags = intersection_get_shader_flags(kg, isect.prim, isect.type); - - if (!(flags & SD_HAS_TRANSPARENT_SHADOW) || num_hits >= max_hits) { - /* If no transparent shadows, all light is blocked and we can - * stop immediately. */ + if ((flags & SD_HAS_TRANSPARENT_SHADOW) == 0) { + /* If no transparent shadows, all light is blocked and we can stop immediately. */ return true; } @@ -244,6 +242,9 @@ ccl_device_inline } num_hits++; + if (num_hits > max_hits) { + return true; + } bool record_intersection = true; diff --git a/intern/cycles/kernel/device/cpu/bvh.h b/intern/cycles/kernel/device/cpu/bvh.h index 2dd576351e2..366b24b0a6e 100644 --- a/intern/cycles/kernel/device/cpu/bvh.h +++ b/intern/cycles/kernel/device/cpu/bvh.h @@ -345,7 +345,7 @@ ccl_device_forceinline void kernel_embree_filter_occluded_shadow_all_func_impl( /* If no transparent shadows or max number of hits exceeded, all light is blocked. */ const int flags = intersection_get_shader_flags(kg, current_isect.prim, current_isect.type); - if (!(flags & (SD_HAS_TRANSPARENT_SHADOW)) || ctx->num_hits >= ctx->max_hits) { + if ((flags & SD_HAS_TRANSPARENT_SHADOW) == 0) { ctx->opaque_hit = true; return; } @@ -358,6 +358,10 @@ ccl_device_forceinline void kernel_embree_filter_occluded_shadow_all_func_impl( } ++ctx->num_hits; + if (ctx->num_hits > ctx->max_hits) { + ctx->opaque_hit = true; + return; + } /* Always use baked shadow transparency for curves. */ if (current_isect.type & PRIMITIVE_CURVE) { diff --git a/tests/data b/tests/data index 90bc81396bb..dd2adcac331 160000 --- a/tests/data +++ b/tests/data @@ -1 +1 @@ -Subproject commit 90bc81396bb52e494715ffd2a90aaa11ca2b2ca6 +Subproject commit dd2adcac331b60ae026ca6711dd1cbec9c20c10a