I have an application that runs a trace against one mesh, and then in the closest_hit program, runs a second trace against a different more-or-less co-located mesh. As suggested to me in a previous post, I’m using a Selector node to pick between the meshes, but I’m wondering if the hack I used in the visit program is necessary. Since attributes aren’t exposed to visit programs, variables are read-only, and the objects are in the same general space, the only way I could come up with to pass index information from closest_hit to visit was to embed a hint in the ray’s tmax property–specifically, an offset based on the intended object (100000.0 to use node 0, 200000.0 to use node1).
This hack is harmless and works fine for my application, but is there any easier/prettier way? Or is the visit program specifically and only intended for ray-based decision-making?