Scope of the attributes to find variables

Hello,

I want to find out the scope of attribute variables. I do not know how. Can someone help me?

Declare attribute variables inside the intersection program.
Calculate and write them only between rtPotentialIntersection and rtReportIntersection there.

Declare the same variables around the anyhit and closesthit programs as needed (unused ones get removed as dead code from the intersection program) and read them there (no write access).

No other scope (e.g. ray generation, miss) can access these attribute variables because there had been no intersection in that case.

http://raytracing-docs.nvidia.com/optix/guide/index.html#programs#4124

You can pass data on to other program domains via the variable with rtPayload semantic.
See this table which program domain can read or read/write different semantic variables.
http://raytracing-docs.nvidia.com/optix/guide/index.html#programs#4045