Hello,
I’m attempting to use OptiX 5.1 for a volumetric ray tracing application. I managed to alter Tutorial 1 to index the number of hits via the ray payload with a member variable (hitCount). I incremented it on each hit, then on the second hit, use the ray length to define the color.
I’m now trying to get something similar to work with the mesh viewer application, and I’m experiencing some weirdness. I started by creating a custom first hit program, which dumps the hitCount variable with rtPrintf. I would expect this number to be 1 at all times, since I’m not launching any new rays, but that is not the case. I frequently observe 2 hits, sometimes as many as 5 hits, from this program!
Why would a first hit program fire multiple times for a given launch index?
Here’s my custom debugging program:
RT_PROGRAM void passthrough_hit()
{
if(launch_index.x == 512 && launch_index.y == 512)
{
float3 hit_point = ray.origin + t_hit * ray.direction;
optix::Ray newRay( hit_point, ray.direction, radiance_ray_type, scene_epsilon );
float rayLength = length(hit_point - ray.origin);
prd_radiance.hitCount++;
rtPrintf("Hit count %d -- ray.origin %f,%f,%f -- rayLength %f\n",prd_radiance.hitCount,
ray.origin.x, ray.origin.y, ray.origin.z, rayLength);
}
// Color my cube red, just to confirm I can see it
prd_radiance.result = make_float3(0.5f,0.0f,0.0f);
}
Here’s an example block of the dumped text log:
Hit count 1 – ray.origin 3.575440,9.577191,3.157028 – rayLength 10.166735
Hit count 3 – ray.origin 3.575440,9.577191,3.157028 – rayLength 10.166735
Hit count 1 – ray.origin 3.575440,9.577191,3.157028 – rayLength 10.166735
Hit count 1 – ray.origin 3.575440,9.577191,3.157028 – rayLength 10.166735
Hit count 1 – ray.origin 3.575440,9.577191,3.157028 – rayLength 10.166735
Hit count 2 – ray.origin 3.575440,9.577191,3.157028 – rayLength 10.166735
Hit count 1 – ray.origin 3.575440,9.577191,3.157028 – rayLength 10.166735
Hit count 3 – ray.origin 3.575440,9.577191,3.157028 – rayLength 10.166735