Often, when we use Optix to conduct raytracing program, we will do as follow.
1.
context->setRayTypeCount( 2 );
material->setClosestHitProgram(0,closet_hit);
material->setAnyHitProgram(1,any_hit);
ray = make_Ray(origin,dir,ray_type,1.e-4f,RT_DEFAULT_MAX);
rtTrace(top_object,ray,ray_load);
Usually, we need 2 types of ray, the radiance ray and shadow ray, so the RayTypeCount is 2. And then, the closest hit program relates to radiance ray, while the any hit program relates to shadow ray, must we observe the regulation? if so, why should we specify ray type when setting ClosestHitProgram and AnyHitProgram? If not, which means, we can do like that:
material->setClosestHitProgram(1,closet_hit);
material->setAnyHitProgram(0,any_hit);
In this case, what does it mean? does it mean that 0 represents shadow ray and 1 represents radiance ray? I am a little confused about the design.
Moreover, if I just want use one type of ray, for example, the shadow ray, then the ray type count should be 1.
context->setRayTypeCount( 1 );
material->setAnyHitProgram(0,any_hit);
3.[code]
ray = make_Ray(origin,dir,0,1.e-4f,RT_DEFAULT_MAX);
rtTrace(top_object,ray,ray_load);
Is it right to do like this?