Cycles: Limit the number of bounces in the shadow linking intersect kernel
Since the previous fix to properly support volumes and transparent objects it became very easy to make it so the intersection loop takes all 1024 iterations to find intersections. This change makes it so the number of intersection is limited by the max number of volume/transparent bounces. This should minimize possible performance impact of the previous fix. Pull Request: https://projects.blender.org/blender/blender/pulls/122448
This commit is contained in:
committed by
Sergey Sharybin
parent
133d6b1a33
commit
fa3eaac0ac
@@ -39,6 +39,11 @@ ccl_device int shadow_linking_pick_mesh_intersection(KernelGlobals kg,
|
||||
|
||||
const uint visibility = path_state_ray_visibility(state);
|
||||
|
||||
int transparent_bounce = INTEGRATOR_STATE(state, path, transparent_bounce);
|
||||
int volume_bounce = INTEGRATOR_STATE(state, path, volume_bounce);
|
||||
|
||||
/* TODO: Replace the look with sequential calls to the kernel, similar to the transparent shadow
|
||||
* intersection kernel. */
|
||||
for (int i = 0; i < SHADOW_LINK_MAX_INTERSECTION_COUNT; i++) {
|
||||
Intersection current_isect ccl_optional_struct_init;
|
||||
current_isect.object = OBJECT_NONE;
|
||||
@@ -77,6 +82,25 @@ ccl_device int shadow_linking_pick_mesh_intersection(KernelGlobals kg,
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Lights past the maximum allowed transparency bounce do not contribute any light, so
|
||||
* consider them as fully blocked and only consider lights prior to this intersection. */
|
||||
if (shader_flags & SD_HAS_TRANSPARENT_SHADOW) {
|
||||
++transparent_bounce;
|
||||
if (transparent_bounce >= kernel_data.integrator.transparent_max_bounce) {
|
||||
ray->tmax = current_isect.t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
kernel_assert(shader_flags & SD_HAS_ONLY_VOLUME);
|
||||
++volume_bounce;
|
||||
if (volume_bounce >= kernel_data.integrator.max_volume_bounce) {
|
||||
ray->tmax = current_isect.t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Move the ray forward. */
|
||||
ray->tmin = intersection_t_offset(current_isect.t);
|
||||
|
||||
Reference in New Issue
Block a user