I am trying to log closest hit point, but am getting strange results. Any ideas why?

I am debugging my optix shader, and am getting results that I don’t understand. First off I just have a simple cube in the scene, and my closet hit program is correctly show the color/texture. For something else I wanted to quickly do some analysis on these hit points in matlab, so I just added some printf’s in the shader, but I would expect that all the hit points would basically be a point cloud that shows the cube, but instead it is very sparse, and can barely make out a cube. Definitely not the same as image view. Another thing I don’t understand, is there isn’t the same amount of hit points every time. What am I doing wrong?

const vec3f ray_orig = optixGetWorldRayOrigin();
const vec3f ray_dir = optixGetWorldRayDirection(); // incident direction
const float ray_t = optixGetRayTmax();
vec3f hit_point = ray_orig + ray_t * ray_dir;

If you’re relying on a printf() inside your shader to print out all the hit points on screen, that might be the problem. CUDA’s printf is designed for a small amount of output, and has a text buffer that is limited in size.

In order to print all of your hit points, you should render your hit data into a frame buffer, transfer that buffer back to the host, and then do all the printf work on the host side.