Is there a way to limit the number of bounces?


I would like to know if limit the number of bounces is possible.
I am working with Path_tracer example and I try to limit them to increase the FPS.

I have found this old post where a user (carstenneumann) said that is possible keeping the count in the “per ray data” for limit them later. But I don´t know where this “bounces” are calculated to count them…

Thanks in advance!

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 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.

Perfect! Thanks by your help!