problem when conducting volume rendering with optix

At the moment, I am working on volume rendering with Optix, usually the volume data is stored in a cubic grid, so I need to get the two points intersected with the ray. However, the optix usually provide us with the closest point rather than two points, is there any method to get the points,and then sample the space between them. The following is a intersection program for a box.

RT_PROGRAM void box_intersect(int)
{
  float3 t0 = (boxmin - ray.origin)/ray.direction;
  float3 t1 = (boxmax - ray.origin)/ray.direction;
  float3 near = fminf(t0, t1);
  float3 far = fmaxf(t0, t1);
  float tmin = fmaxf( near );
  float tmax = fminf( far );

  if(tmin <= tmax)
  {
    bool check_second = true;
    if( rtPotentialIntersection( tmin ) ) 
	{
       texcoord = make_float3( 0.0f );
       shading_normal = geometric_normal = boxnormal( tmin );
       if(rtReportIntersection(0))
         check_second = false;
    } 
    if(check_second) 
	{
      if( rtPotentialIntersection( tmax ) ) 
	  {
        texcoord = make_float3( 0.0f );
        shading_normal = geometric_normal = boxnormal( tmax );
        rtReportIntersection(0);
      }
    }
  }
}

As we can see, the “rtPotentialIntersection” is called twice, the first time is for the near point, and the second is for the far point. So the closest hit program attached with the box will be called twice, but for volume rendering, the closest hit program should be called once, at the same time, the two points should be fetched. Is it possible to get the two points from intersection program or closest hit program? I have no idea how to deal with it. Is there anyone have any idea? Thank you very much for your help.

i am just a optix beginner, but i think the closest hit program is called only one time for one pixel/one ray.

like it s done with the reflection ray, i would start a new closed hit ray from the hit point and hand down the distance by the ray payload.
maybe it also works with an any hit ray. i am excited to hear an expert answer.

i have a question to ur example, would this be the same?

RT_PROGRAM void box_intersect(int)
{
 float3 t0 = (boxmin - ray.origin)/ray.direction;
 float3 t1 = (boxmax - ray.origin)/ray.direction;
 float3 near = fminf(t0, t1);
 float3 far = fmaxf(t0, t1);
 float tmin = fmaxf( near );
 float tmax = fminf( far );

 if(tmin <= tmax)
 {
  float t;
  if(tmin>scene_epsilon){
   t=tmin;
  }else{
   t=tmax;
  }
  if( rtPotentialIntersection( t ) )
  {
   texcoord = make_float3( 0.0f );
   shading_normal = geometric_normal = boxnormal( t );
   rtReportIntersection(0);
  }
}

why should rtReportIntersection get false?