Signed int to unsigned int in payload

Hello there, I am trying to store an index which includes negative numbers in optix payloads. What is the preferred method to cast to and from unsigned int to int for storing as ray payloads?

Hi @AidenLewis, you can store signed integers with e.g.

optixSetPayload_0( static_cast<unsigned int>(mySignedInt) );

and read them with

int mySignedInt = static_cast<int>(optixGetPayload_0());

1 Like