I don’t know if my problem is more related to OptiX 7.0 or Cuda.
If my question is more related to CUDA, I will look in their forum for an answer.
(I am sadly only an engineer and not a computer scientist, so I hope my question isn’t too trivial)
I am trying to use OptiX for Thermal simulation and want to access how much “Energy” (represented by rays hitting it) reaches each triangle.
Later I will also include reflections (with a different “ray energy”), that’s why I did set up a float buffer with the size of my Triangle Count:
CUdeviceptr d_hitcounter = 0;
size_t float_size = sizeof(float);
CUDA_CHECK(cudaMalloc(reinterpret_cast<void**>(&d_hitcounter),float_size*TRIANGLE_COUNT));
CUDA_CHECK(cudaMemset(reinterpret_cast<void*>(d_hitcounter), 0, float_size*TRIANGLE_COUNT));
Since Nsight doesn’t seem to work for OptiX 7 jet, I don’t know if I did set up the buffer correctly.
Now I want my ch program to write the “ray-energy” to the to the d_hitcount pointer + triangle index. Specifically how do I pass the pointer to the ch function?
Do I have to pass the pointer to the ch() as part of the ray payload? I couldn’t find anything in the documentation, but maybe I have been looking in the wrong place.
Also, how can I prevent two OptiX shaders wanting to write simultaneously to the same address. Is it efficient to use atomicadd to prevent this and will this work within OptiX? As this addition will have to be performed by each ray with an intersection I wanted to make sure to perform this addition in the fastest way possible.
Additionally am I correct to assume, that it’s easiest to assign the ray energy as a ray payload?
Thank you very much for your time and help in advance!
I am looking forward to your answer.