Limiting the path length in a path tracer is super simple.
A forward path tracer integrator which is implemented inside the ray generation program only takes about 40 lines of CUDA code for opaque materials. For transparent materials with absorption add another 40 lines.
The structure looks like the attached image, taken from a support slide of my recent GTC presentation. External Media
The path length is limited by the user defined variable max_depth and the while-loop counts the path segments. That’s all.
That’s basically the for(;;) loop in the path_tracer.cu example replaced with a while (depth < max_depth) statement.
The surrounding loop to shoot multiple paths per pixel per launch is just to converge a little faster. With complex scenes you better don’t do that and shoot only one path per pixel per launch to prevent timeouts under Windows.