Any hit program

I am new to OPTIX.
I want to use it for ray tracing on triangular mesh.
Each triangle in the mesh is opaque (i.e. the ray is perfectly reflected).
Also I want to allow up to 6 secondary rays (i.e. bounces).
For this case does the any hit program is mandatory or the closest hit program suffice?

You do not need an anyhit program for a ray type which only needs to handle the closest hits of opaque objects.
The default anyhit is a no-operation which means you automatically get the closest hit when that ray type traverses the scene.

More explanations here:
[url]http://raytracing-docs.nvidia.com/optix/index.html[/url]
[url]http://raytracing-docs.nvidia.com/optix/guide/index.html#programs#closest-hit[/url]
[url]http://raytracing-docs.nvidia.com/optix/guide/index.html#programs#any-hit[/url]

As OptiX beginner please have a look at the OptiX introduction presentation and example sources.
Links here: [url]https://devtalk.nvidia.com/default/topic/998546/optix/optix-advanced-samples-on-github/[/url]
The fourth example already does what you’re asking for and it’s getting better from there.