Cycles: Optimize of volume stack update when sampling SSS

basically we skip all non-volume objects now in the volume stack function.
Depending on the show it might give some percent of speedup.

Most of the speedup would be gained in the scenes when having SSS object
intersecting the volume and taking a reasonable amount of frame space.
This commit is contained in:
Sergey Sharybin 2014-10-06 12:23:16 +02:00
parent b36eb51d37
commit 233de800e2

@ -375,8 +375,7 @@ ccl_device void kernel_path_subsurface_update_volume_stack(KernelGlobals *kg,
Intersection isect;
const float3 Pend = volume_ray.P + volume_ray.D*volume_ray.t;
while(scene_intersect(kg, &volume_ray, PATH_RAY_ALL_VISIBILITY,
&isect, NULL, 0.0f, 0.0f))
while(scene_intersect_volume(kg, &volume_ray, &isect))
{
ShaderData sd;
shader_setup_from_ray(kg, &sd, &isect, &volume_ray, 0, 0);
@ -384,15 +383,7 @@ ccl_device void kernel_path_subsurface_update_volume_stack(KernelGlobals *kg,
/* Move ray forward. */
volume_ray.P = ray_offset(sd.P, -sd.Ng);
volume_ray.D = normalize_len(Pend - volume_ray.P,
&volume_ray.t);
/* TODO(sergey): Find a faster way detecting that ray_offset moved
* us pass through the end point.
*/
if(dot(ray->D, volume_ray.D) < 0.0f) {
break;
}
volume_ray.t -= sd.ray_length;
}
}
#endif