sphere intersection list

hello all,

I have a scene that contain about 30 spheres with other stuffs.

know, I need to know the number, the coordinates and the indices of all spheres hidden partially or entirely by each sphere.
Is there an easy way to do this in Optix?
I am counting to use rtIntersectionDistance with the Ray direction each time to calculate the coordinates of the hit sphere, which should give me a way to determine the index of this sphere.
I am not sure about the way to return these indices, in a 3D rtBuffer is a good idea?

thx

Using rtintersectionDistance is the good way to calculate the hit point and what you want to do should work.

Consider two alternatives:

  • adding the sphere ID as a fourth coordinate of your sphere definition, this way you can use one rtbuffer of the same size as the sphere count and write your result (visible, not visible, partially visible) in the “sphereID-th” element of the rtbuffer, without computing the ID from the position.
  • tracing rays back from the spheres to the eye and use the miss program: if a ray misses the geometry, it hits the eye.

Any good?
L