Yes, as long as you can fit your payload into the available 8 unsigned int payload registers, use them.
See these device functions: optixTrace() overloads, optixSetPayload_*(), optixGetPayload_*()
I found the following online
That’s literally code from the OptiX SDK examples.
I would recommend to do a “Find in Files” over all *.h; *.cpp; *.cu source files with your favorite text editor inside the OptiX SDK, and then read the documentation about the OptiX device functions used inside the CUDA code.
If you need more data you would need to declare a local payload structure inside your ray generation program and encode the 64-bit pointer to it into two of the payload registers.
Here is my ray generation program using split and merge pointers
(The SDK example use a different implementation, search for packPointer and unpackPointer.)
Even then it still makes sense to keep the most frequently accessed fields in that inside payload registers for performance reasons. Avoid as many memory accesses as you can.
See this thread for related comments.