Passing parameters from intersection program to closest hit program?

Hi everyone,

Let’s say I have some per vertex attributes for my triangle mesh. I would like to get the interpolated value in the closest hit program. I don’t think it’s possible without the intersection program passing some information(primitive ID or the interpolated value directly) to the closest hit program. Can anyone give me some hints on how this can be implemented?

Thanks very much,

Just like what you have mentioned, the solution requires you to modify the intersection program.

In your intersection program, you have to declare the values that you want to pass as an attribute:

rtDeclareVariable(float3, interpolated_value, attribute interpolated_value, );

And in your material program, you have to declare the attribute that you want to receive from your intersection program:

rtDeclareVariable(float3, interpolated_value, attribute interpolated_value, );

It is similar to how the geometric and shading normals are passed into the material script.

Thanks very much. It works now.